This shows a simple pie chart diagram, view source to see how this works.
For figuring out how much stroke-dashoffset to use, first check the total length of the path:
alert(document.getElementById("p").getTotalLength());Then the computed dashoffset will be:
dashoffset = (totallength / 100) * percentage