diff --git a/plotly/widgets/graph_widget.py b/plotly/widgets/graph_widget.py index 453b92884ae..0605e08b1cf 100644 --- a/plotly/widgets/graph_widget.py +++ b/plotly/widgets/graph_widget.py @@ -9,8 +9,19 @@ import plotly +# Load JS widget code +# No officially recommended way to do this in any other way +# http://mail.scipy.org/pipermail/ipython-dev/2014-April/013835.html +directory = os.path.dirname(os.path.realpath(__file__)) +js_widget_file = os.path.join(directory, 'graphWidget.js') +with open(js_widget_file) as f: + js_widget_code = f.read() + +display(Javascript(js_widget_code)) + __all__ = None + class Graph(widgets.DOMWidget): """An interactive Plotly graph widget for use in IPython Notebooks. @@ -29,13 +40,6 @@ def __init__(self, graph_url, **kwargs): -------- GraphWidget('https://plot.ly/~chris/3375') """ - directory = os.path.dirname(os.path.realpath(__file__)) - js_widget_file = os.path.join(directory, 'graphWidget.js') - with open(js_widget_file) as f: - js_widget_code = f.read() - - display(Javascript(js_widget_code)) - super(Graph, self).__init__(**kwargs) # TODO: Validate graph_url