javascript - d3 donut chart multy ring with text -


i create multi ring donut chart following examples on web , ok till try display text ring , got stuck different errors. think @ point can access data when comes create rings, got nan values path , text.

here code:

var dataset = {   ringone: [{"label":"70%", "value":70},              {"label":"10%", "value":10},              {"label":"20%", "value":20}],    ringtwo: [{"label":"70%", "value":70},              {"label":"10%", "value":10},              {"label":"20%", "value":20}], };   var width = 460,     height = 300,     cwidth = 45,     outerr = 100,     color = d3.scale.ordinal().range(["#07e", "#00aced", "#e32"]);  var svgdonut = d3.select("#donut")     .append("svg")     .attr("width", width)     .attr("height", height)     .append("g")     .attr("transform", "translate(" + width / 2 + "," + height / 2 + ")" );  var arc = d3.svg.arc();  var pie = d3.layout.pie()     .sort(null)     .value(function(d) { return d.value; });  var rings = svgdonut.selectall("g.slice")     .data(pie([dataset]))     .enter()     .append("g")     .attr("class", "slice");      rings.append("path")         .attr("fill", function(d, i){ return color(i); })         .attr("d", function(d, i, j){ return arc.innerradius( 80 + cwidth * j )                                             .outerradius( outerr * (j) )(d); });      rings.append("text")         .attr("transform", function(d) {                                 d.innerradius = 0;             d.outerradius = outerr;             return "translate(" + arc.centroid(d) + ")";                 })         .attr("text-anchor", "middle")         .text(function(d, i) { return dataset.ringone[i].label; }); 

the error is:

error: invalid value <path> attribute d="m4.898587196589413e-15,-80a80,80 0 1,1 nan,nanl0,0z" error: invalid value <text> attribute transform="translate(nan,nan)" 

fiddle here: https://jsfiddle.net/anaketa/8u7gejjc/

any ideas?


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -