Live data from Hacker News

Show HN: Create Javascript charts with one line of Ruby

ankane.github.io

21–30 of 64 posts

Re: Show HN: Create Javascript charts with one line of Ruby

#22

This looks nice, but most of the hard work is done elsewhere. 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...

Highcharts, Google Chart, groupdate, jQuery (for AJAX), and iso8601.js (date parsing) definitely do the heavy lifting.

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.

Re: Show HN: Create Javascript charts with one line of Ruby

#23
post #20

Nice, going to try this. 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.

Awesome, looking forward to it.

Re: Show HN: Create Javascript charts with one line of Ruby

#26

This looks nice, but most of the hard work is done elsewhere. 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...

"Beautiful charts with 1 line of ruby"

"This looks nice, but most of the hard work is done elsewhere."

What were you expecting?

Re: Show HN: Create Javascript charts with one line of Ruby

#27
If you want to "AJAX" an image onto the page after the initial page load, why not just use an tag? You may be surprised to learn that it's even part of the HTML spec!

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.

Re: Show HN: Create Javascript charts with one line of Ruby

#28

This looks nice, but most of the hard work is done elsewhere. 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...

"Beautiful charts with 1 line of ruby" "This looks nice, but most of the hard work is done elsewhere." What were you expecting?

The title seems to lead on that it's possible to create beautiful charts with just one line of Ruby, when really it's 'Create beautiful charts with just one line of Ruby (if you use these libraries).'

The original title is 'Create beautiful Javascript charts with one line of Ruby', which is more accurate.

Re: Show HN: Create Javascript charts with one line of Ruby

#29

If you want to "AJAX" an image onto the page after the initial page load, why not just use an tag? You may be surprised to learn that it's even part of the HTML spec! 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.

Why should the controller be generating graphics? The UI can do that.

Re: Show HN: Create Javascript charts with one line of Ruby

#30
post #18
post #10

Earlier quoted context omitted.

Thanks! I started out heavy on the Ruby side but moved most logic to the JS to make AJAX charts dead simple to implement. (render :json => chart_data)

The ruby wrapping lib supports AJAX out of the box by passing a URL or route path to the helper and returning JSON from that endpoint.

Well, well, mccolin replying to akane, long live Context Optional. And nice work akane.
Post reply on HN