Skip to content

Commit

Permalink
Bundle plotly.js in html for iframe renderer for chrome compatibility
Browse files Browse the repository at this point in the history
Add iframe_connected renderer to load plotly.js from CDN.
  • Loading branch information
jonmmease committed Jun 24, 2019
1 parent 99a1890 commit 96569c4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
10 changes: 8 additions & 2 deletions packages/python/plotly/plotly/io/_base_renderers.py
Expand Up @@ -525,13 +525,19 @@ class IFrameRenderer(MimetypeRenderer):
"""

def __init__(
self, config=None, auto_play=False, post_script=None, animation_opts=None
self,
config=None,
auto_play=False,
post_script=None,
animation_opts=None,
include_plotlyjs=True,
):

self.config = config
self.auto_play = auto_play
self.post_script = post_script
self.animation_opts = animation_opts
self.include_plotlyjs = include_plotlyjs

def to_mimebundle(self, fig_dict):
from plotly.io import write_html
Expand Down Expand Up @@ -567,7 +573,7 @@ def to_mimebundle(self, fig_dict):
filename,
config=self.config,
auto_play=self.auto_play,
include_plotlyjs="directory",
include_plotlyjs=self.include_plotlyjs,
include_mathjax="cdn",
auto_open=False,
post_script=self.post_script,
Expand Down
3 changes: 2 additions & 1 deletion packages/python/plotly/plotly/io/_renderers.py
Expand Up @@ -423,7 +423,8 @@ def show(fig, renderer=None, validate=True, **kwargs):
renderers["firefox"] = BrowserRenderer(config=config, using="firefox")
renderers["chrome"] = BrowserRenderer(config=config, using="chrome")
renderers["chromium"] = BrowserRenderer(config=config, using="chromium")
renderers["iframe"] = IFrameRenderer(config=config)
renderers["iframe"] = IFrameRenderer(config=config, include_plotlyjs=True)
renderers["iframe_connected"] = IFrameRenderer(config=config, include_plotlyjs="cdn")

# Set default renderer
# --------------------
Expand Down

0 comments on commit 96569c4

Please sign in to comment.