[reportlab-users] Looks like a bug ...
Johan Paul Glutting
reportlab-users@reportlab.com
Mon, 04 Oct 2004 10:37:44 +0200
I think I found a bug in ReportLab. When drawing a Line Chart (I am
using the HorizontalLineChart class), if the first value in a series is
Null, the labels on the points are shifted to the right, although the
lines are drawn correctly. Example:
data = [None, 10, 15, 20]
produces something like this (flat line - this is ASCII graphics after
all ...)
None 10 15
x x_________x_________x
where this data prints out like this:
data = [10, 15, 20, None]
10 15 20
x__________x_______x x
The first set of data can be fixed by substituting "0" for "None", like
this:
data = [0, 10, 15, 20]
0 10 15 20
x_________x________x________x
I discovered this because I am doing data on student registration, by
degree. Some degrees just did not exist before a certain date, and so
the number of students is Null, rather than zero, and there should be no
line drawn on the graph at all...
Some fake code that should reproduce this:
D = Drawing()
lc1 = HorizontalLineChart()
lc2 = HorizontalLineChart()
lc1.data = [[None, 10, 15, 20],[None, 30, 35, 40]]
lc2.data = [[0, 10, 15, 20],[0, 30, 35, 40]]
lc1.lines.symbol = makeMarker('FilledDiamond')
lc2.lines.symbol = makeMarker('FilledDiamond')
lc1.lineLabelFormat = '%s'
lc2.lineLabelFormat = '%s'
D.add(lc1)
D.add(lc2)
fakedoc.Elements.append(D)
I will take a look at the code and see if I can figure out what is going
on (it looks like the data drawing funciton is taking al the values, but
the label drawing function starts the label list from the first value
onto the first visible data point, instead of the proper index...).
Cheers,
JP
--
JP Glutting
Oficina de Qualitat Plaça Víctor Siurana, 1
Universitat de Lleida 25003 Lleida
-------------------------------------------------------
Tel: 973 703 103 Fax: 973 702 036