Description
I searched existing issues and didn't find any issues suggestion this feature before.
This is an idea to solve the problem of rendering databricks notebooks inside VSCode with Plotly.
Based on https://docs.databricks.com/en/visualizations/plotly.html, databricks suggest we use plotly.offline.plot
with output_type=div
and their displayHTML
to render plotly in databricks notebooks. This works well inside databricks notebooks in browser env but will not working if we want to show the same notebook inside vscode notebooks.
The problem here is that when I try to render this outputs in vscode notebook out cell directly, the plotly.js can't set up window.Plotly
correctly due security mode of vscode, then I got an error in vscode said: Uncaught ReferenceError: Plotly is not defined
.
I am using https://marketplace.visualstudio.com/items?itemName=paiqo.databricks-vscode to render and connect notebook inside vscode with databricks. I have a hack hot fix to that extension and add any html that include Plotly.newPlot
into an iframe. So I can confirm add the outputs generated by plotly.offline.plot
with output_type='div'
inside iframe will solve the security issue of vscode and render plotly correctly on both databricks and vscode.
Consider plotly already have IFrameRender, I think we should also add iframe as support type of plotly.offline.plot
, generate the source code and put it inside iframe's srcdoc
. This way plotly offline can create an isolated version of outputs and make sure it renders correctly in restrict envs like vscode.
Thank you! Let's me know if idea works and I am willing to help.