Chartr – Plotr generation for Rails

I’ve been working on a project that uses graphics created with Plotr, and I wanted to automate that from Rails, so I created Chartr. It’s not very complete, but works well enough to create stuff like this:


<script src="http://chartr.rubyforge.org/excanvas.js" type="text/javascript"></script>
<script src="http://chartr.rubyforge.org/plotr_uncompressed.js" type="text/javascript"></script>
  <canvas id="results_chart" height="300" width="500"></canvas>
</div>

var dataset = {“Number/Decade”: [[0, 1000], [1, 5000], [2, 20000], [3, 22000]]};
var options = {colorScheme: “#22aa22”, legend: {position: {}}, axis: {x: {ticks: [{label: “1960”, v: 0}, {label: “1970”, v: 1}, {label: “1980”, v: 2}, {label: “1990”, v: 3}]}}, padding: {left: 100}, background: {}, stroke: {}, legend: {position: {left: ‘120px’}}};
var discvar = new Plotr.BarChart(“results_chart”, options);
discvar.addDataset(dataset);
discvar.render();


Help is more than welcome! I think the API is still a bit clumsy, more chart types need adding, and there are other things that could probably be improved, but it does work.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s