Hier nochmal der komplette Code:
class AreaChart01(_DrawingEditorMixin,Drawing):
def __init__(self,width=300,height=169,*args,**kw):
Drawing.__init__(self,width,height,*args,**kw)
self._colors = PCMYKColor(66,13,0,22, alpha=40) ,PCMYKColor(0,100,100,40) ,PCMYKColor(100,0,90,50) ,PCMYKColor(0,0,0,40) ,PCMYKColor(10,0,100,11) ,PCMYKColor(15,0,0,0) ,PCMYKColor(0,0,0,50)
self._add(self,Rect(0,0,self.width,self.height,fillColor=self._colors[5],strokeColor=None),name='bgrect1',validate=None,desc=None)
# chart
self._add(self,LinePlot(),name='chart',validate=None,desc=None)
self.chart.x = 20
self.chart.y = 90
self.chart.width = 90
self.chart.height = 60
self.chart.lines[0].strokeColor = self._colors[0]
# drawing background
# chart background
self.bgrect1.x = 0
self.bgrect1.width = 0
self.bgrect1.height = 0
# x axis
self.chart.xValueAxis.gridEnd = 0
self.chart.xValueAxis.gridStart = 0
self.chart.xValueAxis.gridStrokeWidth = 0.1
self.chart.xValueAxis.joinAxisMode='bottom'
self.chart.xValueAxis.labels.boxAnchor = 'e'
self.chart.xValueAxis.labels.dx = -2
self.chart.xValueAxis.labels.dy = -5
self.chart.xValueAxis.labels.fontName = 'Times-Roman'
self.chart.xValueAxis.labels.fontSize = 2
self.chart.xValueAxis.maximumTicks = 7
self.chart.xValueAxis.minimumTickSpacing = 5 # in points
self.chart.xValueAxis.strokeColor = self._colors[6]
self.chart.xValueAxis.strokeWidth = 0.1
self.chart.xValueAxis.tickDown = 2
self.chart.xValueAxis.valueSteps = None
self.chart.xValueAxis.visibleGrid = False
# y axis
self.chart.yValueAxis.avoidBoundFrac = 0.1
self.chart.yValueAxis.drawGridLast = True
self.chart.yValueAxis.forceZero = True
self.chart.yValueAxis.gridStrokeColor = self._colors[6]
self.chart.yValueAxis.gridStrokeWidth = 0.1
self.chart.yValueAxis.labels.dy = 0
self.chart.yValueAxis.labels.fontName = 'Times-Roman'
self.chart.yValueAxis.labels.fontSize = 2
self.chart.yValueAxis.labels.rightPadding = 5
self.chart.yValueAxis.labelTextFormat = DecimalFormatter(places=0,thousandSep=',',decimalSep='.')
self.chart.yValueAxis.maximumTicks = 4
self.chart.yValueAxis.rangeRound='floor'
self.chart.yValueAxis.strokeColor = self._colors[6]
self.chart.yValueAxis.strokeWidth = 0.1
self.chart.yValueAxis.tickLeft = 2
self.chart.yValueAxis.tickRight = 0
self.chart.yValueAxis.valueMax = 60
self.chart.yValueAxis.valueMin = 0
self.chart.yValueAxis.valueStep = 5
self.chart.yValueAxis.visibleAxis = True
self.chart.yValueAxis.visibleGrid = True
self.chart.yValueAxis.visibleTicks = True
# legend
self._add(self,Legend(),name='legend',validate=None,desc=None)
self.legend.alignment = 'right'
self.legend.boxAnchor = 'sw'
self.legend.columnMaximum = 8
self.legend.deltax = 20
self.legend.deltay = 0
self.legend.dx = 5
self.legend.dxTextSpace = 5
self.legend.dy = 5
self.legend.fontName = 'Times-Roman'
self.legend.fontSize = 2
self.legend.strokeColor = None
self.legend.strokeWidth = 0
self.legend.x = self.chart.x + self.chart.width + 5
self.legend.yGap = 0
self.legend.y = self.chart.y
# sample data
data1=map(lambda x,y: (x,y), kwn,tbu)
print(data1)
data2=map(lambda x,y: (x,y), kwn,tcl)
print(data2)
data3=map(lambda x,y: (x,y), kwn,tca)
print(data3)
self.chart.data = [data1,data2,data3]
self._seriesNames = 'Total cumulated', 'Closed cumulated', 'Closed & \nPlanAgreed cumulated'
self.bgrect1.fillColor = PCMYKColor(10,10,10,10,alpha=100)
self.chart.lines.strokeWidth = 0.1
def getContents(self):
self.legend.colorNamePairs = zip(self._colors, self._seriesNames)
for i in range(len(self._seriesNames)): self.chart.lines[i].strokeColor= self._colors[i]
return Drawing.getContents(self)
if __name__=="__main__": #NORUNTESTS
AreaChart01().save(formats=['pdf'],outDir='.',fnRoot='ticket_report')