Showing a hello world in a Rails applicatinon with D3

d3.js, ruby-on-rails-3.2

Solution

Are you getting javascript errors on the console? You're using a relative path in your view. Move the files to to the `/public/d3` folder and try:

<script src="/d3/d3.v3.js"></script>

In reality you should put the javascript in the `assets` folder if you're using the asset pipeline.

Use the `d3_rails` gem (get here) in your Gemfile:

`gem 'd3_rails'`

To use the asset pipeline add to `application.js`

`//= require d3.v3`

And the d3 javascript will automatically be included in your javascript `application.js` file.

Problem

All I have in my index.html is this: ``` <!DOCTYPE html> <meta charset="utf-8"> <body> <script src="d3/d3.v3.js"></script> <script> d3.selectAll("body").text("hi") </script> </body> ``` And the structure of looks like this for D3 stuff: But when I start rails and go to localhost3000, Nothing is getting shown on the page. I am sure I am doing something stupid in there but pretty new to D3 and trying to figure out what I did wrong.

Original source