plotly / plotly/plotly.py

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

未关闭
#4,552 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

feature P3
主要语言
Python
星标
18.8k
派生
2.8k
平均合并
16 小时 26 分钟
30 天内合并 PR
21

描述

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.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 plotly.offline.plot 入口点开始,审查现有的 IFrameRender 支持。定义 iframe 输出类型应如何为 iframe srcdoc 生成源代码,同时保留现有的 div 行为,然后在 Databricks 和 VSCode notebook 环境中验证渲染。

由索引模型根据 Issue 内容生成。

评估

技术栈
jupyter-notebook, python, vscode
领域
data-visualization
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
需要澄清
新手友好度
30/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。