Highcharts中的图例不应选择系列数据中指定的颜色

时间:2013-05-02 11:22:32

标签: javascript highcharts legend

我的代码如下:

var options = {
  chart: {
    type: 'column',
    events: {
      click: $scope.goToPath(link)
    }
  },
  title: {
    text: ""
  },
  xAxis: {
    categories: ['You', 'Average', 'Top Quartile'],
    labels: {
      style: {
        fontSize: '14px',
        color: 'grey'
      }
    }
  },
  yAxis: {
    title: {
      text: ''
    }
  },
  plotOptions: {
    column: {
      colorByPoint: true,
      dataLabels: {
        enabled: true,
        color: '#000000',
        style: {
          fontWeight: 'bold'
        },
        formatter: $scope.getBarValues()
      }
    }
  },

  series: [{
      showInLegend: true,
      name: 'Planning Sites',
      data: metric1["chart_numbers"],
      colors: ['#3399CC', '#CCCC33', '#686868']
    }, {
      showInLegend: true,
      name: 'Build Out And Implementation',
      data: metric2["chart_numbers"],
      colors: ['#99CBE5', '#E4E599', '#BFBFBF']
    }
  ]
}

在这里,我想自定义所显示的图例,使其不使用每个系列元素的colors数组中指定的颜色。我怎么能这样做?

我希望传说如下:

Black color - Planning   
Grey color - Build Out  

这是jsFiddle:http://jsfiddle.net/Kc55H/

1 个答案:

答案 0 :(得分:0)

对于您还可以设置color的每个系列,请参阅:http://jsfiddle.net/Kc55H/1/