Skip to content

Commit 941e3b3

Browse files
committed
Modifications following review
1 parent 636869e commit 941e3b3

File tree

3 files changed

+23
-121
lines changed

3 files changed

+23
-121
lines changed

examples/introduction.ipynb

Lines changed: 17 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -23,82 +23,18 @@
2323
"metadata": {},
2424
"outputs": [],
2525
"source": [
26-
"from bokeh.io import push_notebook, show, output_notebook\n",
27-
"from bokeh.resources import INLINE\n",
28-
"from bokeh.layouts import row\n",
29-
"from bokeh.plotting import figure\n",
30-
"output_notebook(resources=INLINE)\n",
31-
"opts = dict(plot_width=250, plot_height=250, min_border=0)"
32-
]
33-
},
34-
{
35-
"cell_type": "code",
36-
"execution_count": null,
37-
"metadata": {},
38-
"outputs": [],
39-
"source": [
40-
"p1 = figure(**opts)\n",
41-
"r1 = p1.circle([1,2,3], [4,5,6], size=20)\n",
42-
"\n",
43-
"p2 = figure(**opts)\n",
44-
"r2 = p2.circle([1,2,3], [4,5,6], size=20)"
45-
]
46-
},
47-
{
48-
"cell_type": "code",
49-
"execution_count": null,
50-
"metadata": {},
51-
"outputs": [],
52-
"source": [
53-
"sr = Sidecar(title='Main Sidecar')\n",
54-
"with sr:\n",
55-
" # get a handle to update the shown cell with\n",
56-
" t = show(row(p1, p2), notebook_handle=True)"
57-
]
58-
},
59-
{
60-
"cell_type": "code",
61-
"execution_count": null,
62-
"metadata": {},
63-
"outputs": [],
64-
"source": [
65-
"r1.glyph.fill_color = \"white\"\n",
66-
"push_notebook(handle=t)"
67-
]
68-
},
69-
{
70-
"cell_type": "code",
71-
"execution_count": null,
72-
"metadata": {},
73-
"outputs": [],
74-
"source": [
75-
"sc = Sidecar(title='Right Sidecar', anchor='right')\n",
26+
"sc = Sidecar(title='Sidecar Output')\n",
7627
"sl = IntSlider(description='Some slider')\n",
28+
"\n",
7729
"with sc:\n",
7830
" display(sl)"
7931
]
8032
},
8133
{
82-
"cell_type": "code",
83-
"execution_count": null,
34+
"cell_type": "markdown",
8435
"metadata": {},
85-
"outputs": [],
8636
"source": [
87-
"import plotly\n",
88-
"import plotly.graph_objs as go\n",
89-
"import plotly.tools as tls\n",
90-
"from IPython.display import display\n",
91-
"\n",
92-
"import pandas as pd\n",
93-
"# dataset = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/diabetes.csv')\n",
94-
"dataset = pd.read_csv('diabetes.csv')\n",
95-
"\n",
96-
"subplot = tls.make_subplots(2, 2, print_grid=False)\n",
97-
"f2 = go.FigureWidget(subplot)\n",
98-
"\n",
99-
"sl = Sidecar(title='Main Sidecar')\n",
100-
"with sl:\n",
101-
" display(f2)"
37+
"# Sidecar as main area panel"
10238
]
10339
},
10440
{
@@ -107,56 +43,25 @@
10743
"metadata": {},
10844
"outputs": [],
10945
"source": [
110-
"# Use add_trace method with optional row/col parameters\n",
111-
"f2.add_trace(go.Scatter(x=dataset['Age'], y=dataset['Pregnancies'], mode='markers'), row=1, col=1)\n",
112-
"\n",
113-
"# Use add_traces with optional rows/cols parameters\n",
114-
"f2.add_traces([\n",
115-
" go.Scatter(x=dataset['Age'], y=dataset['BMI'], mode='markers'),\n",
116-
" go.Scatter(x=dataset['Age'], y=dataset['SkinThickness'], mode='markers')],\n",
117-
" rows=[1, 2], cols=[2, 1]\n",
118-
")\n",
119-
"\n",
120-
"# Use add_scatter with optional row/col parameters\n",
121-
"f2.add_scatter(x=dataset['Age'], y=dataset['BloodPressure'], mode='markers', row=2, col=2)\n",
46+
"sl = IntSlider(description='Some slider')\n",
12247
"\n",
123-
"f2.layout.title = 'Age and Diabetes Factors'"
48+
"with Sidecar(title='Sidecar Output Main', anchor='split-right'):\n",
49+
" display(sl)"
12450
]
12551
},
12652
{
127-
"cell_type": "code",
128-
"execution_count": null,
53+
"cell_type": "markdown",
12954
"metadata": {},
130-
"outputs": [],
13155
"source": [
132-
"import numpy as np\n",
133-
"data = [dict(\n",
134-
" visible = False,\n",
135-
" line=dict(color='#00CED1', width=6),\n",
136-
" name = '𝜈 = '+str(step),\n",
137-
" x = np.arange(0,10,0.01),\n",
138-
" y = np.sin(step*np.arange(0,10,0.01))) for step in np.arange(0,5,0.1)]\n",
139-
"data[10]['visible'] = True\n",
140-
"\n",
141-
"steps = []\n",
142-
"for i in range(len(data)):\n",
143-
" step = dict(\n",
144-
" method = 'restyle', \n",
145-
" args = ['visible', [False] * len(data)],\n",
146-
" )\n",
147-
" step['args'][1][i] = True # Toggle i'th trace to \"visible\"\n",
148-
" steps.append(step)\n",
149-
"\n",
150-
"sliders = [dict(\n",
151-
" active = 10,\n",
152-
" currentvalue = {\"prefix\": \"Frequency: \"},\n",
153-
" pad = {\"t\": 50},\n",
154-
" steps = steps\n",
155-
")]\n",
156-
"\n",
157-
"layout = dict(sliders=sliders)\n",
56+
"`anchor` can take one of the following value: \n",
15857
"\n",
159-
"go.FigureWidget(data, layout)"
58+
"- 'split-right': main panel right of the notebook,\n",
59+
"- 'split-left': main panel left of the notebook,\n",
60+
"- 'split-top': main panel above the notebook,\n",
61+
"- 'split-bottom': main panel below the notebook, \n",
62+
"- 'tab-before': main panel stacked before the tab notebook,\n",
63+
"- 'tab-after': main panel stacked after the tab notebook,\n",
64+
"- 'right': [default] right sidebar panel."
16065
]
16166
}
16267
],
@@ -181,4 +86,4 @@
18186
},
18287
"nbformat": 4,
18388
"nbformat_minor": 2
184-
}
89+
}

sidecar/sidecar.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,8 @@ class Sidecar(Output):
2323
_view_module = Unicode(module_name).tag(sync=True)
2424
_view_module_version = Unicode(EXTENSION_SPEC_VERSION).tag(sync=True)
2525
title = Unicode('Sidecar').tag(sync=True)
26-
anchor = CaselessStrEnum(['split-right', 'split-left', 'split-top', 'split-bottom', 'tab-before', 'tab-after', 'right'], default_value='split-right', allow_none=False).tag(sync=True)
26+
anchor = CaselessStrEnum(
27+
['split-right', 'split-left', 'split-top', 'split-bottom', 'tab-before', 'tab-after', 'right'],
28+
default_value='right',
29+
allow_none=False
30+
).tag(sync=True)

src/plugin.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@ function activateWidgetExtension(app: JupyterLab, registry: IJupyterWidgetRegist
5454
w.addClass('jp-LinkedOutputView');
5555
w.title.label = this.model.get('title');
5656
w.title.closable = true;
57-
// TODO how to make a left tab closable
58-
// app.shell['_leftHandler'].sideBar.tabCloseRequested.connect((sender : any, tab : any) => {
59-
// tab.title.owner.dispose();
60-
// });
6157
app.shell['_rightHandler'].sideBar.tabCloseRequested.connect((sender : any, tab : any) => {
6258
tab.title.owner.dispose();
6359
});
@@ -73,11 +69,8 @@ function activateWidgetExtension(app: JupyterLab, registry: IJupyterWidgetRegist
7369
if(anchor === 'right'){
7470
app.shell.add(w, 'right');
7571
app.shell.expandRight();
76-
// } else if(anchor === 'left') {
77-
// app.shell.add(w, 'left');
78-
// app.shell.expandLeft();
7972
} else {
80-
app.shell.addToMainArea(w, {mode: anchor});
73+
app.shell.add(w, 'main', {mode: anchor});
8174
}
8275
}
8376
}

0 commit comments

Comments
 (0)