Skip to content

Instantly share code, notes, and snippets.

@theinventor
Last active December 18, 2015 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theinventor/5833250 to your computer and use it in GitHub Desktop.
Save theinventor/5833250 to your computer and use it in GitHub Desktop.
Example jsonify builder view for making a nice blob to drive a highcarts widget on geckoboard :)
#we populated some @markets sort of like this;
# @results << OpenStruct.new(name: group[1].first.city.title, color: colors[index], data: [], city_id: group[0])
# later.... each result.data << photos_that_day.to_i
json.chart do
json.type 'column'
json.backgroundColor 'rgba(255, 255, 255, 0.1)'
json.style do
json.fontFamily 'monospace'
json.color "#000"
end
end
json.title do
json.text 'Photo Uploads per Day'
json.style do
json.fontFamily 'monospace'
json.color '#fff'
end
end
json.subtitle do
json.text 'Top 4 markets'
json.style do
json.fontFamily 'monospace'
json.color '#fff'
end
end
json.xAxis do
json.categories @axis_date_labels
end
json.yAxis do
json.min 0
json.title do
json.text 'Photos (count)'
json.style do
json.fontFamily 'monospace'
json.color '#fff'
end
end
end
json.tooltip do
json.headerFormat '<span style="font-size:10px">{point.key}</span><table>'
json.pointFormat '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
'<td style="padding:0"><b>{point.y:.1f} photos</b></td></tr>'
json.footerFormat '</table>'
json.shared true
json.useHTML true
end
json.legend do
json.itemStyle do
json['font-size'.to_sym] = '12px'
json['color'.to_sym] = '#ffffff'
end
end
json.plotOptions do
json.column do
json.pointPadding 0.2
json.borderWidth 0
end
end
json.series(@results) do |market|
json.name market.name
json.color market.color
json.data market.data
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment