highcharts 如何在堆积条形图上设置自定义颜色

9avjhtql  于 2022-11-11  发布在  Highcharts
关注(0)|答案(1)|浏览(245)

我想画一个下面的堆积柱形图,可以画这种图吗?
提前感谢。

xn1cxnb4

xn1cxnb41#

您可以为最后一个系列启用colorByPoint选项:

series: [..., {
    ...,
    colorByPoint: true
  }]

现场演示:https://jsfiddle.net/BlackLabel/fdwbLzan/
API引用:https://api.highcharts.com/highcharts/series.column.colorByPoint

或者为每个点定义单独的颜色:

series: [..., {
    ...,
    data: [{
      y: 3,
      color: 'black'
    }, {
      y: 4,
      color: 'purple'
    }, {
      y: 4,
      color: 'green'
    }, {
      y: 2,
      color: 'orange'
    }, {
      y: 5,
      color: 'blue'
    }]
  }]

现场演示:https://jsfiddle.net/BlackLabel/r87mv6n3/
API参考:https://api.highcharts.com/highcharts/series.column.data.color

相关问题