0 Replies Latest reply on Aug 15, 2010 5:58 AM by UltimediaBE

    Dynamic data inside a chart's dataProvider


      Dear Members,


      I am adding some extra touches to my application, it's basically a tool to give online presentations so I would like to add some charts for a more visual experience.


      I am using the Flex Pie Chart that I create dynamically with actionscript:


      private function createChart():void
           series = new PieSeries();
           series.nameField = "label";
           series.field = "data";
           series.filters = [];
           chart = new PieChart();
           chart.percentWidth =100;
           chart.percentHeight = 100;
           chart.showDataTips = true;
           chart.dataProvider = medalsAC;
           chart.series = [series];


      The above code works fine, the problem is with providing the data for my chart. Below you can see that I created some variables in which I store data. Now the problem is that when I assign these variables like you see below, the chart won't show them. It only shows the static data (200) from the first product.


      So I wonder what I am possibly doing wrong? I guess it's something very simple, but without those dynamic vars I can't use the charts.


      private function setChartData():void
           var data2:uint = 200;    
           var data3:uint = 300;
           var data4:uint = 200;
           var arr:Array = [];
           arr.push({label:"Product 1", data: 200});
           arr.push({label:"Product 2", data:data2)});
           arr.push({label:"Product 3", data:data3});
           arr.push({label:"Product 4", data:data4});
           medalsAC = new ArrayCollection(arr);