首页 > 解决方案 > 如何在highcharts的工具提示中转换日期格式的时间戳?

问题描述

在这里,我在我的反应项目中使用了行高图,在我的行高图中我显示了工具提示,在这个工具时间里我有一个日期,但是这个日期是时间戳格式,我想在工具提示中以日期格式显示这个时间戳如何在高图中工具提示?

 tooltip: {
    headerFormat: '<b>{series.name}</b>',
    pointFormat: '{point.x}',  // 1554422400
  },

标签: highcharts

解决方案


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


推荐阅读