在荧光笔jqplot中显示pointlabel [英] display pointlabel in highlighter jqplot

查看:115
本文介绍了在荧光笔jqplot中显示pointlabel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



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



我试图给每个系列添加一个荧光笔对象,并给它一个格式字符串。但我怎样才能使这更动态?



我也只喜欢在右下角的hoverbox-thingy中显示时间。我怎样才能删除,1和,2?

解决方案

使用荧光笔和光标的工具提示的自定义处理。 在这里介绍



在你的情况下,你会应用以下代码:

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

工作代码示例可在这里找到。






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


I've many series of just two points on a graph to simulate a timeline. These points have a pointlabel. I'd like to have the name of that pointlabel in the highlighter. How do I do that?

please see my JsFiddle http://jsfiddle.net/NVbjv/8/

I'd tried to add a highlighter object to each series, and give it a format string. But how can I make this more dynamic?

I also like to only display time in the hoverbox-thingy in the bottom right. How do I get remove the ",1 " and ",2"?

解决方案

The only idea that comes to my mind is to use a custom processing of the tooltip of highlighter and cursor. Something along the lines as it is presented here.

In your case you would apply the following code:

$("#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.


EDIT: In Chrome I have noticed that the null is printed for the pointLabels therefore use empty strings for their values instead.

这篇关于在荧光笔jqplot中显示pointlabel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆