简体   繁体   中英

Tick and label alignment for Highcharts datetime

I have a chart with multiple samples but all at the same time. How do I get Highcharts to put a tick and corresponding label on each value? I've tried explicitly setting the tickPoints with the datetimes but it doesn't work.

Invalid tick alignment example

Worked this out. Essentially, I implemented a custom tickPositioner function that puts ticks (if enabled) and their respective labels on each value.

xAxis: {
  tickPositioner: function() {
    var ticks = [1496275200000, 1496880000000, 1497484800000, 1499299200000];
    // this line makes highcharts aware the values are dates
    ticks.info = this.tickPositions.info;
    return ticks;
  }
}

You would of course make the tick array values match your data..

An example here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM