From c342abf4bd12aeb7ac5ae6bbd583b16155c67867 Mon Sep 17 00:00:00 2001 From: yankev Date: Thu, 14 Apr 2016 21:56:35 -0400 Subject: [PATCH 1/5] changed the html code for plot functin vs iplot --- plotly/offline/offline.py | 40 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/plotly/offline/offline.py b/plotly/offline/offline.py index c11bcdb19b8..731a5163e18 100644 --- a/plotly/offline/offline.py +++ b/plotly/offline/offline.py @@ -73,7 +73,7 @@ def init_notebook_mode(): def _plot_html(figure_or_data, show_link, link_text, - validate, default_width, default_height): + validate, default_width, default_height, **kwargs): figure = tools.return_figure_from_figure_or_data(figure_or_data, validate) @@ -121,6 +121,42 @@ def _plot_html(figure_or_data, show_link, link_text, layout=jlayout, config=jconfig) + if kwargs and kwargs['browser']: + plotly_html_div = ( + '' + '
' + '
' + '' + '').format( + id=plotdivid, script=script, + height=height, width=width) + + return plotly_html_div, plotdivid, width, height + + else: + plotly_html_div = ( + '' + '
' + '
' + '' + '').format( + id=plotdivid, script=script, + height=height, width=width) + + return plotly_html_div, plotdivid, width, height + plotly_html_div = ( '' '
Date: Thu, 14 Apr 2016 22:36:17 -0400 Subject: [PATCH 2/5] shorter code --- plotly/offline/offline.py | 46 +++++++++------------------------------ 1 file changed, 10 insertions(+), 36 deletions(-) diff --git a/plotly/offline/offline.py b/plotly/offline/offline.py index 731a5163e18..8824f607b25 100644 --- a/plotly/offline/offline.py +++ b/plotly/offline/offline.py @@ -122,52 +122,26 @@ def _plot_html(figure_or_data, show_link, link_text, config=jconfig) if kwargs and kwargs['browser']: - plotly_html_div = ( - '' - '
' - '
' - '' - '').format( - id=plotdivid, script=script, - height=height, width=width) - - return plotly_html_div, plotdivid, width, height - + nb = False # function was not called from a notebook else: - plotly_html_div = ( - '' - '
' - '
' - '' - '').format( - id=plotdivid, script=script, - height=height, width=width) + nb = True + + # evaluate whether or not to include lines based on the nb - return plotly_html_div, plotdivid, width, height + optional_line1 = 'require(["plotly"], function(Plotly) {{ ' if nb else '' + optional_line2 = '}});' if nb else '' plotly_html_div = ( '' '
' '
' - '' '').format( id=plotdivid, script=script, From f0e7be4af28a2683398a174d8fd3206b20119ce4 Mon Sep 17 00:00:00 2001 From: yankev Date: Fri, 15 Apr 2016 11:20:28 -0400 Subject: [PATCH 3/5] changed kwargs to a single parameter --- plotly/offline/offline.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/plotly/offline/offline.py b/plotly/offline/offline.py index 8824f607b25..bd50e2115ba 100644 --- a/plotly/offline/offline.py +++ b/plotly/offline/offline.py @@ -73,7 +73,7 @@ def init_notebook_mode(): def _plot_html(figure_or_data, show_link, link_text, - validate, default_width, default_height, **kwargs): + validate, default_width, default_height, global_requirejs): figure = tools.return_figure_from_figure_or_data(figure_or_data, validate) @@ -121,15 +121,9 @@ def _plot_html(figure_or_data, show_link, link_text, layout=jlayout, config=jconfig) - if kwargs and kwargs['browser']: - nb = False # function was not called from a notebook - else: - nb = True - - # evaluate whether or not to include lines based on the nb - - optional_line1 = 'require(["plotly"], function(Plotly) {{ ' if nb else '' - optional_line2 = '}});' if nb else '' + optional_line1 = ('require(["plotly"], function(Plotly) {{ ' + if global_requirejs else '') + optional_line2 = '}});' if global_requirejs else '' plotly_html_div = ( '' @@ -199,7 +193,7 @@ def iplot(figure_or_data, show_link=True, link_text='Export to plot.ly', plot_html, plotdivid, width, height = _plot_html( figure_or_data, show_link, link_text, validate, - '100%', 525) + '100%', 525, global_requirejs=True) display(HTML(plot_html)) @@ -268,7 +262,7 @@ def plot(figure_or_data, plot_html, plotdivid, width, height = _plot_html( figure_or_data, show_link, link_text, validate, - '100%', '100%', browser=True) + '100%', '100%', global_requirejs=False) resize_script = '' if width == '100%' or height == '100%': From 59dc08ac9a270b3e725d383e31290ad240dcc067 Mon Sep 17 00:00:00 2001 From: yankev Date: Fri, 15 Apr 2016 12:10:23 -0400 Subject: [PATCH 4/5] updated changelog and version number --- CHANGELOG.md | 4 ++++ plotly/version.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12362f7d4e3..87d3622b1d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +## [1.9.9] - 2016-04-15 +### Fixed +- Fixed `require is not defined` issue when plotting offline outside of Ipython Notebooks. + ## [1.9.8] - 2016-04-14 ### Fixed - Error no longer results from a "Run All" cells when working in a Jupyter Notebook. diff --git a/plotly/version.py b/plotly/version.py index 2015c15a33c..80d6acd43b2 100644 --- a/plotly/version.py +++ b/plotly/version.py @@ -1 +1 @@ -__version__ = '1.9.8' +__version__ = '1.9.9' From fa4bb02e312575b9454522d5ef96c9ab093adc90 Mon Sep 17 00:00:00 2001 From: yankev Date: Fri, 15 Apr 2016 15:10:47 -0400 Subject: [PATCH 5/5] edited status of ternary plots --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87d3622b1d8..3e392ed00a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Updated - Updated plotly.min.js so offline is using plotly.js v1.9.0 - - Added Ternary plots with support for scatter traces (trace type `scatterternary`) + - Added Ternary plots with support for scatter traces (trace type `scatterternary`, currently only available in offline mode) - For comprehensive update list see the [plotly.js CHANGELOG](https://github.com/plotly/plotly.js/blob/master/CHANGELOG.md) ## [1.9.7] - 2016-04-04