[reportlab-users] y-axis scaling issue with GridLinePlot
Mark Lippett
mlippett at googlemail.com
Wed Nov 16 02:57:28 EST 2011
Hi folks,
I have just spotted some weird behaviour with GridLinePlot in a django
project. It seems that the shape of the line plotted is OK, but that the
y-axis labels are out of whack. The code I am using is below:
class MyLineChartDrawing(Drawing):
def __init__(self, width=600, height=400, *args, **kw):
apply(Drawing.__init__,(self,width,height)+args,kw)
self.add(GridLinePlot(), name='chart')
self.chart.x = 50 # The x coordinate of the reference point
self.chart.y = 30 # The y coordinate of the reference point
self.chart.width = self.width - 150 # The width of the chart
self.chart.height = self.height - 75 # The height of the chart
self.chart.data = [[('20110930', 80), ('20111007', 116), ('20111014',
139), ('20111021', 163), ('20111028', 105), ('20111104', 97), ('20111111',
112)]]
def HttpChart (self, title, XLabel, YLabel, data, isPercent=False):
return (renderSVG.drawToString(self))
To call this I am simply doing the following
d = MyLineChartDrawing(width=chartWidth, height=chartHeight)
return HttpResponse(d.HttpChart ("", "", "MyYAxisTitle", edata),
'image/svg+xml')
It appears that there is some scaling going on, which becomes quite
dramatic when I add more data. For example, this self.chart.data list,
which simply adds one tuple to the front of the list, causes scaling to go
from comparatively subtly wrong to about 50% out.
self.chart.data = [[('20110923', 32), ('20110930', 80), ('20111007',
116), ('20111014', 139), ('20111021', 163), ('20111028', 105),
('20111104', 97), ('20111111', 112)]]
I am using ReportLab 2.5, Django 1.3.0, Python 2.7 running on OSX 10.7.2.
Thanks in advance for any help or advice,
-Mark
More information about the reportlab-users
mailing list