'How to enable marker on hover only for a range of points in highcharts

I am trying to make a line chart (x-axis shows time) in which only a range of points/markers are enabled on hover. Like from time t1 to time t2, marker should be available and in other case it should be disabled.

I tried using

hover {
        enabled : function(){
                    if(this.x >= t1 && this.x <= t2) return true;
                    else return false;
                    }
      }

But hover didn't seem to understand anonymous function I suppose and the hover is enabled for all. How can I achieve this thing?



Solution 1:[1]

From series.marker.states.hover.enabled:

enabled: Boolean

Enable or disable the point marker. Defaults to true.

It should be set to true/false, not an anonymous function.

If you want only some of the points to have hover state, then enable only for those points that states:

plotOptions: {
  series: {
    marker: {
      states: { 
        hover: { enabled: false } // disable by default
      }
    }
  }
}

And points' settings:

series: [{
  data: [{ 
    x: ...,
    y: ...,
    marker: {
      states: {
        hover: { enabled: true }
      }
    }
  }, { 
    x: ..., // This point has disabled hover state,
    y: ..., // inherited defaults from series.
  }, { 
    x: ...,
    y: ...,
    marker: {
      states: {
        hover: { enabled: true }
      }
    }
  }]
}]

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Community