Thursday, September 17, 2009

Creating the Column chart dynamically

Creating the Column chart dynamically


private function getData():ArrayCollection
{
var arr:Array = [];
arr.push({Month:"Jan", Profit:500});
arr.push({Month:"Feb", Profit:800});
arr.push({Month:"Mar", Profit:1000});
arr.push({Month:"Apr", Profit:700});
arr.push({Month:"May", Profit:900});
return new ArrayCollection(arr);
}


public function CreateColumnChart():void
{
Alert.show("CreateColumnChart");
var colmnChart:ColumnChart = new ColumnChart();
colmnChart.dataProvider =getData();
var catAxis:CategoryAxis = new CategoryAxis();
catAxis.categoryField = "Month";
colmnChart.horizontalAxis = catAxis;
var col:ColumnSeries = new ColumnSeries();
col.yField = "Profit";
col.xField = "Month";
colmnChart.series = [col];
colmnChart.visible = true;
hBox1.addChild(colmnChart);
}

No comments:

Post a Comment