jQuery Flot-显示准确值 [英] jQuery Flot - Display accurate values
本文介绍了jQuery Flot-显示准确值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我注意到jQuery Flot正在舍入结果.但是,当您将鼠标悬停在工具提示中的峰和谷时,我想显示结果的实际十进制值.但不是x或y轴标签,而是图形结果本身.
I notice that jQuery Flot is rounding down the results. But I want to show the actual decimal value for the result when you hover over the peaks and valleys in the tooltip. But not the x or y axis labels, but the graph result itself.
所以我要的不是"44",而是"44.05".
So instead of "44", I want "44.05".
有什么我可以做的工作吗?我看到的所有内容仅用于轴标签.
Is there anything I can do to make that work? Everything I'm seeing is just for the axis labels.
推荐答案
工具提示应允许您执行此操作-看一下这个小提琴 http://jsfiddle.net/Rnusy/
The tool tip should allow you to do this - have a look at this fiddle http://jsfiddle.net/Rnusy/
var previousPoint = null;
$("#placeholder").bind("plothover", function (event, pos, item){
$("#x").text(pos.x.toFixed(2));
$("#y").text(pos.y.toFixed(2));
if (item) {
if (previousPoint != item.dataIndex){
previousPoint = item.dataIndex;
$("#tooltip").remove();
var x = item.datapoint[0].toFixed(2),
y = item.datapoint[1].toFixed(2);
showTooltip(item.pageX, item.pageY, y);
}
}
else {
$("#tooltip").remove();
previousPoint = null;
}
});
这篇关于jQuery Flot-显示准确值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文