Search code examples
javascriptgraphhighcharts

How to show horizontal line instead of a dot for a single value data in highcharts


everyone, I am using highcharts to show graphs. Currently, for a single value, it is showing a dot in a graph as shown in a screenshot. Instead of a dot, I want a horizontal line parallel to the x-axis. Can anyone help me to solve this? Thank you.

enter image description here

Ref: https://jsfiddle.net/5syn3ko1/

Note: please copy and paste the URL in the browser for code sandbox. It is showing an error when I paste the link.


Solution

  • Instead of adding a series with single values, use plot lines:

        xAxis: {
            plotLines: [{
                value: 2010,
                color: 'blue'
            }],
            ...
        }
    

    Live demo: https://jsfiddle.net/BlackLabel/3654z2yw/

    API Reference: https://api.highcharts.com/highcharts/xAxis.plotLines