Search code examples
highchartsreact-highcharts

Is it possible to change color current Yaxis line?


Is it possible to change the color of a specific y-axis line using HighchartJs ?

like this for Yaxis 150 enter image description here


Solution

  • Highcharts offers a wide range of customizations. The reference to a grid line can be found in for example load event and color can be changed by attr method.

      chart: {
        events: {
          load: function() {
            this.yAxis[0].ticks[150].gridLine.attr({
              stroke: 'red'
            });
          }
        }
      }
    

    Live demo: http://jsfiddle.net/BlackLabel/z59od8g2/

    API Reference: https://api.highcharts.com/class-reference/Highcharts.SVGElement#attr