简体   繁体   English

Highcharts工具提示始终相同

[英]Highcharts tooltip is always the same

I have a chart which shows the correct chart ( that is the input are correct). 我有一个显示正确图表的图表(即输入正确)。

Whether I use the default tooltip behaviour or I create my own function for the formatting, There's some weird behaviour which I don't get. 不管我使用默认的工具提示行为还是创建自己的格式化函数,我都无法理解某些奇怪的行为。 Wherever I put my mouse on the chart, the values of the tooltip are always the same. 无论我将鼠标放在图表上的哪个位置,工具提示的值始终相同。

The graph is correct, and I'm 100% sure the values are not the same. 该图是正确的,我100%确定值不相同。 Below is the code I use for the settings of the Chart. 以下是我用于图表设置的代码。

function graphUtilPing(utilGws) {
var options = {
    chart : {
        renderTo : 'ping_util',
        type : 'spline',
        width:'900'
    },
    series:[],
    title : {
        text : 'Utilisation'
    },
    xAxis : {
        type:'datetime',
        title : {
            text : 'Time of the day'
        }
    },
    yAxis : {
        title : {
            text : 'Percentage (%)',
        },
    },
    tooltip:{ 
    shared:false,
    formatter : 
        function() {
        var d = new Date(this.x);
        var hrs = d.getHours();
        var minutes = d.getMinutes();
        var seconds = d.getSeconds();
        var ds =  (hrs < 9 ? "0"+hrs : hrs) + ":" + (minutes < 9 ? "0"+minutes : minutes) + ":" + (seconds < 9 ? "0"+seconds : seconds);
            return '<b>' + this.series.name + '</b><br/>'
                + ds + ": " + this.point.y.toFixed(2) + '%';
    }
}
};
for (var key in utilGws) {
    var gw = utilGws[key];
    var gwUtilValues = gw[0];
    var gwMsTimes = gw[2];
    var chartObj = {
        name: key,
        data: array_combine(gwMsTimes, gwUtilValues)
    };
    options.series.push(chartObj);
}

chart = new Highcharts.Chart(options);
return chart; 

} }

I'm using Chrome and the issue is reproducible on IE as well. 我使用的是Chrome,该问题在IE上也可以重现。

Even without changing the tooltip object, the behaviour I get is the same. 即使不更改工具提示对象,我得到的行为也是相同的。

Any ideas what the issue might be? 任何想法可能是什么问题?

UPDATE: Example where the issue is reproducible: http://jsfiddle.net/Htj74/3/ 更新:该问题是可重现的示例: http : //jsfiddle.net/Htj74/3/

The problem is that your data time is reversed. 问题是您的数据时间倒转了。 It comes from 05 Dec 2012 23:45:00 to 05 Dec 2012 00:00:00 . 05 Dec 2012 23:45:0005 Dec 2012 00:00:00 05 Dec 2012 23:45:00 05 Dec 2012 00:00:00 It should be 05 Dec 2012 00:00:00 to 05 Dec 2012 23:45:00 . 应该是05 Dec 2012 00:00:0005 Dec 2012 23:45:00 05 Dec 2012 00:00:00 05 Dec 2012 23:45:00

The problem is arrayCombine . 问题是arrayCombine It should be the following. 应该是以下情况。

function array_combine (a1, a2) {
    var data = [];
    for (var i = 0, length = a1.length; i < length ; i++) {
      data.push([ a1[i], a2[i] ]);
    }
    return data;
}

demo 演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM