conditional marker colors in highcharts

repincln picture repincln · Oct 25, 2012 · Viewed 14.3k times · Source

I'm using Highcharts and I want to fill markers in line chart with different colors. For example: when variable "a" is 1 then fill marker with red else fill with green. Is it possible to do that?

Here is the code: http://jsfiddle.net/EnyCJ/1/

I was trying to do that with formatter but it doesn't work. Any suggestions?

var a=1;

plotOptions: {
 series: {
  marker: {
   fillColor: {
    formatter: function () {
      if (a == 1) {
       return 'red'
      } else {
       return 'green'
      }
    }
   },
  lineWidth: 2,
  }
 }
},

Answer

Asad Saeeduddin picture Asad Saeeduddin · Oct 25, 2012

Try:

fillColor: a==1 ? "#ff0000" : "#00ff00"

etc.