How to give a fixed color code for a specific label in mermaid pie chart? #148226
-
Select Topic AreaQuestion BodyI have a question about Mermaid pie charts in GitHub Markdown. For example, let’s say I have 30 blue cars, 20 yellow cars, and 5 green cars. If I code them up in a Mermaid pie chart, it looks like this: pie
"Yellow Car" : 20
"Blue Car" : 30
"Green Car" : 5
Now, if the number of yellow cars changes to 50, the chart updates like this: pie
"Yellow Car" : 50
"Blue Car" : 30
"Green Car" : 5
The issue is, the label “Yellow Car” doesn’t stay yellow. Its color changes based on how Mermaid automatically assigns colors. My question is: is there a way to make the label “Yellow Car” always appear in yellow, regardless of its proportion in the chart? Does GitHub Markdown support something like this? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Explanation:
|
Beta Was this translation helpful? Give feedback.
Explanation:
%%{init: ...}%%block initializes the Mermaid configuration, allowing you to define custom colors for the pie chart slices.pie1,pie2, andpie3keys correspond to the slices in the order they are declared in thepieblock.#FFD700: Yellow (assigned to "Yellow Car").#87CEEB: Light Blue (assigned to "Blue Car").#32CD32: Green (assigned to "Green Car").