I want to include my working d3.js code to my Rails app. In my view for builds I’m using paginating because there are about 30000 lines. I want to visualize them with d3.js.
It is working for the first 100 lines when I just call a json-object via the model name:
<%= javascript_tag do %>
d3.json('builds',
function(data){
//working function code..
});
<% end %>
But the json-object builds takes everytime the first 100 items independent from the paginating. That means builds has all data but it just takes the first 100 because I say in builds model self.per_page = 100 that I can use that for my paginating.
I also tried to create a json-object in the view that just has the current build-objects:
var myJson = <%=raw @builds.to_json %>;
But the problem here is that I can’t give the d3.json function a variable name.
Does anyone know how I can create a json object that I can use for my d3 code that is depending on the current page?
I hope it is clear what I mean otherwise please ask!
Thanks in advance!
Ok, after trying everything I found out how this works:
You cannot create a variable and pass it into the d3.json function but you have to let it evaluate the ruby code by itself.