【问题标题】:Custom tooltip data for specific points on highcharthighchart 上特定点的自定义工具提示数据
【发布时间】:2015-07-08 11:29:00
【问题描述】:

我想在工具提示中显示警告或解释,仅当您将鼠标悬停在特定的一两个点上时。这些警告将是唯一的,因此不能重复。

我已将自定义文本“警告”和“警告 2”放入系列数据中,但似乎无法在每个包含它的工具提示中调用该数据。

我的系列数据如下所示:

series: [{
        color: '#333',
        name: 'Pre-tax profits',
        data: [{y: 811, custom: 'WARNING'}, 881, 465, -137, 491, 567, 284, 35, 675]

    }, {
        color: '#00adef',
        name: 'Revenues',
        data: [2663, 2300, 1851, 1782, { y: 2103, custom: 'WARNING 2'}, 2154, 1665, 1666, 2149]

    }]

“y”似乎是多余的,但没有它我会出错。

这是我迄今为止在工具提示格式化程序中的调用方式...

formatter: function () {

            var s = '<b>' + this.x + '</b>';

            $.each(this.points, function () {
                s += '<br/>' + this.series.name + ': ' + this.y + 'm';
                s += '<h2>' + this.point.custom + '</h2>';          
            });

            return s;

        },

因为我在每个点中都调用它,所以我对它们中的大多数都没有定义,而实际上我只想在它有此警告时调用它一次,根据工具提示。也许我可以只在工具提示中显示这些警告,制作一个全新的系列?

这是一个演示,看看我在说什么......

http://thetally.efinancialnews.com/tallyassets/barclays-ib/index.html

【问题讨论】:

    标签: javascript jquery highcharts tooltip


    【解决方案1】:

    您需要在 s 构建器中检查 custom 属性是否存在。如果属性存在,则将其附加到工具提示字符串,如果不存在,则不执行任何操作(或其他操作)。

    【讨论】:

      【解决方案2】:

      自定义参数在 point.options 对象中。使用 this.point.options.custom 提取您的价值。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-02-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多