highcharts时间戳记转换为可读的日期时间

时间:2019-03-20 17:51:58

标签: highcharts

我具有所附的highchart,时间戳显示为从DB收到。我需要某种方式将其转换为人类可读但没有成功的方法。 highchart

      xAxis: {
    type: 'datetime',
    categories: labels,
    formatter: function () {
      return "mydate: " + moment.utc(moment.unix(this.x/1000)).format("DD/MM-YYYY HH:mm:ss") + "<br> myspeed: " + this.y;
    }
  }

1 个答案:

答案 0 :(得分:0)

labels选项必须嵌套在xAxis中,而不是嵌套在xAxis: { type: 'datetime', categories: labels, labels: { formatter: function () { return "mydate: " + moment.utc(moment.unix(this.x/1000)).format("DD/MM-YYYY HH:mm:ss") + "<br> myspeed: " + this.y; } } } 中:https://api.highcharts.com/highcharts/xAxis.labels.formatter

{{1}}