#Autogenerated by ReportLab guiedit do not edit
from rlextra.graphics.guiedit.datacharts import DataAwareDrawing, ODBCDataSource, DataAssociation
from reportlab.graphics.charts.barcharts import HorizontalBarChart
from reportlab.graphics.shapes import _DrawingEditorMixin
from reportlab.lib.colors import yellow, red

class FundBreakdownHBarDrawing(_DrawingEditorMixin,DataAwareDrawing):
	def __init__(self,width=400,height=200,*args,**kw):
		DataAwareDrawing.__init__(self,width,height,*args,**kw)
		self._add(self,HorizontalBarChart(),name='chart',validate=None,desc=None)
		self.chart.x                = 100
		self.chart.y                = 20
		self.chart.data             = [(10,9,8,7,6,5,3,4,2,1)]
		self.chart.reversePlotOrder = 0
		self.chart.height           = 160
		self.chart.bars.fillColor     = yellow
		self.chart.valueAxis.forceZero           = 1
		self.chart.valueAxis.labels.fontName       = 'Helvetica'
		self.dataSource      = ODBCDataSource()
		self.dataSource.sql            = 'SELECT rowId, fundId,  fundName,  label, fundValue FROM breakdownByHolding'
		self.dataSource.associations.size = 4
		self.dataSource.associations.element00 = DataAssociation(column=0, target='chartId', assocType='scalar')
		self.outDir          = 'output'
		self.fileNamePattern = 'holdings%03d'
		self.formats         = ['eps', 'gif','pdf']
		self.dataSource.associations.element00 = DataAssociation(column=1, target='chartId', assocType='scalar')
		self.fileNamePattern = 'holdings_%s'
		self.formats         = ['pdf']
		self.verbose         = 1
		self.dataSource.sql            = 'SELECT fundId,  fundName,  label, fundValue FROM breakdownByHolding ORDER BY fundId, fundValue DESC'
		self.dataSource.associations.element00 = DataAssociation(column=0, target='chartId', assocType='scalar')
		self.dataSource.associations.element01.column    = [3]
		self.dataSource.associations.element01.target    = 'chart.data'
		self.dataSource.associations.element01.assocType='matrix'
		self.chart.barSpacing       = 4
		self.formats         = ['pdf','gif','eps']

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