Unplanned
Last Updated: 15 Jan 2024 11:45 by Sam
Sam
Created on: 15 Jan 2024 11:45
Category: Chart
Type: Bug Report
0
legendItemHover event is called repeatedly when toggleVisibility is used in Chart

Bug report

Setting the visibility using the toggleVisibility method in the legendItemHover event leads to legendItemHover being triggered multiple times. Thus, the legendItemLeave method is never called.

Reproduction of the problem

  1. Open the Dojo example - https://dojo.telerik.com/@NeliKondova/UVIVaBoH
  2. Hover the legend

Current behavior

If you try to move the cursor slightly the legendItemHover event is fired multiple times and the legendItemLeave event is never called.

Expected/desired behavior

The legendItemHover should be fired a single time when the mouse enters the legend and also the legendItemLeave should be fired even if the visibility of the legend is set through the toggleVisibility method.

Workaround - Check for visible/not visible series in the series._options

function onLegendItemHover(e){
        e.preventDefault();
        console.log("Hover");       
        let chart = e.sender;
        let seriesIndex = e.seriesIndex;
        
        for(let i = 0; i < chart.options.series.length; i++){
          if(i !== seriesIndex){
            let series = chart.findSeriesByIndex(i);
            if (series._options.visible) {
	            chart.findSeriesByIndex(i).toggleVisibility(false);
            }
          }
        }  
      }
      
      function onLegendItemLeave(e){
        e.preventDefault();
        let chart = e.sender;
        console.log("Leave");
        for(let i = 0; i < chart.options.series.length; i++){
          let series = chart.findSeriesByIndex(i);
          if (!series._options.visible) {
            chart.findSeriesByIndex(i).toggleVisibility(true);
          }
        }        
      }

Dojo with workaround - https://dojo.telerik.com/@NeliKondova/EpOYadid

Environment

  • Kendo UI version: 2023.3.1114
  • Browser: [all ]
0 comments