0 Replies Latest reply on Jun 10, 2011 2:26 PM by AhmedCogenli

    How to get PieSeriesItem labelText for fill color

    AhmedCogenli

      I've a PieChart, data comes from XML, I'd like to fill the pies with a specific color based on the labelField data of PieSeriesItem. For example if data's labelfield is A, fill color must be 0xFFFFFF... I know I need to use fillFunction but I wasn't able to get labelField property of PieSeriesItem. Here is a sample code;

       

                      var curItem:PieSeriesItem = PieSeriesItem(item);
                      return new SolidColor(0x0000FF * pct, 1.0);
      
                      if (curItem.labelField == "A") {
                          return new SolidColor(0xfecd1d, 1.0); 
                      }
                          
                      else if (curItem.labelField == "B") {
                          return new SolidColor(0xfe2f31, 1.0); 
                      }
      
                      else if (curItem.labelField == "C") {
                          return new SolidColor(0x127ee1, 1.0); 
                      }
                  
                      else {
                          return new SolidColor(0xc2c2c2, 1.0);                     
                      }            
                  }
      

       

       

          <mx:PieChart horizontalCenter="0" width="625" height="625" showDataTips="true" 
      dataProvider="{mainResult.lastResult.record}" 
      id="myChart" y="250" fontFamily="Verdana" fontSize="20">
              <mx:series>
                  <mx:PieSeries id="labelseries" labelField="label" labelPosition="outside" 
      width="100%" height="100%" field="totalnumber" 
                                nameField="labelseries" fillFunction="pieSeries_fillFunc">
                      <mx:filters/>
                  </mx:PieSeries>
              </mx:series>
          </mx:PieChart>
      
      

       

      Any idea?

       

      Thanks in advance