EFanZh / Graphviz-Preview

Extension for Visual Studio Code to preview Graphviz (DOT) files.
https://marketplace.visualstudio.com/items?itemName=EFanZh.graphviz-preview
MIT License
67 stars 6 forks source link

Partial rendering with `graph [dpi /= 72]` #25

Open epagone opened 4 years ago

epagone commented 4 years ago

With graph [dpi = 300] the preview is blank.

EFanZh commented 4 years ago

Can you provide the full content of your source file?

epagone commented 4 years ago

Here is a MWE:

digraph dpi_bug {

  graph [dpi = 300]; #comment this line or set dpi = 72 and the rendering is ok

  A -> B;

}

While creating it, I realised that is the zoom level wrong with non-default values of dpi that crops the graph. In my complex, original case the zoom was so wrong that I obtained a blank canvas.

EFanZh commented 4 years ago

I think this is a bug from GraphViz. I tried to generate an SVG using dot directly:

echo 'digraph dpi_bug { graph [dpi = 300]; A -> B; }' | dot -Tsvg > test.svg

And the generated graph also have wrong image size.

There is a workaround from https://gitlab.com/graphviz/graphviz/issues/1406 to changes -Tsvg to -Tsvg:cairo, but the font shape in generated SVG looks bad to me, so I don’t want to use it.

I think unless GraphViz fix its SVG output, there is not much I can do.