Charts

If you are us­ing re­Struc­tured­Text and in­stall py­gal, Niko­la has sup­port for rather nice charts with lit­tle ef­fort, and i’s even semi-in­ter­ac­tive (hover your point­er over the leg­end!):

.. chart:: StackedLine
   :title: 'Browser usage evolution (in %)'
   :fill: True
   :x_labels: ['2002','2003','2004','2005','2006','2007','2008','2009','2010','2011','2012']
   :width: 600
   :height: 400
   :explicit_size: True
   :style: BlueStyle

   ('Others',  [14.2, 15.4, 15.3,  8.9,    9, 10.4,  8.9,  5.8,  6.7,  6.8,  7.5])
   ('IE',      [85.8, 84.6, 84.7, 74.5,   66, 58.6, 54.7, 44.8, 36.2, 26.6, 20.1])
   ('Firefox', [None, None, None, 16.6,   25,   31, 36.4, 45.5, 46.3, 42.8, 37.1])
   ('Chrome',  [None, None, None, None, None, None,    0,  3.9, 10.8, 23.8, 35.3])
In order to use the Chart directive, you must install the “pygal” Python package.

Here’s how it work­s:

  • Next to the di­rec­­tive, use the chart type you want

  • Any op­tion you can set in a chart? Use it like :ti­tle: in this ex­am­ple. Syn­tax on the val­ue is just like in the py­gal ex­am­ples.

  • For each da­ta se­ries do it like the line that says Fire­fox in this ex­am­ple. The first el­e­ment is the la­bel, then comes the da­ta.

Easy, right? Please ex­plore the py­gal site for more in­for­ma­tion, and just take this ex­am­ple and tweak stuff.