in databao/visualizers/vega_vis_tool.py [0:0]
def get_html(self) -> str:
spec = self.prepare_spec(self._spec, self._df)
# Convert to JSON to correctly deal with JS types (e.g., "None" to "null")
spec_json = json.dumps(spec)
debug = json.dumps(self._debug)
div_id = uuid.uuid4()
# Usage based on https://github.com/JetBrains/data-tools/tree/main/embed
return textwrap.dedent(f'''
<div id="{div_id}">
<script type="application/javascript">
(function() {{
const script = document.createElement("script");
script.onload = function() {{
const container = document.getElementById("{div_id}");
if (container && renderVisualizationTool) {{
renderVisualizationTool({spec_json}, container, {debug})
}}
}};
script.src = "{_DATA_TOOLS_URL}/{self._version}/vistool.js";
document.getElementById("{div_id}").appendChild(script);
}})();
</script>
</div>
''')