I am trying to set a pie on d3.js which will constantly update your data (slices) and labels Will change
I have reviewed several instances such as:
But this is the fact that my implementation is quite different because I use both paths and paths of the text.
Problem: The data is not updated and the text has not been deleted.
This is my code:
function testing (data) {data = data? Data: { "Slis 1" Mthkflur ((Mthkrendm) * 10) + 1), "Slice 2": Mthkflur ((Mtkrendm () * 10) + 1), "Slice 3" : Math .floor ((Math.Randem (* * 10) +1), "Slesses 4": Math.floor ((Math.Rendum (* * 10) +1)}; Var dataA = D3 Entries (data); Var cv_path = cv_svg.selectAll ("g.slice") .data (cv_pie (data)); Cv_path.enter () .append ( "g") .attr ( "class", "slice") .append ( "path") .attr ( "fill", function (d, i) {return cv_color (i); }) .attr ("d", cv_arc) .each (function (d) {this._current = d;}); Cv_path.transition () Duration (750) .attrTween ("d", cv_arcTween); . Cv_path.exit () removal (); Var cv_text = d3.selectAll ( "slice") .append ( "text") .attr ( "transform", function (d) {d.innerRadius = 0; d.outerRadius = cv_r; return "translation (" + cv_arc. ( "font", "bold") .attr ( "fill", "#FFFFFF"). .attr ( "font-size", "30px") .text (function (d) {return d.data.key + "(" + D.data.value + ")";});) delete cv_text.exit ();} I tried to get this right Spent more time but still get stuck (every time something else breaks ..: P) Your help will be highly appreciated!
You were almost there in the same way as the key text Is to behave like that and remove it by handling the .exit () selection. I have modified your jsfiddle I have made a bit easier to understand the g elements.
No comments:
Post a Comment