如何给antd charts treemap自定义颜色

How to give custom color to antd charts treemap

antd 图表树状图我已经整合了,它看起来很糟糕

您可以指定自定义颜色...在图表配置对象中添加颜色 属性 像这样

config = {
...
    color: ({ name }) => {
      if (name === "分类 10") {
        return "lightblue";
      }
      return "red";
      // return color
    }
}
 color: ({ percentage }) => {
      if (percentage < -3) {
        return "#DC3341";
      }
      if (percentage < -2) {
        return "#B22833";
      }
      if (percentage < -1) {
        return "#80262E";
      }
      if (percentage === 0) {
        return "#1E222D";
      } else if (percentage == 1) {
        return "#1A3326";
      } else if (percentage == 2) {
        return "#80262E";
      } else {
        return "#089950";
      }
      // return color
    },