gpt4 book ai didi

javascript - 在荧光笔jqplot中显示点标签

转载 作者:行者123 更新时间:2023-11-30 05:56:18 24 4
gpt4 key购买 nike

我在图表上有很多只有两个点的系列来模拟时间线。这些点有一个点标签。我想在荧光笔中显示该点标签的名称。我该怎么做?

请看我的 JsFiddle http://jsfiddle.net/NVbjv/8/

我曾尝试为每个系列添加一个荧光笔对象,并为其提供一个格式字符串。但是我怎样才能让它更有活力呢?

我还喜欢只在右下角的悬浮框里显示时间。如何删除“,1”和“,2”?

最佳答案

我想到的唯一想法是使用自定义处理荧光笔和光标的工具提示。沿线的东西 as it is presented here.

在您的情况下,您将应用以下代码:

$("#container").bind('jqplotMouseMove', function(ev, gridpos, datapos, neighbor, plot) {
var date = new Date(datapos.xaxis);
var time = "" + (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":" + (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes());
$(".jqplot-cursor-tooltip").html(time + " Oi");
if (neighbor) {
$(".jqplot-highlighter-tooltip").html("Label name= " + neighbor.data[2] + "; time= " + time);
}
});

The working code sample is available here.


编辑:在 Chrome 中,我注意到为 pointLabels 打印了空值,因此使用空字符串代替它们的值。

关于javascript - 在荧光笔jqplot中显示点标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11684919/

24 4 0