我有一个如下图所示的图表。默认情况下,每个工具提示值都位于其自己的工具提示“气泡”中,日期时间位于 Y 轴底部(悬停在 X 标签顶部)。
问题在于,更改日期时间的格式以匹配区域设置对于 Highcharts 来说不是动态的。我知道我可以让用户更改dateTimeLabelFormats
以匹配他们的语言环境,但我希望利用 moment.js 及其内置的语言环境格式。
我只需要更改这些图表中的日期时间,无需更改其他内容。
当我尝试下面的代码时,它为我提供了我正在寻找的区域设置杠杆,但工具提示被合并到 1 个框中,并且没有与默认相同的感觉。
tooltip: {
enabled: true,
dateTimeLabelFormats: {
//minute: '%e %b %H:%M',
hour: '%e %b %H:%M'
},
// For locale control with moment. Combined momentjs with this answer https://stackoverflow.com/a/33939715/1177153
formatter: function() {
var toolTipTxt = '<b>'+ moment.unix(this.x / 1000).format("LLL") +'</b>';
$.each(this.points, function(i, point) {
toolTipTxt += '<br/><span style="color:'+ point.series.color +'"> ' + point.series.name + ': ' + point.y+'</span>';
});
return toolTipTxt;
},
crosshairs: true,
shared: true
},
有没有办法用格式化程序模拟默认工具提示?值和时间戳的单独“气泡”悬停在底部?
是否可以使用xDateFormat
以某种方式使用 moment.js ?