Jerod Santo changelog.com/posts

Create beautiful JavaScript charts with one line of Ruby using Chartkick

So many web apps need to visualize data for their users that a high quality charting library is a huge boon for developers. Andrew Kane’s Chartkick might be just the library for Ruby developers.

Chartkick sample

Chartkick works with Rails 3.1+ and makes adding beautiful charts to your web app as easy as a one liner. Create a simple line chart like this:

<%= line_chart User.group_by_day(:created_at).count %>

Or one with multiple series of data like this:

<%= line_chart @goals.map { |goal| 
  {
    :name => goal.name, 
    :data => goal.feats.group_by_week(:created_at).count 
  } 
} %>

A pie chart is as easy as:

<%= pie_chart Goal.group("name").count %>

Chartkick is mostly a JavaScript library with Ruby helpers to generate the required markup that the JavaScript turns into charts. It requires either Google Charts or Highcharts to work, but it doesn’t require Ruby! If you want to use the JavaScript bits from another language, check out Chartkick.js instead.

Chartkick is MIT licensed and hosted on GitHub.


Discussion

Sign in or Join to comment or subscribe

Player art
  0:00 / 0:00