[reportlab-users] Charts and Axes dimensions

Andy Robinson andy at reportlab.com
Mon Sep 28 08:28:55 EDT 2009


2009/9/27 Troy Caldwell <troy.caldwell at covchurch.org>:

> I realize that if I place the chart at 0,0, my labels for both axes will be

> outside the bounds of the drawing.  They appear, but they appear where I

> don't want them.  I'm trying to figure out a way to calculate the width of

> the y axis, and the height of the x axis so I can then make the decision on

> where to place the chart itself to keep the entire image where I want it.


The framework was designed for people using these charts within
financial publications, alongside other tables and content. Often
you want to stack up several charts above each other and be sure all
the categories line up from one chart to the next. Therefore, we
decided to make the inner 'plot rectangle' explicit (and this is what
x,y,width and height refer to in each chart class). A consequence
of this is that it's your job to allow enough space for the axis
labels, which of course depends on the typical length of the text in
those labels, and the font size and position you specify.

This might need one or two tries at 'design time' but I can't see why
you'd need to redo it for a lot of chart instances.

If you need to know the precise size, every shape (including the
charts) has a method called 'getBounds' which will return its actual
size, including any text labels off the edge of the axis. This would
let you set things up exactly right, at the expense of basically
drawing things twice.

Best Regards,

--
Andy Robinson
CEO/Chief Architect
ReportLab Europe Ltd.
Media House, 3 Palmerston Road, Wimbledon, London SW19 1PG, UK
Tel +44-20-8545-1570


More information about the reportlab-users mailing list