Fix tiny graph: keep SVG natural size, scroll on overflow
Stop replacing the SVG's width/height attributes — this was shrinking the graph to fit the container. Instead keep graphviz's native pt dimensions and let the scroll container handle overflow. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import copy
|
import copy
|
||||||
import re
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from nicegui import ui
|
from nicegui import ui
|
||||||
@@ -428,11 +427,7 @@ def _render_graphviz(dot_source: str, selected_node_id: str | None = None):
|
|||||||
src = graphviz.Source(dot_source)
|
src = graphviz.Source(dot_source)
|
||||||
svg = src.pipe(format='svg').decode('utf-8')
|
svg = src.pipe(format='svg').decode('utf-8')
|
||||||
|
|
||||||
# (a) Responsive SVG sizing — fill container width, remove fixed height
|
# (a) Keep SVG at natural size, let scroll container handle overflow
|
||||||
# so the SVG scales proportionally via its viewBox attribute
|
|
||||||
svg = re.sub(r'\bwidth="[^"]*"', 'width="100%"', svg, count=1)
|
|
||||||
svg = re.sub(r'\s*height="[^"]*"', '', svg, count=1)
|
|
||||||
|
|
||||||
container_id = f'graph-{id(dot_source)}'
|
container_id = f'graph-{id(dot_source)}'
|
||||||
html_content = (
|
html_content = (
|
||||||
f'<div id="{container_id}" '
|
f'<div id="{container_id}" '
|
||||||
|
|||||||
Reference in New Issue
Block a user