Highcharts identify when minRange isreached

23 Views Asked by At

I am using highcharts along with React. I have added a minRange: 3600000, so that the user cant zoom in more then to one hour. I want to identiy programmatically when this minRange is reached.the following selection event will run for every time zoom happens

    selection: function (event) {
      const chart = this;
      if (event?.xAxis && event.xAxis.length > 0) {
        setLeft(chart.plotWidth + 10);
        setTimeStamp(event.xAxis[0]?.max);
      } else {
        const chart = this;
        const lastItem = sampleData.data[sampleData.data.length - 1];
        setLeft(chart.plotWidth + 10);
        setTimeStamp(lastItem.timestamp);
      }
    },

Inside this function i want to run this if block only when the rangeSelection is enabled

      if (event?.xAxis && event.xAxis.length > 0) {
        // one more if condition that the chart is still zoomable if(){
        setLeft(chart.plotWidth + 10);
        setTimeStamp(event.xAxis[0]?.max);
        //}
      }

Full code link is https://stackblitz.com/edit/vitejs-vite-g4kjrc?file=src%2FApp.jsx

0

There are 0 best solutions below