如何在Highcharts中修复xAxis(datetime)比例?

时间:2014-04-10 08:36:20

标签: javascript highcharts

xAxis标签在宽或缩放时滑动; date_format使用'month','week',也许还有其他人。 我只想要日期时间比例月。我该怎么做?我不喜欢'Feb,Feb,...'

$(function () {
    var data = [];
    var y = 1000;
    for (var year = 2014; year <= 2014; year++) {
        for (var month = 0; month <= 5; month++) {
            var day = Math.floor(Math.random() * 30);
            y += Math.floor(Math.random() * 5);
            data.push([Date.UTC(year, month, day), y]);
        }
    }
    var dtlf = {
        week: '%b(w)',
        day: '%b(d)',
        month: '%b(m)',
        year: '%b(y)'
    };
    $('#container').highcharts({
        chart: {zoomType: 'x', type: 'line', width: 800},
        xAxis: {type: 'datetime', gridLineWidth: 1, startOnTick: true, dateTimeLabelFormats: dtlf},
        series: [{name: 'series', type: 'line', data: data}]
    });
});

1 个答案:

答案 0 :(得分:1)

您需要设置tickInterval: 30 * 24 * 3600 * 1000 - 然后每个月都会显示勾号。