Project

chartify

0.0
No commit activity in last 3 years
No release in over 3 years
This gem wraps the data to render chart and then it draws those charts in the web and use the same data to render charts as images, which is often useful when you want to render the chart in pdf or attach it to emails
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

~> 0.5
 Project Readme

Chartify

The purpose of this gem is to capture data to create a chart, in an object, so that we can do the following things

  • Render javascript graph, (which can be chart library agnostic)
  • Create the chart data using ruby only (no js to render chart)
  • Export chart as image (Needed when you want to email a chart)
  • Configuration for chart colors

Note

The project is in progress. So please wait for the release.

The project is similar to chartkick. The reason I am planning to create another project is because it does not support to export charts in image.

Charts supported

  • Line chart
  • Bar chart
  • Pie chart

For generating image from the chart data we are using Gruff

Here are some sample code to generate graph object and render to web.

@chart = Chartify::Factory.build(:line) do |chart|
  chart.data = [{hours_remain: 100, estimated_hours_remain: 100, day: 3.days.ago.to_date},
                {hours_remain: 50, estimated_hours_remain: 45, day: 2.days.ago.to_date},
                {hours_remain: 5, estimated_hours_remain: 10, day: 1.days.ago.to_date}]
  chart.columns = {hours_remain: 'Hours remaining', estimated_hours_remain: 'Estimated hours remaining'}
  chart.label_column = :day
end

In the web page,

<div id="chart" style="width: 900px; height: 180px;"></div>
<%= @chart.render_chart('chart') %>

To export the chart as image,

@chart.to_blob

Now you can attach the blob to email or in the PDF file.

License

This project rocks and uses MIT-LICENSE.