highcharts - 如何在highcharts的工具提示中转换日期格式的时间戳?
问题描述
在这里,我在我的反应项目中使用了行高图,在我的行高图中我显示了工具提示,在这个工具时间里我有一个日期,但是这个日期是时间戳格式,我想在工具提示中以日期格式显示这个时间戳如何在高图中工具提示?
tooltip: {
headerFormat: '<b>{series.name}</b>',
pointFormat: '{point.x}', // 1554422400
},
解决方案
在pointFormatter
函数中,您可以使用 HighchartsdateFormat
方法:
tooltip: {
...,
pointFormatter: function() {
return Highcharts.dateFormat('%a %d %b %H:%M:%S', this.x)
}
}
现场演示:http: //jsfiddle.net/BlackLabel/oLt62kbu/
API参考:
https://api.highcharts.com/class-reference/Highcharts#.dateFormat
https://api.highcharts.com/highcharts/tooltip.pointFormatter
推荐阅读
- javascript - 用户脚本 Javascript 来更改动态创建的 iframe 中的元素值
- python - 为什么我的 sparse_categorical_crossentropy 和 categorical_crossentropy 有 2 种不同的损失?
- python - Python:检测和参数化图像矩阵中的简单矩形/高斯条纹图案
- javascript - Vue Js - 单击输入字段时如何获取详细页面视图
- openapi - Open API 3.0 如何添加 API 正文元素?
- reactjs - 有没有办法检查 propTypes 的观察者(组件)
- pdf - Pandoc Markdown to Latex PDF:具有交替行颜色的表格?
- ethereum - 如何使用 web3j 解码 ABI 的“string []”返回类型的 outputParameters
- excel - 如何在 VBA 中设置 PhantomJS 的 ViewPort 大小?
- flutter - 无法在 Windows 中的任何位置创建 Flutter 项目