Guest User

Untitled

a guest
Oct 7th, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rails 0.48 KB | None | 0 0
  1. @lazybrandv = LazyHighCharts::HighChart.new('graph') do |f|
  2.             f.options[:chart][:defaultSeriesType] = "pie"  
  3.             f.options[:title][:text] = "Top Brands by Volume"
  4.             @piedata=[]
  5.           @brands.each do |brand|
  6.             @piedata.push [Brand.find(brand.brand_id).name, brand.avg_score.to_f]
  7.             end
  8.             @piedata = @piedata.sort_by(&:last).reverse
  9.             @piedata = @piedata.each_with_index.to_a.map! { |(brand, score), index| brand = "#{index+1}: #{brand}", score }
  10.             f.series(:data=>@piedata)
  11.         end
Add Comment
Please, Sign In to add comment