From 32f008004b056c85f764c06a6973740fa61d6ef4 Mon Sep 17 00:00:00 2001 From: yankev Date: Thu, 18 Feb 2016 14:24:44 -0500 Subject: [PATCH 1/3] fix --- plotly/graph_reference/default-schema.json | 26 +++--- plotly/offline/offline.py | 35 ++++++-- plotly/temp-plot.html | 92 ++++++++++++++++++++++ 3 files changed, 134 insertions(+), 19 deletions(-) create mode 100644 plotly/temp-plot.html diff --git a/plotly/graph_reference/default-schema.json b/plotly/graph_reference/default-schema.json index adff88bc8f5..6218fde4659 100644 --- a/plotly/graph_reference/default-schema.json +++ b/plotly/graph_reference/default-schema.json @@ -4405,7 +4405,7 @@ } }, "colorscale": { - "description": "Has only an effect if `marker.color` is set to a numerical array. Sets the colorscale.", + "description": "Sets the colorscale. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use cmin and cmax", "role": "style", "valType": "colorscale" }, @@ -5594,7 +5594,7 @@ } }, "colorscale": { - "description": "Sets the colorscale.", + "description": "Sets the colorscale. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in z space, use zmin and zmax", "role": "style", "valType": "colorscale" }, @@ -6134,7 +6134,7 @@ } }, "colorscale": { - "description": "Sets the colorscale.", + "description": "Sets the colorscale. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in z space, use zmin and zmax", "role": "style", "valType": "colorscale" }, @@ -6781,7 +6781,7 @@ } }, "colorscale": { - "description": "Sets the colorscale.", + "description": "Sets the colorscale. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in z space, use zmin and zmax", "role": "style", "valType": "colorscale" }, @@ -7660,7 +7660,7 @@ } }, "colorscale": { - "description": "Has only an effect if `marker.color` is set to a numerical array. Sets the colorscale.", + "description": "Sets the colorscale. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use cmin and cmax", "role": "style", "valType": "colorscale" }, @@ -8307,7 +8307,7 @@ } }, "colorscale": { - "description": "Sets the colorscale.", + "description": "Sets the colorscale. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in z space, use zmin and zmax", "role": "style", "valType": "colorscale" }, @@ -8933,7 +8933,7 @@ } }, "colorscale": { - "description": "Sets the colorscale.", + "description": "Sets the colorscale. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in z space, use zmin and zmax", "role": "style", "valType": "colorscale" }, @@ -9617,7 +9617,7 @@ } }, "colorscale": { - "description": "Sets the colorscale.", + "description": "Sets the colorscale. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in z space, use zmin and zmax", "role": "style", "valType": "colorscale" }, @@ -10933,7 +10933,7 @@ } }, "colorscale": { - "description": "Has only an effect if `marker.color` is set to a numerical array. Sets the colorscale.", + "description": "Sets the colorscale. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use cmin and cmax", "role": "style", "valType": "colorscale" }, @@ -12308,7 +12308,7 @@ } }, "colorscale": { - "description": "Has only an effect if `marker.color` is set to a numerical array. Sets the colorscale.", + "description": "Sets the colorscale. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use cmin and cmax", "role": "style", "valType": "colorscale" }, @@ -13197,7 +13197,7 @@ } }, "colorscale": { - "description": "Has only an effect if `marker.color` is set to a numerical array. Sets the colorscale.", + "description": "Sets the colorscale. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use cmin and cmax", "role": "style", "valType": "colorscale" }, @@ -14428,7 +14428,7 @@ } }, "colorscale": { - "description": "Has only an effect if `marker.color` is set to a numerical array. Sets the colorscale.", + "description": "Sets the colorscale. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use cmin and cmax", "role": "style", "valType": "colorscale" }, @@ -15053,7 +15053,7 @@ } }, "colorscale": { - "description": "Sets the colorscale.", + "description": "Sets the colorscale. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in z space, use zmin and zmax", "role": "style", "valType": "colorscale" }, diff --git a/plotly/offline/offline.py b/plotly/offline/offline.py index f2153b94e80..79a392eb6b6 100644 --- a/plotly/offline/offline.py +++ b/plotly/offline/offline.py @@ -72,7 +72,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, **config_options): figure = tools.return_figure_from_figure_or_data(figure_or_data, validate) @@ -97,9 +97,32 @@ def _plot_html(figure_or_data, show_link, link_text, jdata = json.dumps(figure.get('data', []), cls=utils.PlotlyJSONEncoder) jlayout = json.dumps(figure.get('layout', {}), cls=utils.PlotlyJSONEncoder) - config = {} + configkeys = ( + 'editable', + 'autosizable', + 'fillFrame', + 'frameMargins', + 'scrollZoom', + 'doubleClick', + 'showTips', + 'showLink', + 'sendData', + 'linkText', + 'showSources', + 'displayModeBar', + 'modeBarButtonsToRemove', + 'modeBarButtonsToAdd', + 'modeBarButtons', + 'displaylogo', + 'plotGlPixelRatio', + 'setBackground', + 'topojsonURL') + + config = (dict((k, config_options[k]) for k in config_options + if k in configkeys)) config['showLink'] = show_link config['linkText'] = link_text + jconfig = json.dumps(config) # TODO: The get_config 'source of truth' should @@ -138,7 +161,7 @@ def _plot_html(figure_or_data, show_link, link_text, def iplot(figure_or_data, show_link=True, link_text='Export to plot.ly', - validate=True): + validate=True, **config_options): """ Draw plotly graphs inside an IPython notebook without connecting to an external server. @@ -186,7 +209,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, **config_options) display(HTML(plot_html)) @@ -196,7 +219,7 @@ def plot(figure_or_data, validate=True, output_type='file', include_plotlyjs=True, filename='temp-plot.html', - auto_open=True): + auto_open=True, **config_options): """ Create a plotly graph locally as an HTML document or string. Example: @@ -255,7 +278,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%', **config_options) figure = tools.return_figure_from_figure_or_data(figure_or_data, validate) diff --git a/plotly/temp-plot.html b/plotly/temp-plot.html new file mode 100644 index 00000000000..ace3c3dc51b --- /dev/null +++ b/plotly/temp-plot.html @@ -0,0 +1,92 @@ +
\ No newline at end of file From 68d7c18d9cbfab9c7fd20cdd256f49832857ad22 Mon Sep 17 00:00:00 2001 From: yankev Date: Thu, 18 Feb 2016 14:47:01 -0500 Subject: [PATCH 2/3] added space to comply with get_embed() result --- .../test_core/test_tools/test_get_embed.py | 2 +- temp-plot.html | 92 +++++++++++++++++++ 2 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 temp-plot.html diff --git a/plotly/tests/test_core/test_tools/test_get_embed.py b/plotly/tests/test_core/test_tools/test_get_embed.py index 33a210a3b57..6b23f3aed7b 100644 --- a/plotly/tests/test_core/test_tools/test_get_embed.py +++ b/plotly/tests/test_core/test_tools/test_get_embed.py @@ -28,7 +28,7 @@ def test_get_embed_url_with_share_key(self): get_embed_return = tls.get_embed('https://plot.ly/~neda/6572' + '?share_key=AH4MyPlyDyDWYA2cM2kj2m') expected_get_embed = ("