javascript - Draw layered arc in D3 -


I want to create a chart with d3.js, which looks like this arch:

Chart should have several layers in it, such as:

How to create a chart, which has "difference", like arc, but with many layers, such as the last bela?

Code for the last chart:

  var dataset = {apple: [53245, 28479, 19697, 24037, 40245], oranges: [53245, 28479, 19697, 24037, 40245], Lemon: [53245, 28479, 19697, 24037, 40245], Pear: [53245, 28479, 19697, 24037, 40245],} ; Var width = 600, height = 400, cwdith = 45; Var color = d3.scale.category20 (); Var Pi = D3 Layout. () .sort (faucet); Var arc = d3.svg.arc (); ("Width", width) .attr ("height", height) .attr ("stroke-width", "2"). Etter ("stroke", "#fff"). Append ("g") .attr ("conversion", "translation (" + width / 2 + "," + height / 2 + ")"); Var gs = svg.selectAll ("g"). Data (d3.values ​​(dataset)) Enter () Attachments ("g"); GsselectAll ("path") data (function (d) {return pi (d);}) .inter () .andend ("path") .attr ("fill", function (d, i) {return color (i );}) .attr ("d", function (d, i, j) {return arc.inner radius (cwidth * j). Oterradius (cwidth * (j + 1)) (d);});  

Any help that I can get anywhere near my goal is appreciated! :)

Pie layout allows you to set start and end angles so that you can do the following To create a gap in the chart:

  var pie = d3.layout.pie () .sort (null) .startAngle (-40 * (Math.PI / 180)) .endAngle (270 * (Math.PI / 180));  

It looks like:

You can only set the internal radius property on the arc code generator, so that you can add the hollow center You can do this by adding an inner_radius to offset all individual arcs in this way:

  var inner_radius = 20; GsselectAll ("path") data (function (d) {return pi (d);}) .inter () .andend ("path") .attr ("fill", function (d, i) {return color (i );}) .attr ("d", function (d, i, j) {return arc. Witterredius (cwidth * j + inner_radius). Oterradius (cwidth * (j + 1) + inner_radius) (d);}) ;  

Once again it is in verb:

In addition, if you want internal radius cwidth you can multiply by bus There are no (j1) and (j + 2) and then you will not need additional inner_radius .


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -