-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flowchart arrow heads are not colored according to linkStyle settings #1236
Comments
Any news regarding the possibility to style the arrowhead properly? (at least having the same color as the stroke) |
Please change the default to grey at a minimum - black arrow head is lost on dark websites. |
I believe the challenge here is that the arrowheads (markers) are actually shared by all lines that use them whereas the line is unique. So updating the color of the marker would affect all lines using the marker. I think this could be done by dynamically creating a unique marker when the the line is styled and applying the requested style to the new marker. |
Any update on this? |
I have found a workaround for styling arrow-head :-) You can add the following CSS into your webpage: <style>
#flowchart-pointEnd { stroke:#0f0 !important; fill:#f00 !important; stroke-width:3px !important; }
</style> Notice the You can define styles for other types of markers: |
If you want to style all arrow heads to be a single color, you can do this:
%%{
init: {
'themeVariables': {
'lineColor': '#0f0'
}
}
}%%
graph TD
A --> B
Example: playground link However, I've still not found a good way to only do it for specific arrow heads. 😅 |
I was able to style the lines and arrows to match the background color and text of my blog with this CSS (all my Mermaid diagrams are in div.mermaid .edgeLabel {
background-color: #151515 !important;
color:#eaeaea !important;
}
div.mermaid .marker {
fill: #eaeaea !important;
stroke: #eaeaea !important;
}
div.mermaid .marker.cross {
stroke: #eaeaea !important;
}
div.mermaid .edgePath .path {
stroke: #eaeaea !important;
}
div.mermaid .flowchart-link {
stroke: #eaeaea !important;
} Was able to figure this out thanks to your comment, @Nezteb: I copied the style element of the diagram before and after applying your |
Hi all, There is a way to fix this in the SVG spec, as explained in this SO thread. Basically, markers in the SVG that Mermaid outputs should have the attribute Looks like this: <svg>
<g>
<marker id="pointy-head" ...>
<path d="..." fill="context-stroke"></path><!-- That's where the fix is done -->
</marker>
</g>
...
<g class="edgePaths">
<path id="L-left-right-0" class="..." d="..." marker-end="url(#pointy-head)"></path><!-- That's where the marker is used -->
</g>
</svg> The only issue is that... not many browsers support this at the time of writing :-( If your audience is 100% FF users it works though 🙃 |
I have created a workaround for this in Javascript cribbed initially from this stackoverflow answer, and modified to work with the current mermaid svg output and both start and end markers.
|
@flowchartsman If you want to detect Mermaid-made flowcharts, you can check for |
Huh, you know, originally I was thinking I could make this work for other diagram types, but now that I think about it, I guess flowcharts are really the only place you can color style links anyway. |
Exactly. And I hope that the same attribute is set to other recognizable values for other graph types.
|
Yup, I've got it running on my site now, and it works nicely. Still seems like a cludgy solution to have to include javascript to fix it :) |
This is supported in Chrome and Edge since April, and Opera since May (caniuse). Safari doesn't support it yet, but at almost 70% of web users, maybe it's worth implementing this now? |
Describe the bug
The arrow head color is not affected by link style
stroke
settings.To Reproduce
Steps to reproduce the behavior:
see live editor example
Expected behavior
Arrow heads should be colored according to link style settings as well.
Additional context
Tested with mermaid 8.4.6
The text was updated successfully, but these errors were encountered: