How do I show/hide datatips on a chart with a secondary series

牧云@^-^@ 提交于 2019-12-11 07:14:41

问题


I have a line chart with a column chart as a secondary series. When I roll over the line, the datatips appear. However, if I move the mouse to a spot where a column appears while still on the line, the data tip item appears for the line AND the column. How do I get it so that I only show datatips for the line but not the column?

<mx:AreaChart id="areachart" dataProvider="{data}" showDataTips="true" >
    <mx:series>

    <mx:AreaSeries id="areaSeries" xField="date" yField="volume" >
    </mx:AreaSeries>


    <mx:ColumnSeries id="secondSeries" xField="date" yField="name" >
    </mx:ColumnSeries>

    </mx:series>

</mx:AreaChart>

回答1:


Subclass AreaChart and override findDataPoints method to filter out the data points you don't want:

public class CustomAreaChart extends AreaChart
{
    public override function findDataPoints(x:Number, y:Number):Array
    {
        var originalDPs : Array = super.findDataPoints(x, y);
        var filteredDPs : Array = [];

        for each (var hd : HitData in originalDPs)
        {
            if (hd.chartItem.element is AreaSeries)
                filteredDPs.push(hd);
        }

        return filteredDPs;
    }
}

And then use this new class instead of AreaChart.




回答2:


Alternatively you can set the interactive property of the column to false:

   <mx:ColumnSeries id="secondSeries" xField="date" yField="name" interactive="false">
   </mx:ColumnSeries>

This will prevent the columns from responding to mouse input.



来源:https://stackoverflow.com/questions/4987547/how-do-i-show-hide-datatips-on-a-chart-with-a-secondary-series

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!