SimpleD3

Helps create simple D3 graphs quickly without much code.

Installation

Add simple d3 to your gemfile

gem 'simple_d3'

Then add d3 to your application.js

..
//= require d3
//= require_tree .

Then add this to your view:

<script type="text/javascript">
  var data = [ 5, 10, 13, 19, 21, 25, 22, 18, 15, 13,
          11, 12, 15, 20, 18, 17, 16, 18, 23, 25 ];
</script>

<%= simple_d3("my_chart") %>

Bar Chart

<script type="text/javascript">
  var data = [ 5, 10, 13, 19, 21, 25, 22, 18, 15, 13,
          11, 12, 15, 20, 18, 17, 16, 18, 23, 25 ];
</script>

<%= simple_d3_bar("my_bars",:graph) %>

Pie Chart

<script type="text/javascript">
  var data = [ 5, 10, 20, 45, 6, 25 ];
</script>

<%= simple_d3_pie("my_pie",:pie) %>

Setting Options

You can also set options, like:

<%= simple_d3("my_pie3",{:type=>"pie", :width=> 1000, :height => 500}) %>

Current options are:

type - "bar" or "pie"
width
height
colors - array of colors

See https://github.com/TigerWolf/simple_d3_demo for more examples.

Screenshot

Screenshot