简体   繁体   中英

generating graphs using chartkick in rails 4

I am using chartkick to generate graphs in my Rails 4 application. I need to map the clickcount of each of my affiliates into a graph for the maintainer of the affiliate sites. So I have used the following

<%= column_chart [name:@affiliate_person.affiliates.map{|t| [t.name]} , data: @affiliate_person.affiliates.map{|t| [t.click_count] }] %>

Each affiliate_person will have many affiliates and I want to show for each affiliate site how much clicks have been generated. How do I do this? The readme is not very helpful

I believe the issue is a column chart just needs a 1-1 association for a label of the data and the amount to represent. Try this:

column_chart @affiliate_person.affiliates.map { |t| [t.name, t.click_count] }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM