Skip to content

Commit

Permalink
issue #399 fix
Browse files Browse the repository at this point in the history
You can now enter in a dictionary for all the options you want using
the parameter ‘config’.
(cherry picked from commit ecfe1fb)
  • Loading branch information
yankev authored and Hendrik Schröter committed Oct 24, 2016
1 parent 3434aeb commit 4420d79
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions plotly/offline/offline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand Down

1 comment on commit 4420d79

@eulerreich
Copy link

Choose a reason for hiding this comment

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

I'm getting the error
_plot_html() got multiple values for keyword argument 'global_requirejs'
when I run offline.iplot because the signature for _plot_html changed here.
Checking out commit 3434aeb gets rid of the error.

Please sign in to comment.