Skip to content

Fix for 1.9.8 offline plotting issue #440

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ 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.

### 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
Expand Down
18 changes: 11 additions & 7 deletions plotly/offline/offline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, global_requirejs):

figure = tools.return_figure_from_figure_or_data(figure_or_data, validate)

Expand Down Expand Up @@ -121,17 +121,21 @@ def _plot_html(figure_or_data, show_link, link_text,
layout=jlayout,
config=jconfig)

optional_line1 = ('require(["plotly"], function(Plotly) {{ '
if global_requirejs else '')
optional_line2 = '}});' if global_requirejs else ''

plotly_html_div = (
''
'<div id="{id}" style="height: {height}; width: {width};" '
'class="plotly-graph-div">'
'</div>'
'<script type="text/javascript">'
'require(["plotly"], function(Plotly) {{'
'<script type="text/javascript">' +
optional_line1 +
'window.PLOTLYENV=window.PLOTLYENV || {{}};'
'window.PLOTLYENV.BASE_URL="' + plotly_platform_url + '";'
'{script}'
'}});'
'{script}' +
optional_line2 +
'</script>'
'').format(
id=plotdivid, script=script,
Expand Down Expand Up @@ -189,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))

Expand Down Expand Up @@ -258,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%')
'100%', '100%', global_requirejs=False)

resize_script = ''
if width == '100%' or height == '100%':
Expand Down
2 changes: 1 addition & 1 deletion plotly/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.9.8'
__version__ = '1.9.9'