From e41ed94ee35a243db72e30ebcd0cc9ea4a305a98 Mon Sep 17 00:00:00 2001 From: Jon Mease Date: Sun, 2 Sep 2018 05:57:47 -0400 Subject: [PATCH 1/2] Fix JavaScript `Error: addFrames failure` in offline html export --- plotly/offline/offline.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plotly/offline/offline.py b/plotly/offline/offline.py index 44e75b53ce7..d95406f4c0a 100644 --- a/plotly/offline/offline.py +++ b/plotly/offline/offline.py @@ -174,9 +174,9 @@ def _plot_html(figure_or_data, config, validate, default_width, jdata = _json.dumps(figure.get('data', []), cls=utils.PlotlyJSONEncoder) jlayout = _json.dumps(figure.get('layout', {}), cls=utils.PlotlyJSONEncoder) - if 'frames' in figure_or_data: - jframes = _json.dumps(figure.get('frames', {}), - cls=utils.PlotlyJSONEncoder) + + jframes = _json.dumps(figure.get('frames', []), + cls=utils.PlotlyJSONEncoder) configkeys = ( 'staticPlot', @@ -229,7 +229,7 @@ def _plot_html(figure_or_data, config, validate, default_width, config['linkText'] = link_text jconfig = jconfig.replace('Export to plot.ly', link_text) - if 'frames' in figure_or_data: + if jframes: script = ''' Plotly.plot( '{id}', From 1513d2217a77a2b1667d53bb67cf1428f4202a5a Mon Sep 17 00:00:00 2001 From: Jon Mease Date: Sun, 2 Sep 2018 06:25:55 -0400 Subject: [PATCH 2/2] Empty list JSON serializes to '[]' which is not Falsey --- plotly/offline/offline.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plotly/offline/offline.py b/plotly/offline/offline.py index d95406f4c0a..1ba236596a9 100644 --- a/plotly/offline/offline.py +++ b/plotly/offline/offline.py @@ -175,8 +175,11 @@ def _plot_html(figure_or_data, config, validate, default_width, jlayout = _json.dumps(figure.get('layout', {}), cls=utils.PlotlyJSONEncoder) - jframes = _json.dumps(figure.get('frames', []), - cls=utils.PlotlyJSONEncoder) + if figure.get('frames', None): + jframes = _json.dumps(figure.get('frames', []), + cls=utils.PlotlyJSONEncoder) + else: + jframes = None configkeys = ( 'staticPlot',