xflr6 / graphviz

Simple Python interface for Graphviz
https://graphviz.readthedocs.io
MIT License
1.63k stars 211 forks source link

fix: set default Jupyter mimetype text/html #205

Open jokasimr opened 11 months ago

jokasimr commented 11 months ago

The default mime-type in the Jupyter integration is currently image/svg+xml. This makes Jupyter display the generated svg in an <img> tag. The issue with that is we lose some nice features of svg such as being able to select text (labels on nodes etc).

If we use the mime type text/html Jupyter displays an <svg> node instead.

Example Screenshot from 2023-10-12 14-41-32

codecov-commenter commented 11 months ago

Codecov Report

Merging #205 (7abda00) into master (1760930) will not change coverage. The diff coverage is 100.00%.

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

@@            Coverage Diff            @@
##            master      #205   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           33        33           
  Lines         1085      1085           
=========================================
  Hits          1085      1085           
Files Coverage Δ
graphviz/jupyter_integration.py 100.00% <100.00%> (ø)

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

xflr6 commented 11 months ago

Thanks for the PR.

The issue with that is we lose some nice features of svg such as being able to select text (labels on nodes etc).

Cannot reproduce, text selection works as intended for me both under nbviewer and the GH renderer.

Screenshot 2023-10-16 190734

Screenshot 2023-10-16 190848

Maybe this is specific to your browser (used Firefox above)?

jokasimr commented 11 months ago

Cannot reproduce, text selection works as intended for me both under nbviewer and the GH renderer.

Interesting, I've tested the following combinations: Jupyter Lab in Firefox and Chrome, Sphinx documentation in Firefox and Chrome.

In those cases the graph visualizations were rendered as <img>. Another example are the graphs displayed in the graphviz docs.