小编Vla*_*lad的帖子

使用Flot jQuery插件显示具有正确时区的工具提示

我在Flot插件中遇到一些问题,同时在图表中显示xaxis标签.他们是'mode: "time"'.目前我使用Flot工具提示功能,工具提示包含日期和时间.我向包含时间戳的插件提供JSON.然后我转换时间戳,然后在工具提示中显示它.问题是,在图表中显示数据时,由于时区之间的差异,工具提示的时间与插件生成的xaxis标签不对应.我的JSON时间戳是+2 GMT,但Flot中的xaxis标签是+0 GMT.所以我想知道是否有可能设置时区或类似的偏移量.

我的JSON(由AJAX生成)

 [1300087800000,29],
 [1300088700000,39],
 [1300089600000,46],
 [1300090500000,53],
 [1300091400000,68],
 [1300092300000,95],
 ...
Run Code Online (Sandbox Code Playgroud)

我的工具提示功能

$(placeholder).bind("plothover", function (event, pos, item) {
     $("#tooltip").remove();

     var x = item.datapoint[0].toFixed(2);
     var y = item.datapoint[1].toFixed(2);

     var currDate   = new Date(Math.floor(x));
     var hour       = currDate.getHours();
     var minute     = String("") + currDate.getMinutes();

     var tooltip = hour + ":" +
                   ((minute.length < 2) ? "0" + minute : minute) + " " +
                   (Math.round(y * 100)/100) + "Wh"
     showTooltip(item.pageX, item.pageY, tooltip);
 });  
Run Code Online (Sandbox Code Playgroud)

Flot选项

 var plotOptions = { …
Run Code Online (Sandbox Code Playgroud)

jquery timezone plot flot

15
推荐指数
2
解决办法
2万
查看次数

标签 统计

flot ×1

jquery ×1

plot ×1

timezone ×1