Replies: 2 comments
-
For any of the maintainers, is there a better place for me to add this information? Is it already in the docs and I didn't find it? If not, I'm happy to try to work it into the documentation. |
Beta Was this translation helpful? Give feedback.
0 replies
-
I spent ages testing out customizing my Gantt chart colours the other night - the code might give some tips if anyone finds this issue: Issue for this: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi all 👋 I'm a long time fan, first time poster. In using a Gantt chart, I came across a question that was difficult to resolve, and so I wanted to put the info here for anyone else's future reference.
Here's how the Gantt chart for my work looks in the default theme:
I needed to change the color of each row to red, green, and blue so that it matches other plots referring to the same content. The Gantt chart docs Styling section suggests you can customize the following attributes: grid.tick, grid.path, .taskText, .taskTextOutsideRight, .taskTextOutsideLeft, todayMarker. These are the text, grid, and today marker, but none are the background color for each row. However, that section of the docs refers to src/diagrams/gantt/styles.js. So, I poked around there and noticed:
This gave me a hunch that setting
sectionBkgColor
,sectionBkgColor2
, andaltSectionBkgColor
might be the ticket. It wasn't clear at this point how to set this configuration, but so I tried a variety of different things in the%%{ init: { ... } }%%
block at the beginning of the diagram.Feeling out of ideas, I went back to the beginning to learn more about themes and Googled "mermaid themes". Possibly due to my previous searches, the top hit was Mermaid Theme Configuration. The Custumizing Themes with themeVariables section has a few things to note:
You will need to use the [base](https://mermaid.js.org/config/theming.html#available-themes) theme as it is the only modifiable theme.
-> In my case, this doesn't seem to be true.%%{ init: { theme': 'base', 'themeVariables': { ... } } }%%
Finally, trying this out with the section and alt color variables I found in the Gantt chart style definition, I was able to customize the row colors for the Gantt chart:
And the config block is:
Note that
altSectionBkgColor
is used for the odd-indexed rows, as is clear in the Javascript styling:It worked fine for me since I coincidentally only needed three rows, but individual colors for each row when there are more than three might require modifying that styling.
Apologies for being long winded, but I wanted to include the information I found along the way in case it helps.
Beta Was this translation helpful? Give feedback.
All reactions