1 Reply Latest reply on Mar 25, 2008 5:09 AM by theNOCer

    Null values coming from JSON

    theNOCer Level 1
      Ok. heres whats going on. I have a bunch of charts all with two series , demand and baseline. About half of them have a null value for the last value in demand and of the half 2 have null for the entire baseline.

      my problem is one of the afore mentioned 2 charts will not show up (chart shows but without lines) unless I iterate through and set all null values to zero in the baseline series. Then baseline will lie on the x axis(BAD) and demand will show correctly(missing the last value because it null, GOOD)

      my question is why? why does demand disappear when baseline values are null? here is some code to maybe help you out


      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
      layout="vertical" viewSourceURL="srcview/index.html" preinitialize="srv.send();" uid="theApp">

      import mx.charts.series.LineSeries;
      import mx.charts.chartClasses.Series;
      import mx.charts.AxisRenderer;
      import mx.charts.CategoryAxis;
      import mx.controls.HorizontalList;
      import mx.containers.Panel;

      import mx.collections.ArrayCollection;
      import mx.rpc.events.ResultEvent;
      import com.adobe.serialization.json.JSON;
      import mx.controls.Alert;
      import mx.utils.ObjectUtil;

      [Bindable]private var ercotDem:Array = new Array();
      [Bindable]private var ercotBase:Array = new Array();

      [Bindable]private var times:Array = new Array();

      private function onJSONLoad(event:ResultEvent):void{
      // ---- i know this json stuff works.
      // ---- i have printed out the data and cheaked
      // ---- to make sure its goign into the array correctly
      // ---- and i use it all over the place in other files
      var rawData:String = String(event.result);
      var jsonOBJ:Object = (JSON.decode(rawData) );
      ercotDem = jsonOBJ.ERCOT.demand as Array;
      ercotBase = jsonOBJ.ERCOT.baseline as Array;
      times = jsonOBJ.times as Array;

      } catch(err:Error){
      private function popup():void{


      <!-- other charts here too -->
      <mx:Panel title="Ercot Demand" height="300" width="600" layout="horizontal">
      <mx:LineChart id="linechart_ercot" height="100%" width="100%"
      showDataTips="true" dataProvider="{times}" mouseSensitivity="50">
      <mx:CategoryAxis />
      <mx:AxisRenderer canDropLabels="true" canStagger="true" />
      <mx:LineSeries displayName="Ercot Baseline" dataProvider="{ercotBase}" />
      <mx:LineSeries displayName=" Ercot" dataProvider="{ercotDem}" />

      <mx:HTTPService id="srv" resultFormat="text" showBusyCursor="true"
      result="onJSONLoad(event)" fault="popup()" />

      keep in mind this is only one panel theres about 9 and all of them work as expected and the code is all the same.

      any ideas?