View Full Version : Getting the selected item in a stacked column chart

12-14-2010, 09:12 AM
I'm trying to get the item associated with a segment that has been clicked in a stacked column chart.

<mx:CartesianChart id="chart"
selectionMode="single" itemClick="chart_itemClickHandler(event)">

protected function chart_itemClickHandler(event:ChartItemEvent):void
// TODO Auto-generated method stub

I would normally, within the handler, use hitData.item to get the information I need here, but it holds the data for the entire column, without specifying which field has been clicked.

So, how do I go about finding the data that has actually been clicked on?


the dataProvider could be

new ArrayCollection([ {month: "Jan", tax: 20, income: 100, food: 10},

{month: "Feb", tax: 15, income: 100, food: 15}]};

This would create a stacked column chart with two bars, each with three segments (one each for tax, income and food).

When I click on the 'tax' segment in the first bar, hitData.item is the whole object {month: "Jan", tax: 20, income: 100, food: 10}, but I need to capture that it was 'tax' I actually clicked on.

Any advice would be welcomed.