sserrato / rails_d3_demo

Sample app that takes user entered numbers and generates a slick D3 chart for it.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

This is a Rails / D3 Demo.

![Image]()

Pull it down or git clone it, then bundle install, then hit localhost:3000 - Add a new “Favorite” with comma separated numbers, such as:

Numbers: 7,4,8,3,9,22

Color: Blue

Movie: Pulp Fiction

You will then be redirected to the show page and can see your fancy D3 chart.

The magic happens in this method in the controller:

def make_jsonish(array)

elements = array.each_with_index.map { |num, i|
  { key: i, value: num}
}

end

And by using this in the javascript:

var dataset = <%= raw JSON.pretty_generate @jsonish %> ;

About

Sample app that takes user entered numbers and generates a slick D3 chart for it.


Languages

Language:Ruby 62.9%Language:HTML 27.6%Language:CSS 7.5%Language:JavaScript 1.6%Language:CoffeeScript 0.5%