[reportlab-users] How to break a line graph?

Andy Robinson andy at reportlab.com
Tue Jun 26 16:27:59 EDT 2007


On 26/06/07, Tim Roberts <timr at probo.com> wrote:

> David Frank wrote:

> > Hi,

> >

> > I am making a line chart [using HorizontalLineChart()] and I have an

> > array of values as the chartdata. Now, one of the arrays has some null At

> > values in it. Eg.,

> >

> > chartdata[2] = [100.2, 100.111, 50.2345, 50.0, None, None, None, None,

> > None, None, 106.651199, 50.34, 206.651, 1978.788, 39.787, 978.787,

> > 18.88, 1.65, 2.99, 2.0]

> I'm not 100% sure after scanning the code, but it looks like this might

> work if you break this yourself:

>


Tim's right. At present the chart classes don't support interrupted lines.

I suggest you subclass the makeLines() method of HorizontalLineChart
(or Vertical if you prefer). This method looks at the data and
returns a list of PolyLine objects - primitive shapes our engine can
render. You could make it test for None values in each series, and,
if any are found, break it into several distinct continuous line
segments.

If you wanted to modify the class instead, we would be very happy to
accept this as a patch. However it would have to properly handle both
the 'line' and 'mountain' cases - the latter being where we fill down
to the axis, and have some new property to enable this so that nothing
changes unless asked for e.g.self.interpolateMissingData (default =
True, or False).

I hope this helps - sorry I don't have time to add it myself this week.

- Andy


More information about the reportlab-users mailing list