0 Replies Latest reply on May 16, 2007 11:27 AM by bvillemure

    Using List to Update LineChart Problem

    bvillemure
      I'm a flex newbie...I'm simply trying to read the selectedItem from a List component, using a click event to call a function that then employs the selectedIndex in a switch conditional to dynamically update the chart. The confusing part is that it will generate list index items 0 and 1, but upon trying to click a list item with an index of 2 or higher I get thrown the following error:

      TypeError: Error #2007: Parameter child must be non-null.

      I'm tracing the selectedIndex and selectedItem and both seem to be getting the appropriate values?
      I've posted the portion of bad code that I'm grappling with and any help here would greatly be appreciated...thanks!

      /////////////////////////////////////////////////////////////////

      public function drawChart():void {
      //var numItems:int = fieldList2.selectedIndices.length;

      var selectedIndex:int = fieldList2.selectedIndex;
      var selectedName:String = fieldList2.selectedItem.toString();
      trace(selectedIndex);
      trace(selectedName);
      //trace(numItems);

      var ls:LineSeries= new LineSeries();
      linechart2.series = [ls];
      // associate the array
      //create a series for each series of data

      switch(selectedIndex){
      //Win series
      case 0:
      ls = new LineSeries();
      ls.displayName = selectedName;
      ls.yField = '@offrailW';
      linechart2.series[0] = ls;
      break;

      //Place series
      case 1:
      ls = new LineSeries();
      ls.displayName = selectedName;
      ls.yField = '@offrailP';
      linechart2.series[1] = ls;
      break;

      //Show series
      case 2:
      ls = new LineSeries();
      ls.displayName = selectedName;
      ls.yField = '@offrailS';
      linechart2.series[2] = ls;
      break;

      //4th series
      case 3:
      ls = new LineSeries();
      ls.displayName = selectedName;
      ls.yField = '@offrail4';
      linechart2.series[3] = ls;
      break;
      }
      }
      ]]>
      </mx:Script>
      <mx:HTTPService id="pocDataRPC"
      url=" http://localhost/corp/Flex-Dev/sampleSet.xml"
      resultFormat="e4x"
      fault="showFault(event)"/>
      <!-- result="pocRPCResult(event)" -->

      <mx:XMLListCollection id="pocData"
      source="{pocDataRPC.lastResult.field.chart}"/>

      <mx:HTTPService id="fieldDataRPC"
      url=" http://localhost/corp/Flex-Dev/fieldData.xml"
      result="fieldRPCResult(event)"
      fault="showFault(event)"/>

      <mx:Panel title="Trakus Charts" width="600" height="500" layout="absolute">
      <mx:TabNavigator width="100%" height="100%">
      <mx:HBox label="Dynamic Chart" height="100%" width="100%">
      <!-- Series are added to this chart dynamically -->
      <mx:LineChart id="linechart2"
      paddingLeft="5" paddingRight="5"
      showDataTips="true"
      dataProvider="{pocData}">
      <mx:horizontalAxis>
      <mx:CategoryAxis categoryField="@poc"/>
      </mx:horizontalAxis>
      </mx:LineChart>
      <mx:VBox>
      <mx:List width="100%" id="fieldList2"
      dataProvider="{dpField}"
      doubleClickEnabled="true"
      doubleClick="drawChart()"></mx:List>
      </mx:VBox>
      </mx:HBox>