6
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 不起作用,任何帮助

4

1 回答 1

9

它不起作用,因为您正在为一天间隔设置标签格式,而使用的是周格式,请参见固定示例: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
    }]
});
于 2013-09-12T15:16:11.270 回答