[Solved] How to modify hover sensitivity in a multiseries scatterLine chart when two series are close to each other or the lines overlap at some point?

1 Answer 13 Views
Chart
Kenia
Top achievements
Rank 1
Kenia asked on 02 Apr 2026, 03:33 PM | edited on 02 Apr 2026, 04:05 PM

I have a multiseries scatterLine chart built in js that also has multiple yaxis shown one at a time as you hover on the series.

Sometimes series can be close to each other and therefore when zooming in or scrolling left and right in a blank space of the chart, the hover event fires taking another series (not necessarily the closest one to mouse position) and therefore changing the one being showcased and restarting zoom, this is my hover event:

        function onHoverScatter(e) {
            if (lockedAxisSeries && lockedAxisSeries !== e.series.yAxis) return;
            if (hoverLock && currentHoverAxis !== e.series.yAxis) return;

            let chart = e.sender;
            var hoveredSeriesIndex = e.series.index;

            let series = chart.options.series;
            let yAxis = chart.options.yAxis;
            hoverLock = true;
            if (currentHoverAxis === hoveredSeriesIndex) return;
            currentHoverAxis = hoveredSeriesIndex;

            for (let i = 0; i < series.length; i++) {
                if (i === hoveredSeriesIndex) {
                    series[i].opacity = 1;
                } else {
                    series[i].opacity = 0.2;
                }
            }

            if (!Array.isArray(yAxis)) yAxis = [yAxis];
            yAxis[hoveredSeriesIndex].plotBands[0].opacity = 0.5;
            yAxis[hoveredSeriesIndex].visible = true;

            yAxis.forEach(function (axis, i) {
                if (i !== hoveredSeriesIndex) {
                    axis.visible = false;
                    axis.plotBands[0].opacity = 0.0;
                }
            });

            chart.options.series.forEach(function (s) {
                if (!s.markers) s.markers = {};
                s.markers.size = 6;
            });

            chart.setOptions({
                series: series,
                yAxis: yAxis,
                xAxis: {
                    min: null,
                    max: null
                }
            });
        }               

 

this is how the series look:

 

this is an example of the hover event firing for a marker much further away than the intended one:

(the blue circle represents where the mouse was positioned)

                                        

1 Answer, 1 is accepted

Sort by
0
Anton Mironov
Telerik team
answered on 07 Apr 2026, 07:35 AM

Hello Kenia,

Thank you for the code snippe, the images, and the details provided.

The default hover sensitivity in scatterLine charts can cause tooltips and hover events to trigger even when the mouse is not directly over a marker, especially if series overlap or are close together. This can lead to unintended axis changes and zoom resets.

To restrict the hover event so it only fires when the mouse is directly over a marker, you can adjust the logic in the getNearestPoint method by lowering the distance threshold. For example:

var nearestPointDistance = (oldPoint ? 6 : Number.MAX_VALUE); // Use a small value like 6 for stricter detection

This ensures that only points very close to the mouse cursor will trigger the hover event. If your markers are small and hard to target, consider slightly increasing the marker size for usability.

You may also want to check if the mouse is actually over a marker before updating the axis or zoom. In your onHoverScatter function, add a check for proximity to the marker before running the rest of the logic.

I hope this information helps.

    Kind Regards,
    Anton Mironov
    Progress Telerik

    Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

    Tags
    Chart
    Asked by
    Kenia
    Top achievements
    Rank 1
    Answers by
    Anton Mironov
    Telerik team
    Share this question
    or