[reportlab-users] time series lineplot

Robin Becker reportlab-users@reportlab.com
Thu, 18 Sep 2003 19:35:21 +0100


In article <38966.199.169.240.132.1063904957.squirrel@svr1.turboweb.net>
, reportlab@sarcastic-horse.com writes
>Hi-
>
>
>About two weeks ago, I asked if reportlab would be capable of making a
>chart that looked similar to this powerpoint chart:
>
>http://www.sarcastic-horse.com/example.pdf
>
>The chart is a lineplot that also shows shaded vertical bars that indicate
>recessions.
>
>After tinkering for a while, this is what I've created with reportlab:
>
>http://www.sarcastic-horse.com/reportlab/reportlab_version_cu.pdf

looks real nice, perhaps if you don't mind we might do a contrib spread
on our upcoming revamped web site? It's a nice example of what can be
done with a bit of effort.

>
>I just wanted to thank all the people on this list with all the tips.
>
>The chart uses mx.DateTime.Date objects to set the boundaries of the
>x-axis.  It is easy to to change the start dates and end dates of the
>graph, and the recession bars (those yellow vertical bars) and the data
>will shift around.  The text labels in the chart are still fixed, but
>that's a next detail.
>
>Right now, I'm just reading data in from text files, but in the real
>application I have in mind, data will be stored in SQL databases, and this
>whole system will be web-driven.
>
>This is what I'm going to work on next:
>_Allow adding text to the fields using x and y axis coordinates rather
>than absolute (x,y) drawing coordinates.  For example, I want to make it
>possible to draw a text field at ('January, 1980', 75%).
>_Add support for quarterly and annual frequency data.
>_Make a proper timeseriesLinePlot class that has startdate, enddate, and
>frequency attributes.

We have such a beast already though it's not so fancy as yours. It uses
normalDate.py for the dating. Doing the frequency is pretty hard.

>_Figure out how to deal with multi-line titles.  The chart area should
>squeeze down.

Squeezing is pretty easy with Andy's new getBounds stuff. You need to
defer all decisions till draw time though. That's when you get to know
the sizes accurately.

>_Learn the legend class and add that in automatically.
>
>If anyone is interested, the source code that made these charts is here:
>
>http://www.sarcastic-horse.com/reportlab/cu.py
>http://www.sarcastic-horse.com/reportlab/fdlib.py
>
>I'd love to hear suggestions about how to improve the code.
>
>To run the charts yourself, you'll need the data, which is here:
>
>http://www.sarcastic-horse.com/reportlab/caputl.txt
>http://www.sarcastic-horse.com/reportlab/prelim_caputl.txt
>
>This data is all from the Federal Reserve Board of Governors and is freely
>available (although in a different format) from their website:
>
>http://federalreserve.gov
>
>Anyway, like I said above, thanks to everyone on this list.  I hope to
>automate my office's production of these slides and this is a very
>encouraging start.
>
>
>Matt
>

-- 
Robin Becker