0 Replies Latest reply on Oct 25, 2010 11:12 PM by NaveenKrish

    Nested data not working for flex charts.

    NaveenKrish

      I am currenlty creating a bar chart which has two series (price and quantity). Below is my code.
      I am not getting the chart rendered using the below code. It working with XML1 but not with XML2 . I have a to design my XML such that it looks like XML2 so that i can add more measures to my chart in runtime
      Is there any issue within. Please help me. I am really stuck on this.

       

       

       

      My Working XML1

       

      <?xml version='1.0' encoding='UTF-8'?>
      <Bars>
      <XYAxis label="Time">
        <Data id="1">
         <Dimension id="1">Jan</Dimension>
         <Measure id="1" name="Price">1000</Measure>
        </Data>
      </XYAxis>
      </Bars>

       

       

       

      My NotWorking XML2

       

      <?xml version='1.0' encoding='UTF-8'?>
      <Bars>
      <XYAxis label="Time">
        <Data id="1">
         <Dimension id="1">Jan</Dimension>
         <Measures>
          <Measure id="1" name="Price">1000</Measure>
          <Measure id="2" name="Quantity">2000</Measure>
         </Measures>
        </Data>
      </XYAxis>
      </Bars>

       


      My Code

       

      data = repData.children() ;

       

      var xAxisValue : String = "Dimension" ;

       

      dataForXYAxis = repData.XYAxis.children ( ) ;

       

      var noOfXYSeries : int = dataForXYAxis.length ( ) ;

       

      // MAIN CHART
      myChart = new ColumnChart ( ) ;
      myChart.showDataTips = true ;
      myChart.dataProvider = dataForXYAxis ;

       

      // AXIS 
      myChart.horizontalAxis = getCategoryAxis ( xAxisValue ) ;
      myChart.horizontalAxisRenderer = getAxisRenderers ( cAxis ) ;

       

      myChart.verticalAxis   = getLinearAxis ( minYValue, maxYValue, "Price\nQuantity" ) ;
      myChart.verticalAxisRenderer = getAxisRenderers ( lAxis ) ;

       

      // SERIES

       

      var mySeries : Array = new Array ( ) ;

       

      var measureLength : Number = repData.XYAxis.Data.Measures.children().length( ) ;

       

      for ( var i : Number=0 ; i < measureLength ; i++ ){

       

      var colSeries : ColumnSeries = new ColumnSeries ( ) ;
      colSeries.chartDataProvider = dataForXYAxis ;
      colSeries.xField = "Dimension" ;
      colSeries.yField = "Measure" ;
      mySeries.push( colSeries ) ;
      }