Show HN: Create Javascript charts with one line of Ruby
ankane.github.io
ankane.github.io
I particularly like the groupdate concept, and might send you a pull request adding 2.X support, if that fits in line with the project goals. I should have rolled my own years ago rather than repeating the same code at 100 places.
https://github.com/ankane/chartkick/blob/master/lib/chartkic...
(Disclosure: I am the developer of RazorFlow, and am only posting here because I feel it's relevant to this particular story)
https://github.com/agiliq/django-graphos
I am going to pick up some ideas from your code.
I was pretty surprised when I got to the ChartsController and saw it returning JSON. Seems like the hard way to go about it. I just assumed it was generating SVGs.
If you want zoomable charts to allow for increasing resolution, then the chart lib should ask the controller for a specific resolution and range on demand.
Even then, 500KB of numeric JSON data compresses really well (I tested with 1 month of real-world per-minute data: 92KB).
I highly recommend it over writing JS for your highcharts, esp if you push a lot of data into the chart.
https://github.com/ankane/groupdate (by the same author) makes it simple to output the right JSON grouped by date (awesome!)
Highcharts/Google charts make it simple to turn json into JS graphs.
This library provides glue so you don't have to read the highchart docs. Might save some people some time, I guess...
My favorite part about the library is you don't need to worry about getting the data in correct format. It just works with existing Rails methods, like ActiveRecord's count.
Also, Google Charts look a lot better with a little bit of custom styling.
"This looks nice, but most of the hard work is done elsewhere."
What were you expecting?
The original title is 'Create beautiful Javascript charts with one line of Ruby', which is more accurate.
The groupdate lib's really handy for quick visualization of data. Nice!
For more complex visualizations, might want to check out GoogleVisualr which I created http://googlevisualr.herokuapp.com/ but that only works with Google Visualizations.
undefined method `group' for #<Array:0x3a32f0c>
error with <%= pie_chart @pixel.hits.group("referrer").count %>
using mongoid 3, Pixel embeds_many Hits, Hit embedded_in Pixel. referrer is a string field of a Hit.http://stackoverflow.com/questions/4732393/ordering-and-grou...
What you're referring to?
Hopefully someone else can speak to this.
pie_chart @pixel.hits.group_by{|u| u.referrer }.each_with_object({}) {|(k,v), h| h[k] = v.size }Time to go back and refactor...
If I were you I would reverse the focus and make it a JavaScript library with helpers for various languages.
I am using Postgresql with Postgis.
Is there a workaround?
Error Loading Chart: Please install Google Charts or Highcharts--
For Google Charts, use:
<%= javascript_include_tag "//www.google.com/jsapi", "chartkick" %> If you prefer Highcharts, use:
<%= javascript_include_tag "path/to/highcharts.js", "chartkick" %>
--