Use itemDoubleClick event handler to display HitData information
<!--
Code from Flex 4 Documentation "Using Adobe Flex 4".
This user guide is licensed for use under the terms of the Creative Commons Attribution
Non-Commercial 3.0 License.
This License allows users to copy, distribute, and transmit the user guide for noncommercial
purposes only so long as
(1) proper attribution to Adobe is given as the owner of the user guide; and
(2) any reuse or distribution of the user guide contains a notice that use of the user guide is governed by these terms.
The best way to provide notice is to include the following link.
To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/
-->
<!-- charts/HitDataOnClick.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()">
<mx:Script>
import mx.charts.events.ChartItemEvent;
import mx.collections.ArrayCollection;
[Bindable]
public var dataSet:ArrayCollection = new ArrayCollection([
{Month:"Jan", Expenses:1500},
{Month:"Feb", Expenses:200},
{Month:"Mar", Expenses:500}
]);
// Define the event handler.
public function myListener(e:ChartItemEvent):void {
ti1.text = e.hitData.item.Expenses;
ti2.text = e.hitData.x + "/" + e.hitData.y;
}
// Define event listeners when the application initializes.
public function init():void {
chart.addEventListener(ChartItemEvent.ITEM_DOUBLE_CLICK, myListener);
}
</mx:Script>
<mx:Panel title="Accessing HitData Object in Event Handlers">
<mx:ColumnChart id="chart" dataProvider="{dataSet}"
doubleClickEnabled="true">
<mx:horizontalAxis>
<mx:CategoryAxis categoryField="Month" />
</mx:horizontalAxis>
<mx:series>
<mx:ColumnSeries yField="Expenses" />
</mx:series>
</mx:ColumnChart>
<mx:Form>
<!--Define a form to display the event information.-->
<mx:FormItem label="Expenses:">
<mx:TextInput id="ti1" />
</mx:FormItem>
<mx:FormItem label="x/y:">
<mx:TextInput id="ti2" />
</mx:FormItem>
</mx:Form>
</mx:Panel>
</mx:Application>
Related examples in the same category