1 Reply Latest reply on Jun 1, 2009 10:53 AM by _Natasha_

    Using the Legend Component with PieChart

    rcanulla Level 1

      Hi there,

       

      I'm using the pieChart Component to display items that people deem "positive/negative..". I have an ArrayCollection providing the data to the Chart, and am using the chart to provide data to the legend.

       

      The Array Collection/Vars = Chart.dataProvider

       

               private var positive:int = 0;
               private var neutral:int = 0;
               private var negative:int = 0;
               private var notRated:int = 1;
      
               var ratingAC:ArrayCollection = new ArrayCollection([
                    { Rating: notRated, Title: "Not Rated" },  // [0] no data
                    { Rating: positive, Title: "Positive" }, // [1] positive rating total
                    { Rating: negative, Title: "Negative" }, // [2] neutral rating total
                    { Rating: neutral, Title: "Neutral" }  // [3] negative rating total
                    ]);
      

       

      Legend/Chart

       

               <mx:Label id="archiveTitle" x="10" y="10" text="Today's Clips" fontSize="14" fontWeight="bold"/>
               <mx:PieChart id="chart" height="159" width="240" color="0x323232"
                  showDataTips="true" y="22" x="60">
                   <mx:series>
                        <mx:PieSeries field="Rating">
                           
                           <mx:showDataEffect>
                               <mx:SeriesInterpolate duration="1500"
                                     />
                           </mx:showDataEffect>
                           <mx:filters>
                               <mx:DropShadowFilter />
                           </mx:filters>
                       </mx:PieSeries>
                  </mx:series>
                  
                 
              </mx:PieChart>
               <mx:Legend id="legend" dataProvider="{chart}"  direction="vertical"   x="5" y="41" height="140"/>
      

       

      The problem is that the Legend Labels show up (blocks of color), but I do not get a label name, or the total amount assigned to the labels. Any help is much appreciated!

        • 1. Re: Using the Legend Component with PieChart
          _Natasha_ Level 4

          Hi,

          legend get labels from displayName property of series.

           

          So if you add property it will be shown in Legend.

           

          <mx:PieChart id="chart" height="159" width="240" color="0x323232"
                      showDataTips="true" y="22" x="60">
                       <mx:series>
                            <mx:PieSeries field="Rating" displayName="My LABEL">
                               
                               <mx:showDataEffect>
                                   <mx:SeriesInterpolate duration="1500"
                                         />
                               </mx:showDataEffect>
                               <mx:filters>
                                   <mx:DropShadowFilter />
                               </mx:filters>
                           </mx:PieSeries>
                      </mx:series>
                      
                     
                  </mx:PieChart>

           

          Hope this helpful.