gpt4 book ai didi

javascript - Highcharts 中的格式化工具提示

转载 作者:行者123 更新时间:2023-11-30 19:10:39 25 4
gpt4 key购买 nike

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

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

最佳答案

如果您仅在 Month name 之后需要 (name),则将 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/

如果在 String N 之后需要 2 个 (name),那么:

    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/

关于javascript - Highcharts 中的格式化工具提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58521194/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com