On Tue, 2002-07-30 at 10:27, Geoffrey Talvola wrote:
> Karl Putland wrote:
> > On Mon, 2002-07-29 at 23:39, Edmund Lian wrote:
> > > Has anybody had any experience generating business-style
> > charts on-the-fly
> > > from within Webware? If so, what did you use? I see a few
> > packages like
> > > Dislin, GNUPlot, etc., but before messing around, I thought
> > I should ask
> > > for experiences. This topic area probably needs to be added
> > to the Wiki; I
> > > can do so once I get enough responses...
> > >
> > > ...Edmund.
> > >
> > Check out the ReportLab graphics package.
> > --Karl
> Can ReportLab generate GIF or PNG charts? I thought it was designed for
> PDF. More recently, I believe SVG was added.
ReportLab has a graphics sub package that is used for for drawing
graphs. Output is bitmap and convertable with PIL, and I belive just
recently SVG support was added.
2.1 Drawings and Renderers
A Drawing is a platform-independent description of a collection of
shapes. It is not directly associated with PDF, Postscript or any other
output format. Fortunately, most vector graphics systems have followed
the Postscript model and it is possible to describe shapes
A drawing contains a number of primitive Shapes. Normal shapes are
those widely known as rectangles, circles, lines, etc. One special
(logic) shape is a Group, which can hold other shapes and apply a
transformation to them. Groups represent composites of shapes and allow
to treat the composite as if it were a single shape. Just about anything
can be built up from a small number of basic shapes.
The package provides several Renderers which know how to draw a drawing
into different formats. These include PDF (of course), Postscript, and
bitmap output. The bitmap renderer uses Raph Levien's libart rasterizer
and Fredrik Lundh's Python Imaging Library (PIL). Very recently, an
experimental SVG renderer was also added. It makes use of Python's
standard library XML modules, so you don't need to install the XML-SIG's
additional package named PyXML. If you have the right extensions
installed, you can generate drawings in bitmap form for the web as well
as vector form for PDF documents, and get "identical output".
The PDF renderer has special "privileges" - a Drawing object is also a
Flowable and, hence, can be placed directly in the story of any Platypus
document, or drawn directly on a Canvas with one line of code. In
addition, the PDF renderer has a utility function to make a one-page PDF
document quickly. The SVG renderer is special as it is still pretty
The SVG code it generates is not really optimised in any way and maps
only the features available in ReportLab Graphics (RLG) to SVG. This
means there is no support for SVG animation, interactivity, scripting or
more sophisticated clipping, masking or graduation shapes. So, be
careful, and please report any bugs you find!
We expect to add both input and output filters for many vector graphics
formats in future. SVG was the most prominent first one to start with
for which there is now an output filter in the graphics package. An SVG
input filter will probably become available in Summer 2002 as an
additional module. GUIs will be able to obtain screen images from the
bitmap output filter working with PIL, so a chart could appear in a
Tkinter GUI window.
> - Geoff
Director of Technical Operations