Re: A new charting library

Lawrence D'Oliveiro <[email protected]>
Newsgroups gmane.comp.lib.cairo
Organization Geek Central
Message-ID <[email protected]>
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.
-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.