repincln repincln - 2 years ago 391
Javascript Question

conditional marker colors in highcharts

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:

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 Source


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


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download