Chart single 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.ChartEvent;
import mx.controls.Alert;
[Bindable]
public var myArray:ArrayCollection = new ArrayCollection([
{Country:"A", GDP:11},
{Country:"B", GDP:22},
{Country:"C", GDP:33},
{Country:"D", GDP:44}
]);
[Bindable]
public var myArray2:ArrayCollection = new ArrayCollection([
{Country:"A", GDP:33},
{Country:"B", GDP:22},
{Country:"C", GDP:11},
{Country:"D", GDP:44}
]);
private function chartEventHandler(event:ChartEvent):void {
Alert.show("Event of type: " +event.type,"ChartEvent",Alert.OK);
}
</mx:Script>
<mx:Panel title="Column Chart">
<mx:ColumnChart id="myChart" dataProvider="{myArray}" showDataTips="true"
chartClick="chartEventHandler(event)">
<mx:horizontalAxis>
<mx:CategoryAxis categoryField="Country"/>
</mx:horizontalAxis>
<mx:series>
<mx:ColumnSeries dataProvider="{myArray}" yField="GDP" xField="Country" displayName="Array" />
<mx:ColumnSeries dataProvider="{myArray2}" yField="GDP" xField="Country" displayName="Array2" />
</mx:series>
</mx:ColumnChart>
<mx:Legend dataProvider="{myChart}"/>
</mx:Panel>
</mx:Application>
Related examples in the same category