在假想的垂直线上浮动工具提示
如何添加工具提示的功能,以便在 鼠标“悬停”在该点上或该点上方/下方的假想垂直线上的任何像素?
我的图表上只有 1 条线。我 希望这样当鼠标移动时可以显示数据点的工具提示 越过穿过该点的“看不见的”垂直线 - 不强制 用户明确将鼠标悬停在该点上。
我找到了这个解决方案 - 但它看起来像是一个黑客(并且不起作用): Flot mousehover算法纯粹基于x位置进行检测?< /a>
有没有更好的方法来做到这一点而不是破解源代码?
这是我正在谈论的一个例子(它的大图表,但是这个 是我想要的功能)。您可以将鼠标悬停在该线上或将鼠标悬停在 X 轴上的任意点以显示该 X 轴上的点 像素: http://finance.yahoo.com/echarts?s=^DJI+Interactive#chart1:symbol=^dji;range=1d;indicator=volume;charttype=line ;crosshair=on;ohlcvalues=0;logscale =on;来源=未定义
How can I add the ability for a tooltip for a point to show when the
mouse "hovers" over that point OR any pixel on an imaginary vertical line above/below that point?
My graph only has 1 line on it. I
would like it so a tooltip can show for the datapoint when the mouse
goes over an "invisible" vertical line through the point - not forcing
the user to explicitly hover over the point.
I found this solution - but it seems like a hack (and doesn't work):
Flot mousehover algorithm to detect purely based on x location?
Is there any better way to do this short of hacking the source?
Here is an example of what I'm talking about (its bigcharts, but this
is the function I want). You can hover over the line or hover over
any point on the X axis to show the point that is on that X axis
pixel:
http://finance.yahoo.com/echarts?s=^DJI+Interactive#chart1:symbol=^dji;range=1d;indicator=volume;charttype=line ;crosshair=on;ohlcvalues=0;logscale=on;source=undefined
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我能够在这个 fiddle 中执行类似于雅虎图表的操作。我只是在鼠标悬停时更新 x 位置:
然后运行更新方法。 update 方法(取自 flot crosshairs 示例)对 y 数据点进行插值最接近 x,然后在线上显示工具提示和点:
我认为为了实际与数据点交互,您必须更改源。
I was able to do something similar to the Yahoo chart in this fiddle. I just update the x position whenever the mouse is hovering:
then run the update method. The update method (taken from the flot crosshairs example) interpolates the y datapoint closest to x, then displays a tooltip and point on the line:
I'm thinking that in order to actually interact with the datapoints, you will have to alter the source.