Home Forums Chart Support Click event on whole chart area Reply To: Click event on whole chart area

#39055

@reactdeveloper,

You can set a flag on rangeChanging and rangeChanged event handler and check the flag before executing the functionality of click event handler as shown in the code snippet below.


let chartRangeChanging = false
.
.
rangeChanging: () => { chartRangeChanging = true },
rangeChanged: () => { chartRangeChanging = false },
.
.
function handleClick() {
  if (currentViewedDps.length != 0 && !chartRangeChanging)
    alert(
      'DataPoint with { label: ' +
      currentViewedDps[0].label +
      ', y: ' +
      currentViewedDps[0].y +
      '} is clicked'
    );
}
.
.

Please take a look at this updated Stackblitz example for complete working code.

—-
Manoj Mohan
Team CanvasJS