Update: Here is an example of a problem - http://jsfiddle.net/Hffks/2/
I am trying to use D3 to encode a line graph, and my line closes at the end, by which I mean that it acts as a closed path, where the first and last points are the same. My data comes in the following JSON format:
[ entityA : [ { time : 1230000, // time since epoch attribute1 : 123 // numeric value attribute2 : 123 // numeric value }, { time : 1230010, // time since epoch attribute1 : 123 // numeric value attribute2 : 123 // numeric value } ], entityB : [ { ... // same format as above ... ]
I use the standard line declaration (d3.svg.line with function for x and y):
var line = d3.svg.line() .x(function(d) { return x_scale(d.c_date)); }) .y(function(d) { return y_scale(d.total); });
Then inside the for loop, which iterates over the objects, I add "svg: path":
canvas.append("svg:path") .attr("d", line(data[entity]))
Everything else about the graph works: the points are correctly placed, I have several independent lines per entity, the axes are highlighted, etc. However, each independent row acts as a closed path.
Thanks for the help for any help!
user1872632
source share