#Autogenerated by ReportLab guiedit do not edit
import reportlab
from reportlab.graphics.widgets.grids import ShadedRect
from reportlab.lib.colors import PCMYKColor, white, red
from rlextra.graphics.guiedit.datacharts import DataAwareDrawing, CSVDataSource, ODBCDataSource, Array, DataAssociation
from reportlab.graphics.charts.barcharts import VerticalBarChart
from reportlab.lib.corp import cm
from reportlab.graphics.shapes import _DrawingEditorMixin, String

class CylinderBarStacked(_DrawingEditorMixin,DataAwareDrawing):
	def __init__(self,width=400,height=200,*args,**kw):
		DataAwareDrawing.__init__(self,width,height,*args,**kw)
		self.width           = 8.4*cm
		self.height          = 8.3*cm
		self.outDir          = './output/'
		self.verbose         = 1
		self._add(self,VerticalBarChart(),name='chart',validate=None,desc='Main bar chart')
		self.chart.barLabels.fontName        = 'Helvetica'
		self.chart.barLabels.fontSize        = 7
		self.chart.data           = [(3389, 19444, 8744, 11200), (3389, 19444, 8744, 11200)]
		self.chart.barLabelFormat = '\xc2\xa3%d'
		self.chart.groupSpacing   = 0.55*cm
		self.chart.bars.symbol        = ShadedRect()
		self.chart.bars.symbol.cylinderMode   = 1
		self.chart.bars.symbol.fillColorEnd   = PCMYKColor(0,0,0,0)
		self.chart.bars.symbol.fillColorStart = PCMYKColor(86,0,17,0)
		self.chart.y              = 2.7*cm
		self.chart.x              = 1.5*cm
		self.chart.valueAxis.tickLeft           = 0
		self.chart.categoryAxis.tickDown        = 0
		self.chart.categoryAxis.visibleAxis     = 0
		self.chart.categoryAxis.visibleTicks    = 1
		self.chart.categoryAxis.categoryNames   = ['1 year', '3 year', '5 year', '10 year']
		self.chart.categoryAxis.labels.fontName     = 'Helvetica'
		self.chart.categoryAxis.labels.fontSize     = 7
		self.chart.valueAxis.labels.fontName        = 'Helvetica'
		self.chart.valueAxis.labels.fontSize        = 7
		self.chart.valueAxis.valueMin           = 0
		self.chart.valueAxis.valueMax           = 20000
		self.chart.valueAxis.valueMax           = None
		self.chart.valueAxis.valueMin           = None
		self.chart.valueAxis.visibleAxis        = 0
		self.chart.valueAxis.strokeColor        = None
		self.chart.valueAxis.forceZero          = 1
		self.chart.bars.strokeColor   = None
		self.chart.bars.symbol.strokeColor    = None
		self.chart.barLabels.dy              = 0.2*cm
		self.chart.barWidth       = 0.7*cm
		self.chart.barSpacing     = 0.6*cm
		self._add(self,String(self.width/2.0,1.6*cm,''),name='caption',validate=None,desc='Caption below this table')
		self.caption.fontName   = 'Helvetica'
		self.caption.fontSize   = 7
		self.caption.text       = 'Savings Split'
		self.caption.textAnchor = 'middle'
		self.fileNamePattern = 'stackedbars%03d'
		self.formats         = ['eps','pdf']
		self.chart.bars.symbol.numShades      = 50
		self.chart.height         = 4.5*cm
		self.dataSource      = CSVDataSource()
		self.dataSource.filename = 'stackedBar.csv'
		self.dataSource.groupingColumn = 'chartId'
		self.dataSource.integerColumns = ['chartId','rowId']
		self.dataSource.floatColumns = ['value1','value2','value3']
		self.dataSource.sep = '\t'
		self.dataSource.associations   = Array(3, DataAssociation)
		self.dataSource.sql            = 'SELECT * FROM generic_bar ORDER BY chartId, rowId'
		self.dataSource.associations.element00 = DataAssociation(column=0, target='chartId', assocType='scalar')
		self.dataSource.associations.element01 = DataAssociation(column=[3,4], target='chart.data', assocType='tmatrix')
		self.dataSource.associations.element02 = DataAssociation(column=2, target='chart.categoryAxis.categoryNames', assocType='vector')
		self.skipIfColumnIsNull(3)
		self.skipIfColumnContainsNull(3)
		self.chart.bars.symbol        = None
		self.chart.bars[0].symbol=ShadedRect()
		self.chart.bars[0].symbol.cylinderMode   = 1
		self.chart.bars[0].symbol.fillColorEnd   = PCMYKColor(0,0,0,0)
		self.chart.bars[0].symbol.fillColorStart = PCMYKColor(86,0,17,0)
		self.chart.bars[0].symbol.numShades      = 50
		self.chart.bars[0].symbol.strokeColor    = None
		self.chart.bars[1].symbol=ShadedRect()
		self.chart.bars[1].symbol.cylinderMode   = 1
		self.chart.bars[1].symbol.fillColorEnd   = PCMYKColor(0,0,0,0)
		self.chart.bars[1].symbol.fillColorStart = PCMYKColor(0,100,91,0)
		self.chart.bars[1].symbol.numShades      = 50
		self.chart.bars[1].symbol.strokeColor    = None
		self.chart.categoryAxis.style='stacked'
		self.chart.barLabels.dy              = -5.66929133858
		self.chart.categoryAxis.labels.maxWidth       = 40
		self.chart.categoryAxis.labels.width          = None
		self.chart.categoryAxis.labels.maxWidth       = 25
		self.chart.categoryAxis.labels.fontSize       = 6
		self.chart.categoryAxis.labels.textAnchor     = 'middle'

if __name__=="__main__": #NORUNTESTS
	CylinderBarStacked().go()
