Search code examples
pythongraphchartsreportlablinegraph

Python Reportlab Area under multiple lines graph


So I have started a project for the web utilizing Reportlab. The website needs to generate PDFs that have embedded charts. So far I've been extremely happy with Reportlab's capabilities (i've done a bunch of pie and bar charts), however its documentation is kinda lacking.

I have looked all over the internet, and have been unable to find an example using reportlab of an Area under the graph chart. See an example of what my client wants here

Has anyone achieved the above result using reportlab? What are your suggestions for achieving the above chart?

Edit: Check out this chart from google chart API, it is basically what I would like to do:

https://chart.googleapis.com/chart
    ?cht=lc
    &chd=e:....,cefhjkqwrlgYcfgc,QSSVXXdkfZUMRTUQ,HJJMOOUbVPKDHKLH,AAAA
    &chco=000000
    &chls=1,1,0|1,1,0|1,1,0|1,4,0
    &chs=200x125
    &chxt=x,y
    &chxl=0:|Sep|Oct|Nov|Dec|1:||50|100
    &chg=25,25
    &chm=b,76A4FB,0,1,0|b,224499,1,2,0|b,FF0000,2,3,0|b,80C65A,3,4,0

google chart api link


Solution

  • I have built a collection of galleries under http://www.reportlab.com/chartgallery/ to serve as examples. I think what you need is the inFills property under the line, look at http://www.reportlab.com/chartsgallery/financial/AreaChart01/ for an example (also read the description there). You could browse the properties on the right to see their values.

    You could also download a trial version of Diagra to build your charts and then convert them to use the open source version when ready to deploy to production.