1
#Autogenerated by ReportLab guiedit do not edit
2
from reportlab.graphics.charts.piecharts import Pie
3
from excelcolors import *
4
from reportlab.graphics.widgets.grids import ShadedRect
5
from reportlab.graphics.charts.legends import Legend
6
from reportlab.graphics.shapes import Drawing, _DrawingEditorMixin, String
7
from reportlab.graphics.charts.textlabels import Label
9
class ExplodedPie(_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.chart.startAngle = -90
29
self._add(self,Label(),name='Title',validate=None,desc="The title at the top of the chart")
30
self.Title.fontName = 'Helvetica-Bold'
31
self.Title.fontSize = 7
34
self.Title._text = 'Chart Title'
35
self.Title.maxWidth = 180
36
self.Title.height = 20
37
self.Title.textAnchor ='middle'
38
self._add(self,Legend(),name='Legend',validate=None,desc="The legend or key for the chart")
39
self.Legend.colorNamePairs = [(color01, 'North'), (color02, 'South'), (color03, 'Central')]
40
self.Legend.fontName = 'Helvetica'
41
self.Legend.fontSize = 7
44
self.Legend.dxTextSpace = 5
47
self.Legend.deltay = 5
48
self.Legend.alignment ='right'
49
self.Legend.columnMaximum = 10
50
self.chart.slices.strokeWidth = 1
51
self.chart.slices.fontName = 'Helvetica'
52
self.background = ShadedRect()
53
self.background.fillColorStart = backgroundGrey
54
self.background.fillColorEnd = backgroundGrey
55
self.background.numShades = 1
56
self.background.strokeWidth = 0.5
57
self.background.x = 20
58
self.background.y = 20
59
self.chart.slices.popout = 5
60
self.background.height = 110
61
self.background.width = 110
62
self._add(self,0,name='preview',validate=None,desc=None)
64
if __name__=="__main__": #NORUNTESTS
65
ExplodedPie().save(formats=['pdf'],outDir=None,fnRoot='exploded_pie')
b'\\ No newline at end of file'