Skip to content
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

plotly.io HTML functions, modular renderers framework, future flags system #1474

Merged
merged 48 commits into from
Apr 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
54c96fa
Initial plotly.io.renderers implementation
jonmmease Mar 16, 2019
8342680
rename 'default' to 'plotly_mimetype'
jonmmease Mar 16, 2019
2cc4f89
Added _repr_mimebundle_
jonmmease Mar 16, 2019
28a669c
Add initial browser renderer to show figure in browser tab
jonmmease Mar 16, 2019
8bf793f
Expose renderer base classes
jonmmease Mar 17, 2019
3dfb24a
Documentation / cleanup of _renderers
jonmmease Mar 17, 2019
2dd92c0
Auto-detect VSCode environment and default to renderer combination of
jonmmease Mar 18, 2019
953bae8
Documentation / cleanup of _base_renderers
jonmmease Mar 18, 2019
da39c34
Update default renderers explanation
jonmmease Mar 18, 2019
c2a6471
Add renderer docstring to repr for easy discoverability
jonmmease Mar 18, 2019
e6b9e45
Make ipython an optional dependency
jonmmease Mar 18, 2019
54ac011
Python 2.7 support
jonmmease Mar 18, 2019
7dc1029
Add parent <html></html. tags for HtmlRenderer with fullhtml=True
jonmmease Mar 18, 2019
c23f76e
Added initial renderers test suite
jonmmease Mar 18, 2019
a1d9d9e
Added IFrameRenderer
jonmmease Mar 19, 2019
9d082f0
Proper HTML tags for fullhtml
jonmmease Mar 19, 2019
b499b35
Added initial to_html functions to plotly.io
jonmmease Mar 19, 2019
63424a5
Reimplement plotly.offline.plot using plotly.io.write_html/to_div.
jonmmease Mar 19, 2019
28463c2
Reimplement plotly.offline.iplot and init_notebook_mode pio.show
jonmmease Mar 19, 2019
e4421bb
Add responsive=True config when figure width/height aren't set
jonmmease Mar 19, 2019
3b11783
Add MathJax configuration when initializing HTML renderer in notebook
jonmmease Mar 19, 2019
2580797
Reimplement HTML Renderers using the plotly.io html functions
jonmmease Mar 19, 2019
8a787fd
Restore plot/iplot image export by adding support for custom JS snippets
jonmmease Mar 20, 2019
c4cb4a7
Remove default renderer and make rendering figure on display an option
jonmmease Mar 20, 2019
a109f86
Update renderer tests with plotly.io.renderers.render_on_display
jonmmease Mar 20, 2019
f7f7cb7
Add download image plotly.offline.plot test
jonmmease Mar 20, 2019
f073a14
add set_v3_defaults and set_v4_defaults renderer methods to make
jonmmease Mar 20, 2019
1058683
Added future flag system under _plotly_future_ to control
jonmmease Mar 20, 2019
df3515e
Roll to_div function into to_html with full_html argument
jonmmease Mar 20, 2019
86eb69a
Rename SideEffectRenderer -> ExternalRenderer
jonmmease Mar 21, 2019
c209a18
Fix optional test suite
jonmmease Mar 23, 2019
19de7b9
Use correct config property to grab platform url from saved config
jonmmease Mar 23, 2019
ecf4867
Remove legacy unused _plot_html function
jonmmease Mar 23, 2019
b87ebed
Move static image renderer tests to orca test suite
jonmmease Mar 23, 2019
e11d74f
Move combination renderers test to orca test suite
jonmmease Mar 23, 2019
e8d2f1b
Remove remaining image renderer references from test_io
jonmmease Mar 23, 2019
de80ffc
Add ipython to orca environment for renderer tests
jonmmease Mar 23, 2019
7cba367
Remove pdf image from renderer tests since it seems to be non-determi…
jonmmease Mar 23, 2019
73752d7
Added chromium browser renderer
jonmmease Mar 26, 2019
8a0f6cc
Fix plotly mimetype renderer when used with numpy arrays/pandas Series
jonmmease Mar 26, 2019
504e342
Lazily initialize default renderers.
jonmmease Mar 26, 2019
1115608
Use 'browser' default renderer if ipython isn't available
jonmmease Mar 26, 2019
c647d70
Trigger notebook renderer activation on `init_notebook_mode` call
jonmmease Apr 8, 2019
839f257
Remove whitespace between method calls
jonmmease Apr 9, 2019
18f36b9
review cleanup
jonmmease Apr 9, 2019
5c02ded
simplify to_html logic path
jonmmease Apr 9, 2019
95e2724
Review / cleanup of new renderers
jonmmease Apr 9, 2019
99769cc
Fix json renderer tests
jonmmease Apr 9, 2019
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
2 changes: 1 addition & 1 deletion .circleci/create_conda_optional_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if [ ! -d $HOME/miniconda/envs/circle_optional ]; then
# Create environment
# PYTHON_VERSION=3.6
$HOME/miniconda/bin/conda create -n circle_optional --yes python=$PYTHON_VERSION \
requests six pytz retrying psutil pandas decorator pytest mock nose poppler xarray scikit-image
requests six pytz retrying psutil pandas decorator pytest mock nose poppler xarray scikit-image ipython

# Install orca into environment
$HOME/miniconda/bin/conda install --yes -n circle_optional -c plotly plotly-orca
Expand Down
8 changes: 8 additions & 0 deletions _plotly_future_/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
_future_flags = set()


def _assert_plotly_not_imported():
import sys
if 'plotly' in sys.modules:
raise ImportError("""\
The _plotly_future_ module must be imported before the plotly module""")
5 changes: 5 additions & 0 deletions _plotly_future_/renderer_defaults.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from __future__ import absolute_import
from _plotly_future_ import _future_flags, _assert_plotly_not_imported

_assert_plotly_not_imported()
_future_flags.add('renderer_defaults')
5 changes: 5 additions & 0 deletions _plotly_future_/template_defaults.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from __future__ import absolute_import
from _plotly_future_ import _future_flags, _assert_plotly_not_imported

_assert_plotly_not_imported()
_future_flags.add('template_defaults')
2 changes: 2 additions & 0 deletions _plotly_future_/v4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from __future__ import absolute_import
from _plotly_future_ import renderer_defaults, template_defaults
6 changes: 6 additions & 0 deletions plotly/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@
from plotly import (plotly, dashboard_objs, graph_objs, grid_objs, tools,
utils, session, offline, colors, io)
from plotly.version import __version__
from _plotly_future_ import _future_flags

from ._version import get_versions
__version__ = get_versions()['version']
del get_versions

# Set default template here to make sure import process is complete
if 'template_defaults' in _future_flags:
# Set _default to skip validation
io.templates._default = 'plotly'
16 changes: 16 additions & 0 deletions plotly/basedatatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,22 @@ def __repr__(self):

return repr_str

def _repr_mimebundle_(self, include, exclude, **kwargs):
"""
repr_mimebundle should accept include, exclude and **kwargs
"""
import plotly.io as pio
if pio.renderers.render_on_display:
data = pio.renderers._build_mime_bundle(self.to_dict())

if include:
data = {k: v for (k, v) in data.items() if k in include}
if exclude:
data = {k: v for (k, v) in data.items() if k not in exclude}
return data
else:
return None

def update(self, dict1=None, **kwargs):
"""
Update the properties of the figure with a dict and/or with
Expand Down
6 changes: 6 additions & 0 deletions plotly/io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@
from ._json import to_json, from_json, read_json, write_json

from ._templates import templates, to_templated

from ._renderers import renderers, show

from . import base_renderers

from ._html import to_html, write_html
Loading