Flot 共享工具提示

发布于 2024-12-01 04:08:03 字数 112 浏览 1 评论 0原文

使用 Flot 动态绘制多个系列的图表。使用 Tootips 在悬停时提供标签。如果多个系列在网格上具有相同的点,则工具提示仅显示 1 个系列的标签。希望工具提示显示共享标签,每个系列在显示其标签的点上。谢谢!

Using Flot to dynamically graph multiple series. Using Toottips to provide labels on hover. Where multiple series have the same points on the grid, Tooltips displays label from only 1 series. Would like to have Tooltips display shared labels with each series on the point showing its label. Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光是把杀猪刀 2024-12-08 04:08:03

我不相信这种能力是轻易存在的。我会预先筛选我的数据并记下任何重叠的数据点。当然,这种方法的可行性取决于数据集的大小:

var data1 = [[0,3],[1,1],[2,2],[4,8],[5,10]];
var data2 = [[0,2],[1,2],[2,2],[4,6],[6,13]];

overLap = {}

for (var i = 0; i < data1.length; ++i)
{
    for (var j = 0; j < data2.length; ++j)
    {
        if ((data1[i][0] == data2[j][0]) && (data1[i][1] == data2[j][1]))
            overLap[data1[i]] = "label1 and label2";
    }
}

然后在绘图上只需检查您的 overLap 关联数组:

$("#placeholder").bind("plothover", function (event, pos, item) {
        if (item) {   
          var key = [item.datapoint[0], item.datapoint[1]]
          if(key in overLap)
          {
               alert(overLap[key]);
          }
        }              
});

这是一个 jsfiddle 和一个工作示例。

I do not believe this ability readily exists. I would pre-screen my data and make a note of any overlapping data points. The viability of this approach, of course, depends on the size of you datasets:

var data1 = [[0,3],[1,1],[2,2],[4,8],[5,10]];
var data2 = [[0,2],[1,2],[2,2],[4,6],[6,13]];

overLap = {}

for (var i = 0; i < data1.length; ++i)
{
    for (var j = 0; j < data2.length; ++j)
    {
        if ((data1[i][0] == data2[j][0]) && (data1[i][1] == data2[j][1]))
            overLap[data1[i]] = "label1 and label2";
    }
}

Then on the plothover just check your overLap associate array:

$("#placeholder").bind("plothover", function (event, pos, item) {
        if (item) {   
          var key = [item.datapoint[0], item.datapoint[1]]
          if(key in overLap)
          {
               alert(overLap[key]);
          }
        }              
});

Here's a jsfiddle with a working example.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文