1
#Autogenerated by ReportLab guiedit do not edit
2
from reportlab.graphics.charts.legends import Legend
3
from reportlab.graphics.charts.lineplots import LinePlot
4
from reportlab.graphics.shapes import Drawing, _DrawingEditorMixin, String
5
from reportlab.graphics.charts.textlabels import Label
6
from excelcolors import *
8
class LineChart(_DrawingEditorMixin,Drawing):
9
def __init__(self,width=200,height=150,*args,**kw):
10
apply(Drawing.__init__,(self,width,height)+args,kw)
11
self._add(self,LinePlot(),name='chart',validate=None,desc="The main chart")
12
self.chart.width = 115
13
self.chart.height = 80
16
self.chart.lines[0].strokeColor = color01
17
self.chart.lines[1].strokeColor = color02
18
self.chart.lines[2].strokeColor = color03
19
self.chart.lines[3].strokeColor = color04
20
self.chart.lines[4].strokeColor = color05
21
self.chart.lines[5].strokeColor = color06
22
self.chart.lines[6].strokeColor = color07
23
self.chart.lines[7].strokeColor = color08
24
self.chart.lines[8].strokeColor = color09
25
self.chart.lines[9].strokeColor = color10
26
self.chart.fillColor = backgroundGrey
27
self.chart.lineLabels.fontName = 'Helvetica'
28
self.chart.xValueAxis.labels.fontName = 'Helvetica'
29
self.chart.xValueAxis.labels.fontSize = 7
30
self.chart.xValueAxis.forceZero = 0
31
self.chart.data = [((0, 50), (100,100), (200,200), (250,210), (300,300), (400,500)), ((0, 150), (100,200), (200,300), (250,200), (300,400), (400, 600))]
32
self.chart.xValueAxis.avoidBoundFrac = 1
33
self.chart.xValueAxis.gridEnd = 115
34
self.chart.xValueAxis.tickDown = 3
35
self.chart.xValueAxis.visibleGrid = 1
36
self.chart.yValueAxis.tickLeft = 3
37
self.chart.yValueAxis.labels.fontName = 'Helvetica'
38
self.chart.yValueAxis.labels.fontSize = 7
39
self._add(self,Label(),name='Title',validate=None,desc="The title at the top of the chart")
40
self.Title.fontName = 'Helvetica-Bold'
41
self.Title.fontSize = 7
44
self.Title._text = 'Chart Title'
45
self.Title.maxWidth = 180
46
self.Title.height = 20
47
self.Title.textAnchor ='middle'
48
self._add(self,Legend(),name='Legend',validate=None,desc="The legend or key for the chart")
49
self.Legend.colorNamePairs = [(color01, 'Widgets'), (color02, 'Sprockets')]
50
self.Legend.fontName = 'Helvetica'
51
self.Legend.fontSize = 7
54
self.Legend.dxTextSpace = 5
57
self.Legend.deltay = 5
58
self.Legend.alignment ='right'
59
self._add(self,Label(),name='XLabel',validate=None,desc="The label on the horizontal axis")
60
self.XLabel.fontName = 'Helvetica'
61
self.XLabel.fontSize = 7
64
self.XLabel.textAnchor ='middle'
65
self.XLabel.maxWidth = 100
66
self.XLabel.height = 20
67
self.XLabel._text = "X Axis"
68
self._add(self,Label(),name='YLabel',validate=None,desc="The label on the vertical axis")
69
self.YLabel.fontName = 'Helvetica'
70
self.YLabel.fontSize = 7
73
self.YLabel.angle = 90
74
self.YLabel.textAnchor ='middle'
75
self.YLabel.maxWidth = 100
76
self.YLabel.height = 20
77
self.YLabel._text = "Y Axis"
78
self.chart.yValueAxis.forceZero = 1
79
self.chart.xValueAxis.forceZero = 1
80
self._add(self,0,name='preview',validate=None,desc=None)
82
if __name__=="__main__": #NORUNTESTS
83
LineChart().save(formats=['pdf'],outDir=None,fnRoot='line_chart')