javascript - D3 js selectAll each doesn't iterate -
i trying implement fisheye lens (cartesian) in scatterplot. trying follow this approach, apparently selector fails.
i have fisheye defined as
var fisheye = d3.fisheye.circular().radius(120); svg.on("mousemove", function() { fisheye.focus(d3.mouse(this)); console.log("here " + points.selectall("circle").length); points.selectall("circle").each(function(d) { console.log("aaa"); d.fisheye = fisheye(d); /*points.selectall("circle") .each(function(d) { console.log("???"); this.attr("cx", function(d) { return d.fisheye.x; }) this.attr("cy", function(d) { return d.fisheye.y; }) this.attr("r", function(d) { console.log("hype"); return 10; }); }); */ }); });
and points defined as
points = svg.append("g") .attr("class", "point") .selectall("circle") .data(dataset) .enter() .append("circle") .attr("cx", function(d) { // set x position using x-scale return x(d.x); }) .attr("cy", function(d) { // set y position using y-scale return y(d.y); }) .attr("r", 5) // set radius of every point 5 .on("mouseover", function(d) { // on mouse on show , set tooltip if(!isbrushing){ tooltip.transition() .duration(200) .style("opacity", 0.9); tooltip.html(d.symbol + "<br/> (" + parsefloat(x(d.x)).tofixed(4) + ", " + parsefloat(y(d.y)).tofixed(4) + ")") .style("left", (d3.event.pagex + 5) + "px") .style("top", (d3.event.pagey - 28) + "px"); } }) .on("mouseout", function(d) { // on mouseout, hide tooltip. tooltip.transition() .duration(500) .style("opacity", 0); });
the console.log "here" spamming when moving mouse, , shows correct amount. hwoever, each loop never executed not see "aaa". have tried use selectall("circle")
doesn't work either.
what doing wrong , how can fisheye work?
Comments
Post a Comment