-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Describe the bug
When using DOT_IMAGE_FORMAT = svg
, DOT_TRANSPARENT = YES
does not have any effect. dot
outputs a svg with a solid object with a non-transparent background.
Expected behavior
The generated svg background object should either be transparent or not exist.
To Reproduce
dot-transparent-ineffective-svg.zip
Minimal example attached. To see affected output, run doxygen
, then open docs/html/group__a.html
. The generated docs use a custom css
that colors the background of .contents
divs purple, so you can see the white background on the generated SVG, as shown in the screenshot above.
Version
1.9.3 (c0b9eafbfb53286ce31e75e2b6c976ee4d345473)
, on x64 Windows 10 Pro 21H2 (19044.1526)
Stack trace
N/A
Additional context
Due to the way SVGs are included in the HTML output as an iframe
, styling with CSS causes the non-transparent background to be ineffective. The dot
file generated doesn't set a bgcolor
attribute on the entire graph, though I do see it trying to in the code. As an example, here:
doxygen/src/dotgroupcollaboration.cpp
Lines 317 to 340 in e18f715
void DotGroupCollaboration::writeGraphHeader(TextStream &t,const QCString &title) const | |
{ | |
int fontSize = Config_getInt(DOT_FONTSIZE); | |
QCString fontName = Config_getString(DOT_FONTNAME); | |
t << "digraph "; | |
if (title.isEmpty()) | |
{ | |
t << "\"Dot Graph\""; | |
} | |
else | |
{ | |
t << "\"" << convertToXML(title) << "\""; | |
} | |
t << "\n"; | |
t << "{\n"; | |
if (Config_getBool(DOT_TRANSPARENT)) | |
{ | |
t << " bgcolor=\"transparent\";\n"; | |
} | |
t << " edge [fontname=\"" << fontName << "\",fontsize=\"" << fontSize << "\"," | |
"labelfontname=\"" << fontName << "\",labelfontsize=\"" << fontSize << "\"];\n"; | |
t << " node [fontname=\"" << fontName << "\",fontsize=\"" << fontSize << "\",shape=box];\n"; | |
t << " rankdir=LR;\n"; | |
} |
The SVG XML produced from the dot without the bgcolor attribute with the creates a polygon with a white
fill:
<!--snipped-->
<polygon fill="white" stroke="transparent" points="-4,4 -4,-23 146,-23 146,4 -4,4"/>
<!--snipped-->
Manually removing that <polygon />
produces the desired outcome:
If I manually edit a dot file, to add the attribute:
--- group__a.dot Thu Feb 17 08:59:12 2022
+++ group__a-modified.dot Thu Feb 17 08:59:13 2022
@@ -1,5 +1,6 @@
digraph "Group A"
{
+ bgcolor="transparent"
edge [fontname="Helvetica",fontsize="10",labelfontname="Helvetica",labelfontsize="10"];
node [fontname="Helvetica",fontsize="10",shape=box];
rankdir=LR;
The <polygon />
isn't created in the output.
The PR #8826 looks like it might be a potential fix for this, as the DOT_COMMON_ATTR
it adds looks like it would be a place to specify bgcolor="transparent"
, but it is my feeling that the DOT_TRANSPARENT
still should create that attribute itself, but for some reason isn't.
Cheers!