浮动鼠标悬停算法纯粹基于x位置进行检测? [英] Flot mousehover algorithm to detect purely based on x location?

查看:88
本文介绍了浮动鼠标悬停算法纯粹基于x位置进行检测?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用jQuery的flot,有一种方法可以通过将项目悬停在它们上来选择项目。在选项中,grid [mouseActiveRadius]可以设置为一个数字,以指示所需的选择圆半径。

Using jQuery's flot, there's a way to allow items to be selected by hovering over them. In the options, grid[mouseActiveRadius] may be set to a number to indicate the desired length of the radius of the selection circle.

例如,如果将其设置为10,然后任何鼠标悬停事件都会突出显示10像素半径圆中的最近点。

For instance, if you set it to 10, then any mouse hover event will highlight the closest point in a 10 pixel radius circle.

但是,我希望告诉flot将鼠标悬停在距离最近的点上。 x方向(而不是最近的点周期)。

However, I wish to instead tell flot to hover the point that's the closest in the x direction (instead of the closest point period).

此示例中的EG:第1点显然比第2点更接近x,但我仍然希望flot选择第2点,因为它在x方向上更近。

EG in this example: point 1 is obviously a lot closer to x than point 2, but I still want flot to select point 2 since it is closer in the x direction.

           x
1







          2

有没有办法做到这一点有插件/内置功能,还是我需要编写扩展flot默认行为的函数?

Is there a way to do this with plugins/built in functionality, or do I need to write a function extending flot's default behavior?

推荐答案

我发现的唯一方法是改变来源。 (它很糟糕,但通常更好的是一个评论很好的黑客而不是无法维护的解决方法)

The only way I found is to change the source. (it sucks ok, but it's often better a well commented hack than a un-maintainable workaround)

找到这段代码:( function findNearbyItem() ,在我的修订版第2278行)

Find this code: (function findNearbyItem(), on line 2278 on my revision)

if (s.lines.show || s.points.show) {
                    for (j = 0; j < points.length; j += ps) {
                        var x = points[j], points[j + 1];
                        if (x == null)
                            continue;

更改为:

if (s.lines.show || s.points.show) {
                    for (j = 0; j < points.length; j += ps) {
                        var x = points[j], y =0; // points[j + 1];
                        if (x == null)
                            continue;

希望这个答案可以帮助任何有同样问题的人。

Hope this answer will help anybody with the same problem.

这篇关于浮动鼠标悬停算法纯粹基于x位置进行检测?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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