简体   繁体   English

如何更改 amchart 中堆积条形图的颜色

[英]How to change color of the stacked bar charts in amchart

I have started exploring AmCharts recently and was impressed by its superb features.我最近开始探索 AmCharts,并对其卓越的功能印象深刻。 However, I am trying to change the color of each stack in the bar but I haven`t been successful so far.但是,我正在尝试更改栏中每个堆栈的颜色,但到目前为止我还没有成功。 I tried various properties like "balloonColor" to change the color of the respective stack but nothing happened.我尝试了诸如“balloonColor”之类的各种属性来更改相应堆栈的颜色,但没有任何反应。

Can someone let me know how can we do this?有人可以让我知道我们该怎么做吗?

This is the graph I am taking about.这是我正在考虑的图表

You can change the bar's color by setting a particular graph's fillColors property, ie您可以通过设置特定图形的fillColors属性来更改条的颜色,即

AmCharts.makeChart("chartdiv", {
  // ...
  "graphs": [{
      "fillColors": "#008800",
      "fillAlpha": 1, //must also be non-zero value; valid values are decimal values <= 1
       // ...
  },
  // repeat for each graph
  ],
  // ...
});

Here's a modified version of the graph that changes the Europe segment to green.这是图表修改版本,将欧洲段更改为绿色。

Amchart 4 chart color scheme can be set like so: Amchart 4 图表配色方案可以这样设置:

chart.colors.list = [
  am4core.color("#845EC2"),
  am4core.color("#D65DB1"),
  am4core.color("#FF6F91"),
  am4core.color("#FF9671"),
  am4core.color("#FFC75F"),
  am4core.color("#F9F871")
];

Amchart 4 piechart color scheme can be updated like this: Amchart 4 饼图配色方案可以这样更新:

pieSeries.colors.list = [
  am4core.color("#845EC2"),
  am4core.color("#D65DB1"),
  am4core.color("#FF6F91"),
  am4core.color("#FF9671"),
  am4core.color("#FFC75F"),
  am4core.color("#F9F871"),
];

Documentation: https://www.amcharts.com/docs/v4/concepts/colors/ .文档: https : //www.amcharts.com/docs/v4/concepts/colors/ It also discusses gradients, etc.它还讨论了梯度等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM