From 702c3a89471cb30668f6d7c7d5d30373b086926b Mon Sep 17 00:00:00 2001 From: longxiaofei Date: Tue, 30 Jul 2024 16:37:58 +0800 Subject: [PATCH] fix: manually invoke display_preview_on_jupyter --- pygwalker/api/pygwalker.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pygwalker/api/pygwalker.py b/pygwalker/api/pygwalker.py index 1d04e70..a865880 100644 --- a/pygwalker/api/pygwalker.py +++ b/pygwalker/api/pygwalker.py @@ -258,7 +258,7 @@ def display_preview_on_jupyter(self): """ Display preview on jupyter notebook/lab. """ - display_html(self._get_gw_preview_html()) + display_html(self._get_gw_preview_html(True)) @property def chart_list(self) -> List[str]: @@ -581,7 +581,10 @@ def _get_render_iframe( else: return html - def _get_gw_preview_html(self) -> str: + def _get_gw_preview_html(self, manual: bool = False) -> str: + """ + 'manual' represents the user actively calling to obtain preview_html. It will randomly generate a gid, keeping it separate from the logic of walker automatically generating the preview part. + """ if not self.workflow_list: return "" datas = [] @@ -594,7 +597,7 @@ def _get_gw_preview_html(self) -> str: self.vis_spec, datas, self.theme_key, - self.gid, + self.gid if not manual else self.gid + rand_str(), self.appearance )