From 33b01b4f1d956d47283b4cedabf5254284d84573 Mon Sep 17 00:00:00 2001 From: Gertjan van Zwieten Date: Fri, 16 Feb 2024 15:08:19 +0100 Subject: [PATCH] scale graphviz svg down to 2/3 of original size This patch modifies the width and height parameters of the graphviz generated svg image in order. This avoids having to scale the image via the browser which may affect other tabs as well. Sadly it does not seem possible to instruct the dot executable to generate an image at the desired scale directly. --- nutils/_graph.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/nutils/_graph.py b/nutils/_graph.py index b39b00a67..2631bb412 100644 --- a/nutils/_graph.py +++ b/nutils/_graph.py @@ -71,10 +71,15 @@ def export_graphviz(self, *, fill_color: Optional[GraphvizColorCallback] = None, treelog.warning('graphviz failed for error code', status.returncode) graph = status.stdout if image_type == 'svg': - graph = re.sub(b'', insert_clickHandler, graph, count=1, flags=re.DOTALL) + graph = re.sub(b'', lambda svg_match: b'''' + + clickHandler, graph, count=1, flags=re.DOTALL) img.write(graph) -insert_clickHandler = rb''' + +clickHandler = rb'''