我注意到 jQuery Flot 对结果进行四舍五入。但当您将鼠标悬停在工具提示中的峰值和谷值上时,我想显示结果的实际小数值。但不是 x 或 y 轴标签,而是图形结果本身。
所以我想要的不是“44”,而是“44.05”。
我能做些什么来实现这一点吗?我看到的所有内容都只是针对轴标签。
最佳答案
工具提示应该允许您执行此操作 - 看看这个 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 - 显示准确的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15961948/