LineChart purely in Actionscript 3
Hello Chaps,
Below you’ll find a quick and simple Line Chart in Actionscript. You need to instantiate an Array Collection of data, here’s my dummy data;
private function getDataProvider():ArrayCollection {
var arr:Array = [];
arr.push({month: 2, data: 3});
arr.push({month: 4, data: 5});
arr.push({month: 6, data: 9});
arr.push({month: 11, data: 23});
return new ArrayCollection(arr);
}
Call this function below by some mean, or simply through initialize=”pieChartF()” in your header MXML… and voila, you’ve got yourself a pie Chart and it’s Legend.
private function lineChartF():void {
var arr:ArrayCollection = new ArrayCollection;
arr = getDataProvider();
var lineChart:LineChart = new LineChart();
lineChart.dataProvider = arr;
lineChart.percentWidth = 60;
lineChart.percentHeight = 60;
lineChart.x = 100;
lineChart.y = 85;
lineChart.showDataTips = true;
var lineSeries:LineSeries = new LineSeries();
lineSeries.xField = "month";
lineSeries.yField = "data";
var arr2:Array = new Array();
arr2.push(lineSeries);
lineChart.series = arr2;
var legendLine:Legend = new Legend();
legendLine.dataProvider = lineChart;
legendLine.x = 700;
legendLine.y = 140;
lineContainer.addChild(lineChart);
lineContainer.addChild(legendLine);
}
Add lineContainer to the id of any container you want, and run/debug.
Hey!! thanks for the simple linechart…. help’d me a lot … thanks a lot
Mani
December 31, 2008 at 11:33 am
[...] http://flexr.wordpress.com/2008/06/1…ctionscript-3/ [...]
LineChart creation problem
February 26, 2009 at 7:28 am
could u attach the sample files !?
it’s better with it, coz I’m still newbie…
thanks
renoido oizawa
July 4, 2009 at 6:57 am
thank u my dear fiend it helps me well
Anuroop Vincent
October 15, 2009 at 12:39 pm