highcharts x-axis显示错误的数据

时间:2014-11-12 23:19:29

标签: javascript highcharts

我的highcharts代码如下:几乎总是从01开始,它显示1月和2月

我确实查找了高级文档文档,我无法弄清楚如何让这个东西每天都需要+1。意思是如果它从第5开始,它将显示5 6 7 8 9 基于串联值的数量。 该图表显示每天的总浏览量。无论如何,你指出我正确的方向?

    $('#arpv').highcharts({exporting: { enabled: false } ,
        xAxis: {
              type: 'datetime',     
dateTimeLabelFormats: {
            day: '%d. '

        },pointInterval: 24 * 3600 * 1000 

        },
        yAxis: {
            floor: 0,
            title: {
                text: 'Pageviews'
            },
            plotLines: [{
                value: 0,
                width: 1,
                color: '#808080'
            }]
        },
        title: {
            text: 'Pagesviews Summary',
            x: -20 //center
        },
        subtitle: {
        //    text: 'pageviews over time',
            x: -20
        },

        tooltip: {
            valueSuffix: ' Pageviews',
                crosshairs: true,
                 formatter: function() {
        var date = new Date(this.x);
        var year = date.getFullYear();


        return '<span style="color:'+this.series.color+'">'+ this.series.name +'</span>: '+ this.y + ' pageviews';
     },
        },
        legend: {
            layout: 'vertical',
            align: 'right',
            verticalAlign: 'middle',
            borderWidth: 0
        },
                 series: [  { name: 'Pageviews', data: [ 26562,5793,26585,2203,1444,2150,2833,2416,10114,13564,16234,15253,5415,10340,18184,12830,14340,21520,18883,41571,23913,16013,16681,10499,18557,18692,14550,6655,17490,46258,26671,5739,26585,49114,30038,25998,19076,26577,10231,24110 ],pointInterval: 24 * 3600 * 1000 } ]


    });

 </script>

2 个答案:

答案 0 :(得分:1)

在xAxis配置中,您使用的是pointInterval,它应该是tickInterval

xAxis: {
    type: 'datetime',     
    dateTimeLabelFormats: {
        day: '%d. '

    },
    tickInterval: 24 * 3600 * 1000 
}

示例fiddle

答案 1 :(得分:1)

pointInterval参数应放在plotOptions.series中,而不是放在xAxis上。