Noman
Noman

Reputation: 699

How to give custom color to antd charts treemap

enter image description here

I have integrated the antd charts treemap and its looking really bad

Upvotes: 3

Views: 1411

Answers (2)

Noman
Noman

Reputation: 699

 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
    },

Upvotes: 0

Sanoodia
Sanoodia

Reputation: 905

You can assign custom colors... in Chart configuration object add color property like this

config = {
...
    color: ({ name }) => {
      if (name === "分类 10") {
        return "lightblue";
      }
      return "red";
      // return color
    }
}

Upvotes: 3

Related Questions