高光条件下的条件标记颜色

问题描述:

我使用Highcharts,我想用不同的颜色填充折线图中的标记。例如:当变量a为1时,用红色填充标记,否则用绿色填充。是否有可能这样做?

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?

以下是代码: 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,
  }
 }
},


试试:

Try:

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

等。