protovis javascript charts: part 1

Calculating the Arc

Now we need to calculate the arc of each wedge in our array. We still use function d but with an important change. At the end of our function we see Math.PI.

If you recall, pi is the ratio of a circle's circumference to it's diameter. This can be used to calculate an arc for each point of data. This is one of several math shortcuts built into javascript.

We now have a pie with appropriately sized slices. But we want to highlight the first slice. We do that by changing the fillStyle and using a method called pv.colors. This lets us create a series of colors that correspond to our data. We'll make the first one black and the rest blue. You can also use hexadecimal or rgb colors if you wish.