[reportlab-users] Howto force a value axes to end in a tick?

Robin Becker robin at reportlab.com
Wed Jun 10 09:50:43 EDT 2009


Dinu Gherman wrote:

> Hi,

>

> while having fun with AreaLinePlots I wonder if there is a way

> to specify for a value axis to chose ticks such that the maximum

> value displayed by the chart always falls on the chart's border-

> line (or somewhere "close" to that, but inside the chart area)?

>

> In fact, this question is independant of AreaLinePlot, but I'll

> have to raise some more issues with AreaLinePlot in further post-

> ings...

>

> Thanks/Regards,

>

> Dinu

>

> ......................................................................

> Follow me on Twitter: http://twitter.com/dinugherman

>

>

........

I think you need to look at ValueAxis' rangeRound attribute.

rangeRound can be 'none', 'ceiling', 'floor' or 'both'. The default means use
whatever range we are given and then (usually the axis ends without ticks). To
make the upper end have a tick use ceiling similarly for the lower end with
floor; botth makes the range end on a tick for upper and lower limits. There
might be better ways to do this, but all we're doing really is working out a
tick scheme and then faking the range to include the potentially missing ticks.
Of course given the ticking scheme that might make the new ticks fail again.

A related attribute is avoidBoundFrac which can be None or a number or a pair of
numbers. That tells the axis what fraction of the tick interval we need to leave
between the limit values and the top/bottom of the chart. So if we end up with a
maximum point of 1.0 and the top of the axis is 1.0 then ticked or not the chart
area coincides with the limit point; some designers don't like that. Setting
avoidBoundFrac to say 0.1 would insure that at least some fraction .1 of the
tick interval would be added at the top. That would probably force the axis to
extend to 1.025 or whatever so that some space is left free.

--
Robin Becker


More information about the reportlab-users mailing list