Skip to content

Commit baf9667

Browse files
Merge pull request #83 from SylvainCorlay/master
improve notebooks
2 parents f9ad0a5 + 2538ac6 commit baf9667

File tree

2 files changed

+10
-149
lines changed

2 files changed

+10
-149
lines changed

2019-07-10-CICM/notebooks/DrawControl.ipynb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
"metadata": {},
77
"outputs": [],
88
"source": [
9-
"from __future__ import print_function\n",
10-
"\n",
119
"from ipyleaflet import (\n",
1210
" Map,\n",
1311
" Marker,\n",

2019-07-10-CICM/notebooks/custom-widget.ipynb

Lines changed: 10 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 5,
5+
"execution_count": null,
66
"metadata": {},
77
"outputs": [],
88
"source": [
@@ -19,48 +19,9 @@
1919
},
2020
{
2121
"cell_type": "code",
22-
"execution_count": 6,
22+
"execution_count": null,
2323
"metadata": {},
24-
"outputs": [
25-
{
26-
"data": {
27-
"application/javascript": [
28-
"\n",
29-
"var s = document.createElement(\"style\");\n",
30-
"s.innerHTML = `\n",
31-
"path {\n",
32-
" stroke: #fff;\n",
33-
"}\n",
34-
"\n",
35-
"path:first-child {\n",
36-
" fill: yellow !important;\n",
37-
"}\n",
38-
"\n",
39-
"circle {\n",
40-
" fill: #000;\n",
41-
" pointer-events: none;\n",
42-
"}\n",
43-
"\n",
44-
".q0-9 { fill: rgb(197,27,125); }\n",
45-
".q1-9 { fill: rgb(222,119,174); }\n",
46-
".q2-9 { fill: rgb(241,182,218); }\n",
47-
".q3-9 { fill: rgb(253,224,239); }\n",
48-
".q4-9 { fill: rgb(247,247,247); }\n",
49-
".q5-9 { fill: rgb(230,245,208); }\n",
50-
".q6-9 { fill: rgb(184,225,134); }\n",
51-
".q7-9 { fill: rgb(127,188,65); }\n",
52-
".q8-9 { fill: rgb(77,146,33); }`;\n",
53-
"\n",
54-
"document.getElementsByTagName(\"head\")[0].appendChild(s);\n"
55-
],
56-
"text/plain": [
57-
"<IPython.core.display.Javascript object>"
58-
]
59-
},
60-
"metadata": {},
61-
"output_type": "display_data"
62-
}
63-
],
24+
"outputs": [],
6425
"source": [
6526
"%%javascript\n",
6627
"\n",
@@ -94,7 +55,7 @@
9455
},
9556
{
9657
"cell_type": "code",
97-
"execution_count": 7,
58+
"execution_count": null,
9859
"metadata": {},
9960
"outputs": [],
10061
"source": [
@@ -108,92 +69,9 @@
10869
},
10970
{
11071
"cell_type": "code",
111-
"execution_count": 8,
72+
"execution_count": null,
11273
"metadata": {},
113-
"outputs": [
114-
{
115-
"data": {
116-
"application/javascript": [
117-
"require.undef('myd3');\n",
118-
"\n",
119-
"define('myd3', [\"@jupyter-widgets/base\",\n",
120-
" \"https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.17/d3.js\"], function(widgets, d3) {\n",
121-
" \n",
122-
" var HelloView = widgets.DOMWidgetView.extend({\n",
123-
" \n",
124-
" render: function() { \n",
125-
" var that = this;\n",
126-
" this.width = this.model.get('width');\n",
127-
" this.height = this.model.get('height');\n",
128-
" that.vertices = this.model.get('vertices');\n",
129-
" \n",
130-
" that.voronoi = d3.geom.voronoi()\n",
131-
" .clipExtent([[0, 0], [that.width, that.height]]);\n",
132-
"\n",
133-
" this.svg = d3.select(this.el).append(\"svg\")\n",
134-
" .attr(\"width\", that.width)\n",
135-
" .attr(\"height\", that.height)\n",
136-
" .on(\"mousemove\", function() { \n",
137-
" that.vertices[0] = d3.mouse(this);\n",
138-
" that.redraw();\n",
139-
" });\n",
140-
" \n",
141-
" var g1 = this.svg.append(\"g\");\n",
142-
" this.path = g1.selectAll(\"path\");\n",
143-
" var g2 = this.svg.append(\"g\");\n",
144-
" this.circle = g2.selectAll(\"circle\");\n",
145-
"\n",
146-
" this.model.on('change:vertices', this.update_vertices, this);\n",
147-
" this.redraw();\n",
148-
" },\n",
149-
" \n",
150-
" update_vertices: function() {\n",
151-
" this.redraw();\n",
152-
" },\n",
153-
" \n",
154-
" redraw: function () {\n",
155-
" this.vertices = this.model.get('vertices');\n",
156-
"\n",
157-
" this.path = this.path\n",
158-
" .data(this.voronoi(this.vertices), this.polygon);\n",
159-
" this.path.exit().remove();\n",
160-
" this.path.enter().append(\"path\")\n",
161-
" .attr(\"class\", function(d, i) { return \"q\" + (i % 9) + \"-9\"; })\n",
162-
" .attr(\"d\", this.polygon);\n",
163-
" this.path.order();\n",
164-
"\n",
165-
" this.circle = this.circle\n",
166-
" .data([]);\n",
167-
" this.circle.exit().remove();\n",
168-
" \n",
169-
" this.circle = this.circle\n",
170-
" .data(this.vertices.slice(1)); \n",
171-
"\n",
172-
" this.circle.enter().append(\"circle\")\n",
173-
" .attr(\"transform\", function(d) { \n",
174-
" return \"translate(\" + d + \")\";\n",
175-
" })\n",
176-
" .attr(\"r\", 1.5);\n",
177-
" },\n",
178-
" \n",
179-
" polygon: function (d) {\n",
180-
" return \"M\" + d.join(\"L\") + \"Z\";\n",
181-
" }\n",
182-
" });\n",
183-
" \n",
184-
" return {\n",
185-
" HelloView : HelloView\n",
186-
" };\n",
187-
"});\n"
188-
],
189-
"text/plain": [
190-
"<IPython.core.display.Javascript object>"
191-
]
192-
},
193-
"metadata": {},
194-
"output_type": "display_data"
195-
}
196-
],
74+
"outputs": [],
19775
"source": [
19876
"%%javascript\n",
19977
"require.undef('myd3');\n",
@@ -271,24 +149,9 @@
271149
},
272150
{
273151
"cell_type": "code",
274-
"execution_count": 9,
152+
"execution_count": null,
275153
"metadata": {},
276-
"outputs": [
277-
{
278-
"data": {
279-
"application/vnd.jupyter.widget-view+json": {
280-
"model_id": "085e2bc3e4ca4559b5e716000556498a",
281-
"version_major": 2,
282-
"version_minor": 0
283-
},
284-
"text/plain": [
285-
"MyD3(height=300, vertices=[[381.19521593979994, 254.6699557324651], [528.3166463597643, 232.1950820743343], [3…"
286-
]
287-
},
288-
"metadata": {},
289-
"output_type": "display_data"
290-
}
291-
],
154+
"outputs": [],
292155
"source": [
293156
"import numpy as np\n",
294157
"sample_size = 100\n",
@@ -302,7 +165,7 @@
302165
},
303166
{
304167
"cell_type": "code",
305-
"execution_count": 20,
168+
"execution_count": null,
306169
"metadata": {},
307170
"outputs": [],
308171
"source": [
@@ -349,5 +212,5 @@
349212
}
350213
},
351214
"nbformat": 4,
352-
"nbformat_minor": 1
215+
"nbformat_minor": 4
353216
}

0 commit comments

Comments
 (0)