var chart = new Highcharts.Chart({
chart: {
    renderTo: container
},

plotOptions: {
    series: {
        pointStart: Date.UTC(2010, 0, 1),
        pointInterval: 24 * 3600 * 1000 * 1 // one day
    }
},
xAxis: {
            type: 'datetime',
            dateTimeLabelFormats: { // don't display the dummy year
                 day: '%b %e',
            },
        },
series: [{
    data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}, {
    data: [144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4, 29.9, 71.5, 106.4, 129.2]
}]

代码上端工作正常,但是当我将pointInterval更改为24 * 3600 * 1000 * 7(1周)时,highchart dateTimeLabelFormat不起作用,有任何帮助

最佳答案

它不起作用,因为您将标签格式设置为一天间隔,而使用的是周格式,请参见固定示例:http://jsfiddle.net/F2uMR/1/

$('#container').highcharts({
    xAxis: {
        type: 'datetime',
        dateTimeLabelFormats: {
            day: '%b %e',
            week: '%b %e'
        }
    },

    series: [{
        data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4],
        pointStart: Date.UTC(2010, 0, 1),
        pointInterval: 24 * 3600 * 1000 * 7// one week
    }]
});

关于javascript - highchart dateTimeLabelFormats不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18767736/

10-11 05:26