17 Replies Latest reply on May 14, 2009 6:28 PM by Michael Borbor

    Why does the second chart not show?

    kavehg

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application     xmlns:mx="http://www.adobe.com/2006/mxml"
                          xmlns:data="com.kg.data.*"
                          width="100%"
                          height="100%"
                          initialize="getParameterNumbers()"
                          backgroundColor="#FFFFFF">

       

          <mx:Script>
              <![CDATA[          
                  import mx.rpc.events.FaultEvent;
                  import mx.rpc.events.ResultEvent;
                  import mx.collections.ArrayCollection;
                  import mx.charts.PieChart;
                  import mx.charts.series.PieSeries;
                  import mx.charts.Legend;           
                  import com.kg.data.ParameterCount;

                  [Bindable]
                  public var paramCount:ArrayCollection;
             
                  // Get the initial data set from the server
                  private function getParameterNumbers():void {
                      remoteObject.getParameterCount();
                      addSecondChart();
                  }

       

                  // Handle the recevied message.
                  private function resultHandler(event:ResultEvent):void {
                      paramCount = new ArrayCollection();
                      var parameterResultData:ArrayCollection = ArrayCollection(event.result);
                      var resultLength:Number = parameterResultData.length;
                      for(var i:Number = 0; i < resultLength; i++) {
                          var tempParamResult:ParameterCount = new ParameterCount();
                          tempParamResult.name = parameterResultData.getItemAt(i).name;
                          tempParamResult.count = parameterResultData.getItemAt(i).count;
                          paramCount.addItem(tempParamResult);
                      }
                  }

       

                  // Handle a message fault.
                  private function faultHandler(event:FaultEvent):void {
                      statusTextArea.text += "Received fault: " + event.fault + "\n";
                  }          

       

                 
                  public function addSecondChart():void {
                      var chart:PieChart;
                      var series:PieSeries;

       

                      series = new PieSeries();
                      series.nameField = "name";
                      series.field = "count";
                      series.filters = [];

       

                      chart = new PieChart();
                      chart.percentWidth = 100;
                      chart.percentHeight = 100;
                      chart.showDataTips = true;
                      chart.dataProvider = paramCount;
                      chart.series = [series];

       

                      p1.addChild(chart);
                  }

       

              ]]>
          </mx:Script>

       

          <mx:RemoteObject id="remoteObject"
              destination="pokerDataSource"
              result="resultHandler(event);"
              fault="faultHandler(event);"/>

       


          <mx:HBox width="100%" id="topHBox">
              <mx:VBox>
                  <mx:PieChart id="firstChart"
                      dataProvider="{paramCount}"
                      showDataTips="true"
                      selectionMode="single"
                      itemRollOverColor="#FF0066">
                      <mx:series>
                          <mx:PieSeries
                              field="count"
                              nameField="name"
                              labelPosition="callout"
                          />
                      </mx:series>
                  </mx:PieChart>
                  <mx:Legend dataProvider="{firstChart}"/>
              </mx:VBox>
             
              <mx:TextArea     id="statusTextArea"
                              width="100%"        
                              height="100%"               
                              backgroundAlpha="0"
                              focusAlpha="0"
                              selectable="false"/>       
          </mx:HBox>
          <mx:Panel id="p1"/>
      </mx:Application>