Use Event object to get a reference to the clicked ColumnSeries.
<!--
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/SimpleDrillDown.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" height="100%"
width="100%" creationComplete="initApp()">
<mx:Script>
import mx.collections.ArrayCollection;
[Bindable]
public var dpac:ArrayCollection = new ArrayCollection ([
{ date:"01/01/2006", cash:50000,stocks:198192, retirement:130101,home:750000, other:19148 },
{ date:"02/01/2006", cash:50000,stocks:210309, retirement:143707,home:760000, other:19493 },
{ date:"03/01/2006", cash:50000,stocks:238992, retirement:169529,home:770000, other:19933 },
{ date:"04/01/2006", cash:50000,stocks:292269, retirement:242596,home:770000, other:21445 }]);
public var initSeriesArray:Array = new Array();
public var level:Number = 1;
public var newSeries:Array;
private function initApp():void {
// Get initial series Array -- to be reloaded when it returns
// from a drill down.
initSeriesArray = chart.series;
}
private function zoomIntoSeries(e:Event):void {
newSeries = new Array();
if (level == 1) {
newSeries.push(e.currentTarget);
level = 2;
} else {
newSeries = initSeriesArray;
p1.title = "Net Worth";
level = 1;
}
chart.series = newSeries;
}
</mx:Script>
<mx:Panel id="p1" title="Net Worth">
<mx:ColumnChart id="chart" dataProvider="{dpac}" type="stacked"
showDataTips="true">
<mx:series>
<mx:ColumnSeries id="s1" displayName="Cash" yField="cash"
xField="date" click="zoomIntoSeries(event)" />
<mx:ColumnSeries id="s2" displayName="Stocks" yField="stocks"
xField="date" click="zoomIntoSeries(event)" />
<mx:ColumnSeries id="s3" displayName="Retirement"
yField="retirement" xField="date"
click="zoomIntoSeries(event)" />
<mx:ColumnSeries id="s4" displayName="Home" yField="home"
xField="date" click="zoomIntoSeries(event)" />
<mx:ColumnSeries id="s5" displayName="Other" yField="other"
xField="date" click="zoomIntoSeries(event)" />
</mx:series>
<mx:horizontalAxis>
<mx:DateTimeAxis title="Date" dataUnits="months" />
</mx:horizontalAxis>
</mx:ColumnChart>
<mx:Legend dataProvider="{chart}" />
</mx:Panel>
</mx:Application>
Related examples in the same category