Skip to content

LineChart purely in Actionscript 3

June 10, 2008

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();


   lineChart.series = arr2;

   var legendLine:Legend = new Legend();

       legendLine.dataProvider = lineChart;
       legendLine.x = 700;
       legendLine.y = 140;

Add lineContainer to the id of any container you want, and run/debug.


From → Uncategorized

  1. Mani permalink

    Hey!! thanks for the simple linechart…. help’d me a lot … thanks a lot

  2. renoido oizawa permalink

    could u attach the sample files !?

    it’s better with it, coz I’m still newbie…


  3. Anuroop Vincent permalink

    thank u my dear fiend it helps me well

  4. Mike permalink

    Clearly laid out and easy to implement. Thank you.

Trackbacks & Pingbacks

  1. LineChart creation problem

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: