[cairo] A new charting library
Lawrence D'Oliveiro
ldo at geek-central.gen.nz
Fri Apr 17 13:48:54 PDT 2015
On Fri, 17 Apr 2015 09:10:19 -0300, Elvis Teixeira wrote:
> PROJECT INFO:
> name: slope
> type: Charting library
> author: Elvis Teixeira (Brazil)
> license: LGPL
> link: https://github.com/elvismt/slope
I was going to say this was a natural job for Python, and then I saw
you were ahead of me. :)
Some random comments:
In PySlope/data.py, why not shorten Data.set_visible to
def set_visible(self, on):
c.slope_data_set_visible(self.cobj, on)
Similarly for XyData.set_antialias in PySlope/xydata.py.
Where you have a lot of instance attributes (e.g. XyChart, in
PySlope/simple_charts.py), it can be a good idea to list these in a
__slots__ class attribute. This way, when you try to assign to the wrong
one, Python reports “no such attribute” rather than silently creating a
new one. This helps prevent typos.
In that same source file, how about shortening XyChart.axis to
def axis(self, name):
return \
self._metrics.get_axis \
(
{
'top' : xymetrics.LEFT_AXIS,
'left' : xymetrics.TOP_AXIS,
'bottom' : xymetrics.BOTTOM_AXIS,
'right' : xymetrics.RIGHT_AXIS,
}[name]
)
You could even use enums, but that restricts you to Python 3.4 and
later.
More information about the cairo
mailing list