#Autogenerated by ReportLab guiedit do not edit
from rlextra.graphics.guiedit.datacharts import DataAwareDrawing, XMLDataSource
from reportlab.graphics.charts.barcharts import HorizontalBarChart
from reportlab.graphics.shapes import _DrawingEditorMixin, String

class DataAwareDrawing_000(_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.dataSource      = XMLDataSource()
		self.chart.data             = [(100, 110, 120, 130)]
		self.chart.y                = 20
		self.chart.x                = 100
		self._add(self,String(100,180,'Hello Chart'),name='title',validate=None,desc=None)
		self.dataSource.fileName      = 'sampleBar.xml'
		self.dataSource.associations.element00.expression = 'str(data.title)'
		self.dataSource.associations.element00.target     = 'title.text'
		self.dataSource.associations.element01.expression = "[float(node.percent) for node in data if node.tagName == 'holding']"
		self.dataSource.associations.element01.target     = 'chart.data'
		self.dataSource.associations.element01.expression = "[[float(node.percent)] for node in data if node.tagName == 'holding']"
		self.formats         = ['pdf', 'gif']
		self.outDir          = './output'
		self.chart.height           = 150
		self.dataSource.associations.element01.expression = "[[float(node.percent) for node in data if node.tagName == 'holding']]"
		self.dataSource.associations.size      = 3
		self.dataSource.associations.element02.target     = 'chart.categoryAxis.categoryNames'
		self.dataSource.associations.element02.expression = "[node.name for node in data if node.tagName == 'holding']"

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