0 Replies Latest reply on Jan 16, 2008 10:17 AM by echovalley1

    Chart bindable not working?

    echovalley1
      I am new to flex, here is my testing program for real-time charting. It simulates a JFreeChart TimeSeries, the series shifts left one point per second. The setInterval works, getData works, however, the chart is not refreshing. Could you advise? Thanks,
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" initialize="initApp()">
      <mx:Script>
      <![CDATA[
      [Bindable]
      var results: Array;

      var call:uint = 0;
      var interval: Number=1000;



      function initApp():void {
      results=new Array();
      for (var i:int=0; i<20; i++) {
      var tm:Date = new Date();
      results.push({time: tm, value: 20000+Math.round(Math.random()*10000)});
      }

      call=setInterval(getData, interval);
      }
      [Bindable]
      function getData():void {
      // In a real life scenario, you could poll the server here, or use an XMLSocket or Flash Communication Server
      // approach to push data from the server to the client.
      results.shift();
      var tm2:Date = new Date();
      var sizeOfresult:uint = results.push({time: tm2, value: 20000+Math.round(Math.random()*10000)});
      trace(sizeOfresult);


      }


      ]]>
      </mx:Script>

      <mx:LineChart id="chart" dataProvider="{results}" showDataTips="true" width="100%" height="100%">

      <mx:horizontalAxis>
      <mx:CategoryAxis dataProvider="{results}" categoryField="time"/>
      </mx:horizontalAxis>


      <mx:series>

      <mx:LineSeries dataProvider="{results}" yField="value" displayName="Total"/>

      </mx:series>


      </mx:LineChart>

      </mx:Application>