Search code examples
javascriptmathjspdf

Draw a pie graph using jspdf library


I am trying to use the jspdf library to draw a fairly dynamic pie graph. I have considered drawing the graph in html5 canvas and then saving it as a jpeg and saving the image into the pdf. This, however doesn't work for android browsers and I need to make something which works on all the tablets. jspdf doesn't seem to have an arc function and drawing a circle with lines in it doesn't let me fill the arcs with different colours. Any help is appreciated! Thanks!


Solution

  • I solved this problem by using the inbuilt cubic bezier function. This link was very useful : http://itc.ktu.lt/itc354/Riskus354.pdf Once I could draw an arc, drawing a pie graph was very easy!