Arnis
Arnis

Reputation: 29

dynamic marker color highcharts

I am new to highcharts so any help will be highly appreciated.

See my fiddle here Is it possible to change marker color based on yaxis values. I try to use zones but it also fills area underneath and line itself which i don't want to.

In this case i want all markers that are under 99.9 turn red. Is it possible using plotOptions and somehow get yaxis values. Can someone point me to proper syntax or other ways to achieve this as i get Uncaught ReferenceError: chart is not defined.

      plotOptions: {
    series: {

      marker: {
        //fillColor: chart.get('y-axis') <=99.9 ? "yellow" : "blue"


      }
    }
  },

Thanks.

Upvotes: 0

Views: 1428

Answers (1)

ppotaczek
ppotaczek

Reputation: 39069

You can define the marker options for each point:

    data.forEach(function(el, i) {
        data[i] = {
            x: el[0],
            y: el[1],
            marker: {
                fillColor: el[1] <= 99.9 ? "yellow" : "blue"
            }
        }
    });

Live demo: https://jsfiddle.net/BlackLabel/yjpgqcvw/

API: https://api.highcharts.com/highcharts/series.line.data.marker

Upvotes: 1

Related Questions