Skip to content

Add Plotly custom mimetype to NB outputs. #713

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 3 commits into from
Mar 20, 2017
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## [2.0.6] - 2017-03-20
## Added
- Added a new mimetype 'text/vnd.plotly.v1+html' for `iplot` outputs.

## [2.0.5] - 2017-03-07
## Fixed
- `import plotly` was broken in `2.0.3` and `2.0.2` because the new `dashboard_objs` wasn't included in our `setup.py`'s "`packages`". Now it is and `import plotly` and the other features introduced in `2.0.3` and `2.0.2` should work.
Expand Down
40 changes: 28 additions & 12 deletions plotly/graph_objs/graph_objs.py
Original file line number Diff line number Diff line change
Expand Up @@ -983,9 +983,9 @@ class Data(PlotlyList):
Valid items for 'data' at path [] under parents ():
['Area', 'Bar', 'Box', 'Candlestick', 'Choropleth', 'Contour',
'Heatmap', 'Heatmapgl', 'Histogram', 'Histogram2d',
'Histogram2dcontour', 'Mesh3d', 'Ohlc', 'Pie', 'Pointcloud', 'Scatter',
'Scatter3d', 'Scattergeo', 'Scattergl', 'Scattermapbox',
'Scatterternary', 'Surface']
'Histogram2dcontour', 'Mesh3d', 'Ohlc', 'Parcoords', 'Pie',
'Pointcloud', 'Scatter', 'Scatter3d', 'Scattergeo', 'Scattergl',
'Scattermapbox', 'Scatterternary', 'Surface']

"""
_name = 'data'
Expand Down Expand Up @@ -1416,9 +1416,10 @@ class Line(PlotlyDict):
"""
Valid attributes for 'line' at path [] under parents ():

['autocolorscale', 'cauto', 'cmax', 'cmin', 'color', 'colorscale',
'colorsrc', 'dash', 'outliercolor', 'outlierwidth', 'reversescale',
'shape', 'showscale', 'simplify', 'smoothing', 'width', 'widthsrc']
['autocolorscale', 'cauto', 'cmax', 'cmin', 'color', 'colorbar',
'colorscale', 'colorsrc', 'dash', 'outliercolor', 'outlierwidth',
'reversescale', 'shape', 'showscale', 'simplify', 'smoothing', 'width',
'widthsrc']

Run `<line-object>.help('attribute')` on any of the above.
'<line-object>' is the object at []
Expand Down Expand Up @@ -1494,6 +1495,20 @@ class Ohlc(PlotlyDict):
_name = 'ohlc'


class Parcoords(PlotlyDict):
"""
Valid attributes for 'parcoords' at path [] under parents ():

['dimensions', 'domain', 'hoverinfo', 'legendgroup', 'line', 'name',
'opacity', 'showlegend', 'stream', 'type', 'uid', 'visible']

Run `<parcoords-object>.help('attribute')` on any of the above.
'<parcoords-object>' is the object at []

"""
_name = 'parcoords'


class Pie(PlotlyDict):
"""
Valid attributes for 'pie' at path [] under parents ():
Expand Down Expand Up @@ -1547,12 +1562,13 @@ class Scatter(PlotlyDict):
"""
Valid attributes for 'scatter' at path [] under parents ():

['connectgaps', 'dx', 'dy', 'error_x', 'error_y', 'fill', 'fillcolor',
'hoverinfo', 'hoveron', 'ids', 'idssrc', 'legendgroup', 'line',
'marker', 'mode', 'name', 'opacity', 'r', 'rsrc', 'showlegend',
'stream', 't', 'text', 'textfont', 'textposition', 'textpositionsrc',
'textsrc', 'tsrc', 'type', 'uid', 'visible', 'x', 'x0', 'xaxis',
'xcalendar', 'xsrc', 'y', 'y0', 'yaxis', 'ycalendar', 'ysrc']
['connectgaps', 'customdata', 'customdatasrc', 'dx', 'dy', 'error_x',
'error_y', 'fill', 'fillcolor', 'hoverinfo', 'hoveron', 'ids',
'idssrc', 'legendgroup', 'line', 'marker', 'mode', 'name', 'opacity',
'r', 'rsrc', 'showlegend', 'stream', 't', 'text', 'textfont',
'textposition', 'textpositionsrc', 'textsrc', 'tsrc', 'type', 'uid',
'visible', 'x', 'x0', 'xaxis', 'xcalendar', 'xsrc', 'y', 'y0', 'yaxis',
'ycalendar', 'ysrc']

Run `<scatter-object>.help('attribute')` on any of the above.
'<scatter-object>' is the object at []
Expand Down
9 changes: 7 additions & 2 deletions plotly/offline/offline.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,11 @@ def init_notebook_mode(connected=False):
'</script>'
'').format(script=get_plotlyjs())

ipython_display.display(ipython_display.HTML(script_inject))
display_bundle = {
'text/html': script_inject,
'text/vnd.plotly.v1+html': script_inject
}
ipython_display.display(display_bundle, raw=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why raw=True?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kully :

From IPython Docs:

raw : bool
Are the data objects raw data or Python objects that need to be formatted before display? [default: False]

We dont want IPython to do any further processing on this, so we use raw=True.

__PLOTLY_OFFLINE_INITIALIZED = True


Expand Down Expand Up @@ -346,7 +350,8 @@ def iplot(figure_or_data, show_link=True, link_text='Export to plot.ly',
cls=plotly.utils.PlotlyJSONEncoder))
display_bundle = {
'application/vnd.plotly.v1+json': {'data': data, 'layout': layout},
'text/html': plot_html
'text/html': plot_html,
'text/vnd.plotly.v1+html': plot_html
}
ipython_display.display(display_bundle, raw=True)

Expand Down
Loading