7

我不确定发生了什么,但日期显示在轴上,并在一个月后的工具提示中显示。因此,此图表上数据的第一个日期是 7 月,但它显示为 8 月,依此类推。有任何想法吗?我已将代码放入 JSFiddle ( http://jsfiddle.net/Z2VGL/1/ ) 以及以下:

$(function () {
$('#container').highcharts({
    chart: {
        type: 'spline'
    },
    title: {
        text: ''
    },
    plotOptions: {
        series: {
            lineWidth: 5,
            marker: {
                fillColor: '#FFFFFF',
                lineWidth: 2,
                radius: 6,
                lineColor: null // inherit from series
            }
        }
    },
    subtitle: {
        text: ''
    },
    xAxis: {
        type: 'datetime',
        dateTimeLabelFormats: { // don't display the dummy year
            month: '%e %b',
            year: '%b'
        }
    },
    yAxis: {
        title: {
            text: 'Ability Score (out of 100)',
            style: {
                color: '#323A45',
                fontWeight: 'bold'
            }
        },
        min: 0
    },
    tooltip: {
        formatter: function () {
            return '<b>' + this.series.name + '</b><br/>' + Highcharts.dateFormat('%e %b', this.x) + ': ' + this.y;
        }
    },

    series: [{
        name: 'Overall Ability',
        // Define the data points. All series have a dummy year
        // of 1970/71 in order to be compared on the same x axis. Note
        // that in JavaScript, months start at 0 for January, 1 for February etc.
        data: [
            [Date.UTC(2013, 07, 12), 50],
            [Date.UTC(2013, 08, 13), 57.9474605576],
            [Date.UTC(2013, 08, 14), 58.5667571154],
            [Date.UTC(2013, 08, 15), 69.0590308869], ]

    }, {
        name: 'Target',
        data: [
            [Date.UTC(2013, 07, 12), 80],
            [Date.UTC(2013, 08, 13), 80],
            [Date.UTC(2013, 08, 14), 80],
            [Date.UTC(2013, 08, 15), 80],
            /*
                    [Date.UTC(2013,  0,  1), 80.0],
                    [Date.UTC(2013,  1,  1), 80.0],
                    [Date.UTC(2013,  2,  1), 80.0],
                    [Date.UTC(2013,  3,  1), 80.0],
                    [Date.UTC(2013,  4,  1), 80.0],
                    [Date.UTC(2013,  5,  1), 80.0],
                    [Date.UTC(2013,  6,  1), 80.0],
                    [Date.UTC(2013,  7,  1), 80.0]
                    */

], dashStyle: 'longdash', 标记: { 启用: false } }]

});

});

提前致谢。

4

1 回答 1

12

从这个文档中可以看到:Mozilla JS Reference Date UTC

month
An integer between 0 and 11 representing the month.
于 2013-08-15T17:00:04.137 回答