Highcharts中的格式化工具提示

问题描述 投票:0回答:1

如何确保在工具提示中,仅在沿轴的值之后显示“(name)”?在字符串“系列1:..(名称)”之后,还会显示当前代码“(名称)”。

Highcharts.chart('container', {
tooltip: {
    formatter: function () {
        return this.points.reduce(function (s, point) {
            return s + '(name)' + '<br/>' + point.series.name + ': ' +
                point.y + 'm';
        }, '<b>' + this.x + '</b>');
    },
    shared: true
}
});

示例:https://jsfiddle.net/nsdtf7ah/

打印屏幕:http://joxi.ru/Dr8501zTowVWGm

javascript highcharts
1个回答
0
投票

如果仅在(name)名称后需要Month,则将tooltip替换为:

    tooltip: {
        formatter: function () {
            return this.points.reduce(function (s, point) {
                return s + '<br/>' + point.series.name + ': ' + point.y + 'm';
            }, '<b>' + this.x  + '(name)'+ '</b>');
        },
        shared: true
    },

https://jsfiddle.net/m4q2sh7t/

如果您在(name)之后需要两个String N,则:

    tooltip: {
        formatter: function () {
            return this.points.reduce(function (s, point) {
                return s + '<br/>' + point.series.name + ': ' + point.y + 'm'  + '(name)';
            }, '<b>' + this.x+ '</b>');
        },
        shared: true
    },

https://jsfiddle.net/m4q2sh7t/1/

© www.soinside.com 2019 - 2024. All rights reserved.