在条形高度图上添加颜色渐变颜色

时间:2018-04-12 20:06:23

标签: javascript highcharts

我尝试在高潮图上为条形添加渐变

我试试这个

colors: [{
    linearGradient: perShapeGradient,
    stops: [
      [0, '#c2352b'],
      [1, '#f44336 ']
    ]
  }, {
    linearGradient: perShapeGradient,
    stops: [
      [0, '#1b75bf'],
      [1, '#2196f3']
    ]
  }, {
    linearGradient: perShapeGradient,
    stops: [
      [0, '#cc7a00'],
      [1, '#ff9800']
    ]}, 
          ]

但是我所有的酒吧颜色都变得相同(甚至有渐变色)。 这是完整代码demo here的链接。

1 个答案:

答案 0 :(得分:2)

您的代码没有任何问题。问题是,您为整个系列设置颜色,所有数据都来自同一系列。如果您放置另一个系列,您可以看到它采用另一种颜色:https://codepen.io/anon/pen/XEwdQm?editors=0010

为每个category设置不同颜色可以做的是将colorByPoint中的plotOptions属性设置为true

plotOptions: {
   colorByPoint: true
}

以下是示例:https://codepen.io/anon/pen/KoLzjL?editors=0010

相关问题