javascript - D3.js Flipping text at the bottom half of a donut (arcs) -
i following this tutorial. made last part, data, code doesn't work (i explain later).
here's jsfiddle of code far. have commented part flips text works.
if (d.endangle > 90 * math.pi/180) { var startloc = /m(.*?)a/, middleloc = /a(.*?)0 0 1/, endloc = /0 0 1 (.*?)$/; var newstart = endloc.exec( newarc )[1]; var newend = startloc.exec( newarc )[1]; var middlesec = middleloc.exec( newarc )[1]; newarc = "m" + newstart + "a" + middlesec + "0 0 0 " + newend; }
so far, have not understood regex (even before part, var firstarcsection = /(^.+?)l/;
). factor should angle, , should rotate text 180 degrees , place around arc again facing right way.
here's data:
var donutdata = [ {name: "firstarc", value: 16}, {name: "secondarc", value: 9}, {name: "thirdarc", value: 2}, {name: "fourtharc", value: 62}, {name: "fiftharc", value: 23}, {name: "sixtharc", value: 21} ];
here's issue: code above works in configurations, if change value of "thirdarc" 20 instance, or if change other values. cases work, don't (endloc.exec( newarc )[1];
becomes undefined).
i have seen related question, have no idea causes text flipped @ bottom in jsfiddle, there nothing angle or start , end points.
my questions how flip texts @ bottom half of first jsfiddle, , regex for?
Comments
Post a Comment