简体   繁体   English

Flot:抓住最接近十字准线的点

[英]Flot: grab nearest point to crosshair

I've been customizing my graphics and I've been trying to get the nearest point to the crosshair. 我一直在定制我的图形,我一直在努力获得最接近十字准线的点。 The closest I got was by adding the mouseActiveRadius option, however this does not apply my desired effect. 我得到的最接近的是添加mouseActiveRadius选项,但是这不适用于我想要的效果。 This is what happens: 这是发生的事情:

在此输入图像描述

As can be seen, the wrong point is being highlighted. 可以看出,正在强调错误的观点。

My plot code: 我的情节代码:

    $.plot("#players_chart",
        [{
            label: "Total number of players",
            data: data.data_labels
        }],
        {
            series: {
                lines: {
                    show: true
                }
            },
            xaxis: {
                mode: "time",
                minTickSize: [1, "day"],
                timeformat: "%a"
            },
            yaxis: {
                tickDecimals: 0
            },
            crosshair: {
                mode: "x"
            },
            grid: {
                hoverable: true,
                autoHighlight: true,
                mouseActiveRadius : 1000
            }
        }
    );

Is there any way to add some kind of horizontal radius to the crosshair instead of grid? 有没有办法在十字准线而不是网格上添加某种水平半径?

Thank you in advance. 先感谢您。

The default point highlighting is separated from the crosshair plugin and works only by distance from the cursor. 默认点突出显示与十字准线插件分开,仅适用于距光标的距离。 If you want to only work with horizontal distance you can do the highlighting manually. 如果您只想使用水平距离,可以手动进行高亮显示。

Set autoHighlight: false and bind a plothover event where you search the nearest point on the x axis and then highlight that point. 设置autoHighlight: false并绑定一个plothover事件,在该事件中搜索x轴上的最近点,然后突出显示该点。

Similar code is in the example for the crosshair plugin . 十字线插件示例中有类似的代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM