highcharts 工具提示错误的日期

highcharts tooltip wrong date

我制作了一张图表,其中工具提示以格式显示日期和时间,但显示的日期和时间错误。

请看下面的代码。

HTML代码

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>

Javascript代码

var maxval="94";
$(function () {
var chart;
$(document).ready(function() {
    chart = new Highcharts.Chart({

    credits: {
        enabled: false
    },  
    chart: {
        type: 'column',
        renderTo: 'container',
    },
    title: {
        text: 'Weekly Traffic'
    },
    xAxis: {
        type: 'datetime',
        labels: {
            format: '{value:%d-%b-%Y}',
            rotation:-45,
        },
    },

    yAxis: {
        labels:{enabled: false},
     title: {
              text: ''
           },
    }, 

          tooltip: {
                formatter: function() {
                        return '<b>'+ this.series.name +'</b><br/>'+': '+Highcharts.dateFormat('%Y-%m-%d %H:%M', this.x) +'<br>'+   Highcharts.numberFormat((this.y /maxval ) * 100) + '%';
                }
            },

    plotOptions: {
        line: {
         enableMouseTracking: false
        },

        series:{
         pointStart: 1444242600000,
        pointInterval: 86400000,
             shadow:false,
         dataLabels:{
            enabled:true,
            formatter:function()
                {
                var pcnt = (this.y /maxval ) * 100;
                return Highcharts.numberFormat(pcnt) + '%';
                }
            }
        }    
},

    series: [{
        name: 'Firefox',
        data: [10,56,32,12,64,13,38],
    },{
        name: 'Chrome',
        data: [52,59,10,60,94,3,8],
    },{
        name: 'Edge',
        data: [22,56,20,35,14,73,38],
    },{
        name: 'Opera',
        data: [30,36,80,65,44,53,81],
    },{
        name: 'Safari',
        data: [40,16,50,77,34,33,36],

    }],

    });

});

});

给出工作 fiddle here.

您需要在highcharts的全局选项中设置utc false。

 Highcharts.setOptions({
global: {
    useUTC: false
}
});

Updated fiddle here