score:2

You can find the min and max of the axis through the formatter like this:

xAxis: {
    type: 'datetime',
    labels: {
        formatter: function() {
            console.log(this.axis.min);
            console.log(this.axis.max);
            return this.value; // Default. Return something relevant instead
        },
    }
}

See the API (or console.log) for all values of this in the formatter. The axis might here be the y-axis as well. You can always access the x-axis through this.chart.xAxis[0] if necessary.

Note however that unless you want to be very specific with your formatting you might want to consider customizing dateTimeLabelFormats (API).


Related Articles