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

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

问题描述

我有一个带有柱状图的折线图作为辅助系列。当我翻车时,数据提示出现。但是,如果我将鼠标移动到某一列出现的位置,但仍然在行上,数据提示项将显示在行和列中。

 < mx:AreaChart id = areachartdataProvider ={data}showDataTips =true> 
< mx:series>

< mx:AreaSeries id =areaSeriesxField =dateyField =volume>
< / mx:AreaSeries>


< mx:ColumnSeries id =secondSeriesxField =dateyField =name>
< / mx:ColumnSeries>

< / mx:series>

< / mx:AreaChart>


解决方案

子类AreaChart并重写findDataPoints方法来过滤掉数据你不想要的点:$ b​​
$ b $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $' x:Number,y:Number):Array
{
var originalDPs:Array = super.findDataPoints(x,y);
var filteredDPs:Array = [];

(var HD:原始DP中的HitData)
{
if(hd.chartItem.element是AreaSeries)
filteredDPs.push(hd);
}

返回filteredDPs;




$ b $然后用这个新类代替AreaChart。

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>

解决方案

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.

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

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