I think our 2nd angle function of:
.angle(function(d) d*(2/3)*Math.PI)
is in error. The 1/3 as in 1/3 d*2*Math.PI should be the normalized
wedge size
12.02/(12.02 + 12.01 +9 + 3) for the first.
12.01/(12.02 + 12.01 +9 + 3) for the 2nd
9/(12.02 + 12.01 +9 + 3) ... etc.
How to do this is the issue now.
On May 22, 11:16 am, FRANCOIS MERCIER <
francois.merc...@me.com> wrote:
> Hello,
>
> I'm trying to display frequencies in the form of a "donut plot", using pv.wedge.
> Let's assume I have a sample of 36 pairs of shoes, for which I want to study the "type" (boots, sneakers, ...), and within each "type" I want to know the "material" used to make the shoes (leather, rubber, ...).
> I want to display the frequency of "types" in a first donut or ring, and I want to display the frequency of "material" within each "type" in a second ring, surrounding the first one.
>
> As you will notice, when using the code below, I managed to obtain the "type" and "material" aligned for the 1st wedge of the inner ring, but it's getting messy for the 2nd wedge of the inner ring.
>
> Any help on how to fix this would be much apreciated.
>
> Thanks a lot,
> Best regards
> Francois
>
> /*****************************************************************************/
>
> var fill1=pv.colors("gold", "olivedrab", "darkseagreen", "lightseagreen")
> var offset=(1/6)*Math.PI
>
> new pv.Panel()
> .width(600)
> .height(600)
>
> .add(pv.Wedge)
> .data(pv.normalize([12.02, 12.01, 9, 3]))
> .left(300)
> .top(300)
> .innerRadius(135)
> .outerRadius(195)
> .angle(function(d) d*2*Math.PI)
> .fillStyle(fill1)
> .strokeStyle("white")
> .lineWidth(4)
>
> .add(pv.Wedge)
> .data(pvnormalize([7, 4, 1]))
> .left(300)
> .top(300)
> innerRadius(215)
> .outerRadius(275)
> .angle(function(d) d*(2/3)*Math.PI)
> .fillStyle(function (d) pv.rgb(255, 215, 0, .1+d))
> .strokeStyle("white")
> .lineWidth(4)
>
> .add(pv.Wedge)
> .data(pv.normalize([6, 5, 1]))
> .left(300)
> .top(300)
> .innerRadius(215)
> .outerRadius(275)
> .startAngle(function() offset+this.index)
> .angle(function(d) d*(1/2)*Math.PI)
> .fillStyle(function (d) pv.rgb(107, 142, 35, .1+d))
> .strokeStyle("white")
> .lineWidth(4)
>
> .root.render();
>
> /*****************************************************************************/