prabh_singh
prabh_singh

Reputation: 177

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?

Upvotes: 1

Views: 1315

Answers (1)

Paweł Fus
Paweł Fus

Reputation: 45079

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 }
      }
    }
  }]
}]

Upvotes: 2

Related Questions