d3.js - d3 line chart with Voronoi -
d3.js - d3 line chart with Voronoi -
i trying utilise next code in own work;
http://bl.ocks.org/mbostock/8033015
i have working, mouse overs code not behave in same way on sample code.
i ensure line inserted underlying info ;
svg.selectall('.line') .data(data) .enter() .append("path") .attr("class", "line") .attr('stroke', function(d,i){return colors[i%colors.length];}) .attr("d", function(d) { ** d.line = this; ** homecoming line(d.values)});
i generate voroni info per sample code;
var vr = (voronoi(d3.nest() .key(function(d) { homecoming x(d.timestamp) + "," + y(d.attainment) + y(d.dcuid); }) .rollup(function(v) { homecoming v[0]; }) .entries(d3.merge(data.map(function(d) { homecoming d.values; }))) .map(function(d) { homecoming d.values; })));
but problem comes when want @ augmented info in voronoi mouse on - line object no longer there.
voronoigroup.selectall(".line") .data(vr) .enter().append("path") .attr("d", function(d) {return "m" + d.join("l") + "z";}) .datum(function(d) {return d.point; }) .on("mouseover", function(d){alert(d.line)})
in demo code, alert work.
i have set fiddle of issue here;
http://jsfiddle.net/ccppq/2/
d3.js
Comments
Post a Comment