Amcharts 网格颜色不透明度

问题描述

需要更改线条(网格)颜色,创建自定义主题,但我的线条不透明

enter image description here

function am4themes_sdTheme(target) {
  if (target instanceof am4core.InterfaceColorSet) {
    target.setFor('text',am4core.color('#ffffff')); // text color
    target.setFor('grid',am4core.color('#ffffff')); // line color
  }
}
am4core.useTheme(am4themes_sdTheme);

谢谢!

解决方法

那是一个 tick,而不是一个网格。您必须单独定位它:

function am4themes_sdTheme(target) {
  if (target instanceof am4core.InterfaceColorSet) {
    target.setFor('text',am4core.color('#ffffff')); 
  }
  if (target instanceof am4charts.Tick) { 
    target.strokeOpacity = 0;
  }
}
am4core.useTheme(am4themes_sdTheme);

Tick 扩展了不同类型的元素,因此如果您想区分饼图、轴刻度等,您可能需要更具体并使用 PieTick。

,

function am4themes_sdTheme(target) {
  if (target instanceof am4core.InterfaceColorSet) {
    target.setFor('text',am4core.color('#ffffff')); // text color
    target.setFor('grid',am4core.color('#ffffff')); // line color
  }
  if (target instanceof am4charts.Tick) {
    target.strokeOpacity = 1; // line opacity
  }
}
am4core.useTheme(am4themes_sdTheme);