highcharts x轴的日期问题

问题描述 投票:0回答:1

我试图显示在x轴上的日期。所有时间都呈现休息一天。这是我的日期,以在x轴示出2017年4月23日,二零一七年四月三十零日,2017年5月7日,5个/ 14 / 2017,05 / 21 / 2017,06 / 04/2017。什么它的显示是thisenter image description here。这其中不存在或接近(2017年5月29日),这是与其他重叠显示日期。这是我的codexAxis: { tickAmount: 5, type: 'datetime', dateTimeLabelFormats: { day: '%m/%d/%Y', week: '%m/%d/%Y', month: '%m/%d/%Y', }, labels: { style: { fontFamily : "Open Sans" }, } }, time: {useUTC: false },

highcharts ionic3
1个回答
0
投票

这是因为你已经time.useUTC = true(默认选项)。将其更改为false,并预期它应该工作。

码:

var data = [
  ['4 / 23 / 2017', 1], // [date, value]
  ['4 / 30 / 2017', 2],
  ['5 / 7 / 2017', 4],
  ['5 / 14 / 2017', 2],
  ['05 / 21 / 2017', 3],
  ['06 / 04 / 2017', 5]
];

Highcharts.chart('container', {

  xAxis: {
    tickAmount: 5,
    type: 'datetime',
    dateTimeLabelFormats: {
      day: '%m/%d/%Y',
      week: '%m/%d/%Y',
      month: '%m/%d/%Y',
    },
    labels: {
      style: {
        fontFamily: "Open Sans"
      },
    }
  },
  time: {
    useUTC: false
  },

  series: [{
    data: data.map(elem => {
        elem[0] = new Date(elem[0]).getTime();
      return elem;
    })
  }]
});

API:

演示:

© www.soinside.com 2019 - 2024. All rights reserved.