plotly / plotly/plotly.py

with `plotly.offline.plot` add `iframe` to `output_type` to render an isolated version of outputs inside iframe

Open
#4,552 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature P3
Dominant language
Python
Stars
18.8k
Forks
2.8k
Avg merge
16h 26m
Merged PRs (30d)
21

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the plotly.offline.plot entry point and review the existing IFrameRender support. Define how an iframe output type should generate source for iframe srcdoc while preserving the existing div behavior, then validate rendering in Databricks and VSCode notebook environments.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter-notebook, python, vscode
Domain
data-visualization
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.