Highcharts missing date stamp on xAxis

I have a problem with the Highcharts chart. I want to make a chart with the datetime axis every day, but Highcharts shortens the date stamp on the x axis, it should start from today, not tomarrow. However, a tooltip shows the date. Are there any Highcharts settings that I skipped to make it work? I would be grateful for your help. Thank.

the code:

var s = {
        min: 0,
        max: 50,
        totalPoints: 12
    };

function getRandomData() {
    var data  = [],
        date  = new Date().getTime(),
        res   = [],
        numb;

    for (var i = 0; i < s.totalPoints; i += 1) {
        if (i > 0) date += 24 * 3600 * 1000;
        numb = Math.floor(Math.random() * (s.max - s.min + 1) + s.min);
        res.push([date, numb]);
    }


    return res;
}


$(function () {
    var chart = new Highcharts.Chart({

        chart: {
            renderTo: 'container',
        },

        xAxis: {
            type: 'datetime',
            tickInterval: 24 * 3600 * 1000
        },
        series: [{
            data: getRandomData()
        }]

    });
});

Live on: jsfiddle

+4
source share
1 answer

To show the first and last tick, with the points located between your tics for datetime, you can use the xAxis.startOnTickand xAxis.endOnTickto true.

JFiddle .

+3

Source: https://habr.com/ru/post/1547460/


All Articles