svg.charts - Package for generating SVG Charts in Python
svg.charts is a pure-python library for generating charts and graphs in SVG, originally based on the SVG::Graph Ruby package by Sean E. Russel.
svg.charts supercedes svg_charts 1.1 and 1.2.
svg.charts is written by Jason R. Coombs. It is licensed under an MIT-style permissive license.
You can install it with easy_install or pip:
easy_install svg.charts pip install svg.charts
Or, check out the mercurial repository source.
To run the tests, refer to the .travis.yml file for the steps run on the Travis-CI hosts.
svg.charts depends heavily on lxml and cssutils. Thanks to the contributors of those projects for stable, performant, standards-based packages.
Sean E. Russel for creating the SVG::Graph Ruby package from which this Python port was originally derived.
Leo Lapworth for creating the SVG::TT::Graph package which the Ruby port was based on.
Stephen Morgan for creating the TT template and SVG.
svg.charts has some examples (taken directly from the reference implementation) in tests/samples.py. These examples show sample usage of the various chart types. They should provide a good starting point for learning the usage of the library.
svg.charts also provides API documentation.
Upgrading from 1.x to 2.0
I suggest removing SVG 1.0 from the python installation. This involves removing the SVG directory (or svg_chart*) from site-packages.
Change import statements to import from the new namespace.
from SVG import Bar Bar.VerticalBar(...) becomes from svg.charts.bar import VerticalBar VerticalBar(...)
- Documentation! This package desperately needs some high-level, tutorial-style how-tos, and not just links to example code.
This project is hosted at sourceforge. Please use that site for reporting bugs and requesting help. Patches are also welcome.
#4: Added hook in Graph to allow overriding of the attributes on the root SVG element. One can now override or monkeypatch Graph._get_root_attributes to alter the rendering of the root attributes such as width and height. For example, to omit width and height:
class MyPlot(plot.Plot): def _get_root_attributes(self): attrs = super(MyPlot, self)._get_root_attributes() del attrs['width'] del attrs['height'] return attrs
- Project now builds and tests pass on Python 3 without 2to3.
- Corrected buggy logic in y-axis label rendering (thanks to Emmanuel Blot).
- Converted to Unix line endings.
- Updated to latest cssutils with Python 3 support. Thanks Christof!
- Fixed a few remaining issues with Python 3 compatibility.
- Fixed bug in rendering of Pie Chart styles.
- Improved testing framework. Now samples are at least generated as part of the test suite.
- Fixed build issue where package data wasn't included due to 2to3 technique. Now using distribute technique and installation on Python 3 requires distribute.
- Fixed bug where x axis labels would not be rendered properly if the largest value was the same as the largest visible x value on the chart.
- Altered the way CSS files are loaded, so they can be more easily customized by subclasses (and less dependent on the class names).
- A small attempt to improve the documentation - added links to examples that already exist.
- Fix IndexError in svg.charts.plot.Plot.field_size when there are only two values returned by float_range (in the case there are only two different 'y' values in the data) and scale_y_integers == True. Credit to Jean Schurger for the patch.
- Fixed problem in setup.py installing on Unix OS (case sensitivity of readme.txt). Credit to Luke Miller and Jean Schurger for supplying a patch for this issue.
- Updated cssutils dependency to 0.9.6 (currently in beta) to require the CSS profiles support.
- Completed an SVG CSS profile according to the SVG 1.1 spec.
- Added preliminary SVG CSS profile, suitable for stock CSS properties.
- First major divergence from the Ruby reference implementation
- Now implemented as a namespace package (svg.charts instead of svg_charts)
- Changed XML processor to lxml
- Enabled extensible css support using cssutils, greatly reducing static CSS
- Renamed modules and methods to be more consistent with PEP-8 naming convention
- Bug fixes
- First public release