PDA

View Full Version : Which area of areachart has been clicked?


snowbunny
09-30-2008, 12:57 PM
Hi...
I have a stacked areachart and need it to be clickable, with the information from the clicked series available to the listener.
This is straightforward using itemClick with ChartItemEvent, but I don't just want the item to be clickable; I need the entire coloured area to work.
I've inspected the properties of ChartEvent (used with chartClick), but can't see anything that would help determine the series clicked on.

Any help would be appreciated.

Thanks!

monkey4Hire
09-30-2008, 02:16 PM
define your chart as the following.



<mx:AreaChart x="100" y="50" id="areachart1" type="stacked" dataProvider="{expenses}">
<mx:series>
<mx:AreaSeries displayName="Series Profit" yField="Profit" click="onProfitClick(event)" />
<mx:AreaSeries displayName="Series Expenses" yField="Expenses" click="onExpensesClick(event)"/>
</mx:series>
</mx:AreaChart>



add the following event handlers.



private function onProfitClick(event:MouseEvent):void
{
// Do something
}

private function onExpensesClick(event:MouseEvent):void
{
// Do something
}

snowbunny
09-30-2008, 03:38 PM
define your chart as the following.



<mx:AreaChart x="100" y="50" id="areachart1" type="stacked" dataProvider="{expenses}">
<mx:series>
<mx:AreaSeries displayName="Series Profit" yField="Profit" click="onProfitClick(event)" />
<mx:AreaSeries displayName="Series Expenses" yField="Expenses" click="onExpensesClick(event)"/>
</mx:series>
</mx:AreaChart>



add the following event handlers.



private function onProfitClick(event:MouseEvent):void
{
// Do something
}

private function onExpensesClick(event:MouseEvent):void
{
// Do something
}



You're a star! So simple, thanks!