Login

Charts in relatorio

2008-08-26 16:37

Since this is my first post on planet python: Hello !!

A few days ago, I commited a change that enables relatorio to output charts in png. I use PyCha as the plotting module since its graphics looked appealing and the syntax was simple enough to be used by lambda users. Since PyCha does not support negative values, I patched it and while I was working on it I also add a few features that I hope to see included upstream.

a chart made with PyCha

The nice stuff about this is that I can finally include a chart into an ODF file without to much hurdle, it works just like an image, the OpenDocument plugin will detect you are using a relatorio report and make the necessary call to create the chart.

a chart in an ODT file

This is all good and fine except that I don't like the way I templatize (is that a word) the chart: I use a genshi template of a yaml file like this one:

options:
    background: {hide: true}
    legend: {hide: true}
    padding: {bottom: 10, left: 70, right: 10, top: 10}
chart:
    type: pie
    width: 600
    height: 400
    dataset:
    {% for line in o.lines %}
      - - ${line.item.name}
        - - [0, $line.amount]
    {% end %}

When this file is generated with the relevant data, the options dictionary is transmitted to PyCha and the chart dictionary is then used to create the chart. Going through the yaml step feels like it is unnecessary but I fail to see how I can make this work without requesting the user to learn python.

Comments

1. 2008-08-30 10:34 : by udo spallek

Hey Nicolas and Gaëtan,
just a day inattentively and you got a new feature. Looks and sounds great! ASAP I try to test it and hope the relatorio release 0.4.0 is comming soon.
Cheers Udo

2. 2008-08-30 10:38 : by udo spallek

Another thing,
upon a request for a sophisticated report engine on de.comp.lang.python, I made some advertising for relatorio. Maybe some guys will take a look.
Cheers Udo

3. 2008-09-09 10:33 : by Nicolas Évrard

Thank you Udo for all your testing and for spreading the word !

Post a comment