From 4420d794ed58f31cd2c3a1f13558a9e9da798335 Mon Sep 17 00:00:00 2001 From: yankev Date: Mon, 15 Feb 2016 21:50:52 +0100 Subject: [PATCH] issue #399 fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit You can now enter in a dictionary for all the options you want using the parameter ‘config’. (cherry picked from commit ecfe1fb) --- plotly/offline/offline.py | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/plotly/offline/offline.py b/plotly/offline/offline.py index e06f28c27a..247e482143 100644 --- a/plotly/offline/offline.py +++ b/plotly/offline/offline.py @@ -160,8 +160,8 @@ def init_notebook_mode(connected=False): __PLOTLY_OFFLINE_INITIALIZED = True -def _plot_html(figure_or_data, show_link, link_text, validate, - default_width, default_height, global_requirejs): +def _plot_html(figure_or_data, config, validate, default_width, + default_height, global_requirejs): figure = tools.return_figure_from_figure_or_data(figure_or_data, validate) @@ -186,10 +186,30 @@ def _plot_html(figure_or_data, show_link, link_text, validate, jdata = json.dumps(figure.get('data', []), cls=utils.PlotlyJSONEncoder) jlayout = json.dumps(figure.get('layout', {}), cls=utils.PlotlyJSONEncoder) - config = {} - config['showLink'] = show_link - config['linkText'] = link_text - jconfig = json.dumps(config) + configkeys = ( + 'editable', + 'autosizable', + 'fillFrame', + 'frameMargins', + 'scrollZoom', + 'doubleClick', + 'showTips', + 'showLink', + 'sendData', + 'linkText', + 'showSources', + 'displayModeBar', + 'modeBarButtonsToRemove', + 'modeBarButtonsToAdd', + 'modeBarButtons', + 'displaylogo', + 'plotGlPixelRatio', + 'setBackground', + 'topojsonURL') + + config_clean = dict((k,config[k]) for k in configkeys if k in config) + + jconfig = json.dumps(config_clean) # TODO: The get_config 'source of truth' should # really be somewhere other than plotly.plotly