HIGHCHARTS: Event on Export can’t access x-axis labels

Thank you for the demo.

Try to use this config – notice that the render event triggers after each chart redraw:

"events": {
  render() {
    let chart = this,
      xAxis = chart.xAxis[0],
      ticks = xAxis.ticks,
      firstTick = ticks[xAxis.tickPositions[0]],
      secondTick = ticks[xAxis.tickPositions[1]],
      ticksDistance = secondTick.mark.getBBox().x - firstTick.mark.getBBox().x;

    for (let i in ticks) {
      let tick = ticks[i];
      if (!tick.isLast) {
        tick.label.translate(ticksDistance / 2, 0)
      }
    }
  }
}

Demo: https://jsfiddle.net/BlackLabel/o06r1yfw/

To hide the last label set the xAxis.showLastLabel property to false.

API: https://api.highcharts.com/highcharts/xAxis.showLastLabel

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top