Handle PieChart item click event : Pie Chart « Chart « Flex






Handle PieChart item click event

Handle PieChart item click event
          

<?xml version="1.0"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
  <mx:Script>
     import mx.collections.ArrayCollection;
     import mx.charts.events.ChartItemEvent;

     [Bindable]
     public var myArray:ArrayCollection = new ArrayCollection([
        {Country:"A", GDP:1},
        {Country:"B", GDP:6},
        {Country:"C", GDP:4},
        {Country:"D", GDP:2},
        {Country:"E", GDP:3}
     ]);
     [Bindable]
     public var americanGDP:ArrayCollection = new ArrayCollection([
        {Category:"X", GDPContribution:1},
        {Category:"Y", GDPContribution:2},
        {Category:"Z", GDPContribution:2}

     ]);

     private function itemClickHandler(e:ChartItemEvent):void {
         var selectedIndx:int = e.currentTarget.series.selectedIndex;
         trace("selectedIndx: " + selectedIndx);

     }
</mx:Script>
  <mx:Panel title="Pie Chart">
     <mx:PieChart id="myChart"
        dataProvider="{myArray}"
        showDataTips="true"
        itemClick="itemClickHandler(event)"
        selectionMode="single" >
        <mx:series>
           <mx:PieSeries id="ps1" field="GDP" nameField="Country" labelPosition="callout" selectable="true" />
        </mx:series>
     </mx:PieChart>
     <mx:Legend dataProvider="{myChart}"/>
  </mx:Panel>
</mx:Application>

   
    
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.Pie chart with two seriesPie chart with two series
2.Pie Chart DemoPie Chart Demo
3.SeriesSlide effect for Pie chartSeriesSlide effect for Pie chart
4.Create a pie chartCreate a pie chart
5.Set horizonta lAxis and Area Series for Pie ChartSet horizonta lAxis and Area Series for Pie Chart
6.Add a second tag to display two data series for Pie ChartAdd a second <mx:AreaSeries> tag to display two data series for Pie Chart
7.To explode all wedges of a pie chart evenly, you use the explodeRadius property on the PieSeriesTo explode all wedges of a pie chart evenly, you use the explodeRadius property on the PieSeries
8.Pie chart inner radiusPie chart inner radius
9.The following example defines a PieChart control:The following example defines a PieChart control:
10.To create a doughnut chart, specify the innerRadius property on the PieChart controlTo create a doughnut chart, specify the innerRadius property on the PieChart control
11.creates a PieChart that uses only red, white, and blue colors for the wedges:creates a PieChart that uses only red, white, and blue colors for the wedges:
12.Add a drop shadow filter to a PieChart control, Flex renders that drop shadow filter in addition to the default drop shadow filter on the PieSeries.Add a drop shadow filter to a PieChart control, Flex renders that drop shadow filter in addition to the default drop shadow filter on the PieSeries.
13.Create a PieChart control and applies a drop shadow to itCreate a PieChart control and applies a drop shadow to it
14.Set nameField property of a PieChart control's data series to ExpenseSet nameField property of a PieChart control's data series to Expense
15.PieChart with ActionScriptPieChart with ActionScript
16.Set selection model for PieChart to single selectableSet selection model for PieChart to single selectable
17.Describe the properties of the PieChart's PieSeriesDescribe the properties of the PieChart's PieSeries
18.defines an Array of custom SolidColor objects, and applies it to the PieSeries object in the PieChart control.defines an Array of custom SolidColor objects, and applies it to the PieSeries object in the PieChart control.
19.Doughnut PieChart(PieChart with a hole)Doughnut PieChart(PieChart with a hole)
20.Exploding PieChartExploding PieChart
21.creates a PieChart that uses a spectrum of reds for the wedges:creates a PieChart that uses a spectrum of reds for the wedges:
22.Pie custom LabelPie custom Label
23.Pie ExplodePie Explode
24.Pie Multiple SeriesPie Multiple Series
25.Pie Set Fill ColorsPie Set Fill Colors
26.The fourth data point, the Car expense, is explodedThe fourth data point, the Car expense, is exploded
27.Get selected index from ChartItemEventGet selected index from ChartItemEvent
28.Change chart data provider and update data series after clickingChange chart data provider and update data series after clicking
29.Pie Label position calloutPie Label position callout