【问题标题】:Highcharts: Dates Off By 1 MonthHighcharts:日期关闭 1 个月
【发布时间】:2013-08-15 16:53:03
【问题描述】:

我不确定发生了什么,但日期会显示在轴上,并且一个月后会显示在工具提示中。因此,此图表上数据的第一个日期是 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', 标记:{ 启用:假 } }]

});

});

提前致谢。

【问题讨论】:

    标签: highcharts


    【解决方案1】:

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

    month
    An integer between 0 and 11 representing the month.
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-05-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-05
      • 1970-01-01
      相关资源
      最近更新 更多