[reportlab-users] how to handle the missing value in a linechart by not drawing the point?
Xinhui Tang
xinhui.tang at gmail.com
Thu Jan 7 18:53:44 EST 2010
Friends:
I am testing the HorizontalLineChart. It works perfectly except for the
missing point it draws a line from the previous point to the next point.
My desired behavior is to draw line from point 1 to point 2 and ignore point
3 if it is "None", and draw another line from point 4 to point 5.
The current behavior is : it draws point 1 to point 2, ignores point 3 since
it is "None". However it continues to draw lines from point 2 to point 4
and from point 4 to 5.
How could I break the line into two discontinued lines?
Here is the original code:
from reportlab.graphics.shapes import Drawing
from reportlab.graphics.charts.lineplots import LinePlot
from reportlab.graphics.widgets.markers import makeMarker
from reportlab.graphics.charts.linecharts import HorizontalLineChart
from reportlab.graphics import renderPDF
drawing = Drawing(400, 200)
data = [
(5, 20, None, 45, 6, 4),
(5, 20, 46, 38, 23, 21, 6, 14)
]
lc = HorizontalLineChart()
lc.x = 50
lc.y = 50
lc.height = 125
lc.width = 300
lc.data = data
lc.joinedLines = 1
catNames = 'Jan Feb Mar Apr May Jun Jul Aug'.split(' ')
lc.categoryAxis.categoryNames = catNames
lc.categoryAxis.labels.boxAnchor = 'n'
lc.valueAxis.valueMin = 0
lc.valueAxis.valueMax = 60
lc.valueAxis.valueStep = 15
lc.lines[0].strokeWidth = 2
lc.lines[1].strokeWidth = 1.5
drawing.add(lc)
renderPDF.drawToFile(drawing, 'test.pdf', 'test')
Thanks, Xinhui
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20100107/6ace79a2/attachment.html>
More information about the reportlab-users
mailing list