1
#Autogenerated by ReportLab guiedit do not edit
2
from reportlab.graphics.charts.piecharts import Pie
3
from reportlab.graphics.widgets.grids import ShadedRect
4
from reportlab.graphics.charts.legends import Legend
5
from reportlab.graphics.shapes import Drawing, _DrawingEditorMixin, String
6
from reportlab.graphics.charts.textlabels import Label
7
from excelcolors import *
9
class SimplePie(_DrawingEditorMixin,Drawing):
10
def __init__(self,width=200,height=150,*args,**kw):
11
apply(Drawing.__init__,(self,width,height)+args,kw)
12
self._add(self,Pie(),name='chart',validate=None,desc="The main chart")
13
self.chart.width = 100
14
self.chart.height = 100
17
self.chart.slices[0].fillColor = color01
18
self.chart.slices[1].fillColor = color02
19
self.chart.slices[2].fillColor = color03
20
self.chart.slices[3].fillColor = color04
21
self.chart.slices[4].fillColor = color05
22
self.chart.slices[5].fillColor = color06
23
self.chart.slices[6].fillColor = color07
24
self.chart.slices[7].fillColor = color08
25
self.chart.slices[8].fillColor = color09
26
self.chart.slices[9].fillColor = color10
27
self.chart.data = (100, 150, 180)
28
self._add(self,Label(),name='Title',validate=None,desc="The title at the top of the chart")
29
self.Title.fontName = 'Helvetica-Bold'
30
self.Title.fontSize = 7
33
self.Title._text = 'Chart Title'
34
self.Title.maxWidth = 180
35
self.Title.height = 20
36
self.Title.textAnchor ='middle'
37
self._add(self,Legend(),name='Legend',validate=None,desc="The legend or key for the chart")
38
self.Legend.colorNamePairs = [(color01, 'North'), (color02, 'South'),(color03, 'Central')]
39
self.Legend.fontName = 'Helvetica'
40
self.Legend.fontSize = 7
43
self.Legend.dxTextSpace = 5
46
self.Legend.deltay = 5
47
self.Legend.alignment ='right'
48
self.chart.slices.strokeWidth = 1
49
self.chart.slices.fontName = 'Helvetica'
50
self.background = ShadedRect()
51
self.background.fillColorStart = backgroundGrey
52
self.background.fillColorEnd = backgroundGrey
53
self.background.numShades = 1
54
self.background.strokeWidth = 0.5
55
self.background.x = 25
56
self.background.y = 25
57
self.Legend.columnMaximum = 10
58
self._add(self,0,name='preview',validate=None,desc=None)
60
if __name__=="__main__": #NORUNTESTS
61
SimplePie().save(formats=['pdf'],outDir=None,fnRoot=None)
b'\\ No newline at end of file'