Skip to content

Updating cdn-options PR #492

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
May 31, 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
80 changes: 80 additions & 0 deletions plotly/graph_reference/default-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -11230,20 +11230,31 @@
},
"lighting": {
"ambient": {
"description": "Ambient light increases overall color visibility but can wash out the image.",
"dflt": 0.8,
"max": 1,
"min": 0,
"role": "style",
"valType": "number"
},
"diffuse": {
"description": "Represents the extent that incident rays are reflected in a range of angles.",
"dflt": 0.8,
"max": 1,
"min": 0,
"role": "style",
"valType": "number"
},
"facenormalsepsilon": {
"description": "Epsilon for face normals calculation avoids math issues arising from degenerate geometry.",
"dflt": 1e-06,
"max": 1,
"min": 0,
"role": "style",
"valType": "number"
},
"fresnel": {
"description": "Represents the reflectance as a dependency of the viewing angle; e.g. paper is reflective when viewing it from the edge of the paper (almost 90 degrees), causing shine.",
"dflt": 0.2,
"max": 5,
"min": 0,
Expand All @@ -11252,18 +11263,55 @@
},
"role": "object",
"roughness": {
"description": "Alters specular reflection; the rougher the surface, the wider and less contrasty the shine.",
"dflt": 0.5,
"max": 1,
"min": 0,
"role": "style",
"valType": "number"
},
"specular": {
"description": "Represents the level that incident rays are reflected in a single direction, causing shine.",
"dflt": 0.05,
"max": 2,
"min": 0,
"role": "style",
"valType": "number"
},
"vertexnormalsepsilon": {
"description": "Epsilon for vertex normals calculation avoids math issues arising from degenerate geometry.",
"dflt": 1e-12,
"max": 1,
"min": 0,
"role": "style",
"valType": "number"
}
},
"lightposition": {
"role": "object",
"x": {
"description": "Numeric vector, representing the X coordinate for each vertex.",
"dflt": 100000,
"max": 100000,
"min": -100000,
"role": "style",
"valType": "number"
},
"y": {
"description": "Numeric vector, representing the Y coordinate for each vertex.",
"dflt": 100000,
"max": 100000,
"min": -100000,
"role": "style",
"valType": "number"
},
"z": {
"description": "Numeric vector, representing the Z coordinate for each vertex.",
"dflt": 0,
"max": 100000,
"min": -100000,
"role": "style",
"valType": "number"
}
},
"name": {
Expand Down Expand Up @@ -17937,20 +17985,23 @@
},
"lighting": {
"ambient": {
"description": "Ambient light increases overall color visibility but can wash out the image.",
"dflt": 0.8,
"max": 1,
"min": 0,
"role": "style",
"valType": "number"
},
"diffuse": {
"description": "Represents the extent that incident rays are reflected in a range of angles.",
"dflt": 0.8,
"max": 1,
"min": 0,
"role": "style",
"valType": "number"
},
"fresnel": {
"description": "Represents the reflectance as a dependency of the viewing angle; e.g. paper is reflective when viewing it from the edge of the paper (almost 90 degrees), causing shine.",
"dflt": 0.2,
"max": 5,
"min": 0,
Expand All @@ -17959,20 +18010,49 @@
},
"role": "object",
"roughness": {
"description": "Alters specular reflection; the rougher the surface, the wider and less contrasty the shine.",
"dflt": 0.5,
"max": 1,
"min": 0,
"role": "style",
"valType": "number"
},
"specular": {
"description": "Represents the level that incident rays are reflected in a single direction, causing shine.",
"dflt": 0.05,
"max": 2,
"min": 0,
"role": "style",
"valType": "number"
}
},
"lightposition": {
"role": "object",
"x": {
"description": "Numeric vector, representing the X coordinate for each vertex.",
"dflt": 10,
"max": 100000,
"min": -100000,
"role": "style",
"valType": "number"
},
"y": {
"description": "Numeric vector, representing the Y coordinate for each vertex.",
"dflt": 100000,
"max": 100000,
"min": -100000,
"role": "style",
"valType": "number"
},
"z": {
"description": "Numeric vector, representing the Z coordinate for each vertex.",
"dflt": 0,
"max": 100000,
"min": -100000,
"role": "style",
"valType": "number"
}
},
"name": {
"description": "Sets the trace name. The trace name appear as the legend item and on hover.",
"role": "info",
Expand Down
27 changes: 22 additions & 5 deletions plotly/offline/offline.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
_matplotlib_imported = False

__PLOTLY_OFFLINE_INITIALIZED = False
__PLOTLY_USE_CDN = False


def download_plotlyjs(download_url):
Expand All @@ -53,14 +52,31 @@ def init_notebook_mode(connected=False):
Initialize plotly.js in the browser if it hasn't been loaded into the DOM
yet. This is an idempotent method and can and should be called from any
offline methods that require plotly.js to be loaded into the notebook dom.

Keyword arguments:

connected (default=False) -- If True, the plotly.js library will be loaded
from an online CDN. If False, the plotly.js library will be loaded locally
from the plotly python package

Use `connected=True` if you want your notebooks to have smaller file sizes.
In the case where `connected=False`, the entirety of the plotly.js library
will be loaded into the notebook, which will result in a file-size increase
of a couple megabytes. Additionally, because the library will be downloaded
from the web, you and your viewers must be connected to the internet to be
able to view charts within this notebook.

Use `connected=False` if you want you and your collaborators to be able to
create and view these charts regardless of the availability of an internet
connection. This is the default option since it is the most predictable.
Note that under this setting the library will be included inline inside
your notebook, resulting in much larger notebook sizes compared to the case
where `connected=True`.
"""
if not _ipython_imported:
raise ImportError('`iplot` can only run inside an IPython Notebook.')

global __PLOTLY_OFFLINE_INITIALIZED
global __PLOTLY_USE_CDN

__PLOTLY_USE_CDN = connected

if connected:
# Inject plotly.js into the output cell
Expand All @@ -69,14 +85,15 @@ def init_notebook_mode(connected=False):
'<script>'
'requirejs.config({'
'paths: { '
# Note we omit the extension .js because require will include it.
'\'plotly\': [\'https://cdn.plot.ly/plotly-latest.min\']},'
'});'
'if(!window.Plotly) {{'
'require([\'plotly\'],'
'function(plotly) {window.Plotly=plotly;});'
'}}'
'</script>'
)
)
else:
# Inject plotly.js into the output cell
script_inject = (
Expand Down