From a0c0fe1a57bdf7aef68821276ed10bf92b88e27f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Bel=C3=A1k?= Date: Thu, 17 Aug 2023 14:03:46 +0200 Subject: [PATCH] fix: set default plotly renderer when exporting to HTML Previously plotly plots would not be rendered in HTML exports. --- edvart/report.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/edvart/report.py b/edvart/report.py index 6b393bf..88e4107 100755 --- a/edvart/report.py +++ b/edvart/report.py @@ -291,9 +291,15 @@ def export_html( ) # Add code cells to generated notebook - nb["cells"].append(nbf4.new_code_cell("import pickle\nimport base64")) - nb["cells"].append(nbf4.new_code_cell(unpickle_report)) - nb["cells"].append(nbf4.new_code_cell("report.show()")) + for code_string in ( + "import base64", + "import pickle", + unpickle_report, + "import plotly.io as pio", + "pio.renderers.default = 'notebook'", + "report.show()", + ): + nb["cells"].append(nbf4.new_code_cell(code_string)) self._export_html( nb=nb,