A new Riff-radio.org site with a static approach.

charts.rst 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. .. link:
  2. .. description:
  3. .. tags:
  4. .. date: 2013-08-27 18:20:55 UTC-03:00
  5. .. title: Charts
  6. .. slug: charts
  7. If you are using reStructuredText and install pygal, Nikola has support for rather nice charts
  8. with little effort, and i's even semi-interactive (hover your pointer over the legend!):
  9. .. code:: rest
  10. .. chart:: StackedLine
  11. :title: 'Browser usage evolution (in %)'
  12. :fill: True
  13. :x_labels: ['2002','2003','2004','2005','2006','2007','2008','2009','2010','2011','2012']
  14. :width: 600
  15. :height: 400
  16. :explicit_size: True
  17. :style: BlueStyle
  18. ('Others', [14.2, 15.4, 15.3, 8.9, 9, 10.4, 8.9, 5.8, 6.7, 6.8, 7.5])
  19. ('IE', [85.8, 84.6, 84.7, 74.5, 66, 58.6, 54.7, 44.8, 36.2, 26.6, 20.1])
  20. ('Firefox', [None, None, None, 16.6, 25, 31, 36.4, 45.5, 46.3, 42.8, 37.1])
  21. ('Chrome', [None, None, None, None, None, None, 0, 3.9, 10.8, 23.8, 35.3])
  22. .. raw:: html
  23. <div style="text-align: center;">
  24. .. chart:: StackedLine
  25. :title: 'Browser usage evolution (in %)'
  26. :fill: True
  27. :x_labels: ['2002','2003','2004','2005','2006','2007','2008','2009','2010','2011','2012']
  28. :width: 600
  29. :height: 400
  30. :explicit_size: True
  31. :style: BlueStyle
  32. ('Others', [14.2, 15.4, 15.3, 8.9, 9, 10.4, 8.9, 5.8, 6.7, 6.8, 7.5])
  33. ('IE', [85.8, 84.6, 84.7, 74.5, 66, 58.6, 54.7, 44.8, 36.2, 26.6, 20.1])
  34. ('Firefox', [None, None, None, 16.6, 25, 31, 36.4, 45.5, 46.3, 42.8, 37.1])
  35. ('Chrome', [None, None, None, None, None, None, 0, 3.9, 10.8, 23.8, 35.3])
  36. .. raw:: html
  37. </div>
  38. Here's how it works:
  39. * Next to the directive, use the `chart type you want <http://pygal.org/chart_types/>`_
  40. * Any option you can set in a chart? Use it like ``:title:`` in this example. Syntax on
  41. the value is just like in the pygal examples.
  42. * For each data series do it like the line that says ``Firefox`` in this example. The first element
  43. is the label, then comes the data.
  44. Easy, right? Please explore `the pygal site <http://pygal.org>`_ for more information, and just
  45. take this example and tweak stuff.