Can't seem to have more than 1 continuous looping chart on a page.
-
Love the plugin. Just a quick question:
When there is more than one d3 animation looping on a single post, only the final one loops continuously. Is this something in my code, or a bug in the plugin?
e.g. add this code a few identical charts to a single post:
//1 var pointsBig = [ // the original, "wide" set of points [480, 200], [580, 400], [680, 100], [780, 300], [180, 300], [280, 100], [380, 400] ]; var points = []; // my new, narrow array of points // shrink the x-values by 50% var halfX = function (oldArray, newArray) { for (var i = 0; i < oldArray.length ; i++) { newArray.push( [oldArray[i][0] / 2, oldArray[i][1]] ); } } halfX(pointsBig, points); var svg = d3.select(".wpd3-138-1").append("svg") .attr("width", 960) .attr("height", 500); var path = svg.append("path") .data([points]) .attr("d", d3.svg.line() .tension(0) // Catmull–Rom .interpolate("cardinal-closed")); svg.selectAll(".point") .data(points) .enter().append("circle") .attr("r", 4) .attr("transform", function(d) { return "translate(" + d + ")"; }); var circle = svg.append("circle") .attr("r", 13) .attr("transform", "translate(" + points[0] + ")"); transition(); function transition() { circle.transition() .duration(10000) .attrTween("transform", translateAlong(path.node())) .each("end", transition); } // Returns an attrTween for translating along the specified path element. function translateAlong(path) { var l = path.getTotalLength(); return function(d, i, a) { return function(t) { var p = path.getPointAtLength(t * l); return "translate(" + p.x + "," + p.y + ")"; }; }; }
Thanks!
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Can't seem to have more than 1 continuous looping chart on a page.’ is closed to new replies.