views:

12

answers:

0

I have multiple LineSeries within a LineChart, sort of like this:

            private var data:ArrayCollection = new ArrayCollection( [
               { Time: 1, Bob: 5, Joe: 5, Sarah: 6 },
               { Time: 2, Bob: 4, Joe: 6, Sarah: 7 } ]);

            public function doItemClick(event:ChartItemEvent):void {
               var hitdata:HitData = event.hitData;
               var lsItem:LineSeriesItem = LineSeriesItem(hitdata.chartItem);
               var nearestPoints:Array = dataChart.findDataPoints(event.currentTarget.mouseX, event.currentTarget.mouseY);
               // hitdata.item maps to a single row in the original array collection, so Time is defined, but the Bob vs. Joe vs. Sarah decision is not.
            }
            ...
            <mx:LineChart id="dataChart" dataProvider="{data}" itemClick="doItemClick(event);">
                <mx:horizontalAxis>
                    <mx:CategoryAxis categoryField="Time"/>
                </mx:horizontalAxis>
                <mx:series>
                    <mx:LineSeries id="bobSeries" yField="Bob" displayName="Bob"/>
                    <mx:LineSeries id="joeSeries" yField="Joe" displayName="Joe"/>
                    <mx:LineSeries id="sarahSeries" yField="Sarah" displayName="Sarah"/>
                </mx:series> 
            </mx:LineChart>

As you can see, there are three different structures I can grab back in the doItemClick() method. But none of them seem to tell me which of the three series was clicked on. The point does tell me which 'Time' row the point came from, through hitdata.item.Time, but not whether the point came from Bob, Joe, or Sarah. All three of those variables are defined under hitdata.item.

How do I figure out which lineseries was clicked on?