如何在带有次要系列的图表上显示/隐藏数据提示 [英] How do I show/hide datatips on a chart with a secondary series

查看:24
本文介绍了如何在带有次要系列的图表上显示/隐藏数据提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有柱形图的折线图作为辅助系列.当我翻过这条线时,会出现数据提示.但是,如果我将鼠标移动到仍然在线的列出现的位置,则会为该行和该列显示数据提示项.如何获得它以便只显示行的数据提示而不显示列?

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>

推荐答案

子类化 AreaChart 并覆盖 findDataPoints 方法来过滤掉你不想要的数据点:

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;
    }
}

然后使用这个新类而不是 AreaChart.

And then use this new class instead of AreaChart.

这篇关于如何在带有次要系列的图表上显示/隐藏数据提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆