Christopher Akiki commited on
Commit
677155a
1 Parent(s): 1253165
7a9e12f9fb3d8e06@459.js ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function _1(md){return(
2
+ md`# Example Components
3
+
4
+ This notebook contains shared utilities for [D3 charts](/collection/@d3/charts).`
5
+ )}
6
+
7
+ function _name(Inputs){return(
8
+ Inputs.text({label: "Name", value: "ExampleChart"})
9
+ )}
10
+
11
+ function _3(howto,name){return(
12
+ howto(name, {open: true})
13
+ )}
14
+
15
+ function _4(howto,name){return(
16
+ howto(name, {open: true, specifier: "@d3/example", imports: {d3: "d3", d3Sankey: "d3-sankey"}})
17
+ )}
18
+
19
+ function _currentSpecifier()
20
+ {
21
+ const {pathname} = new URL(document.baseURI);
22
+ return pathname.slice(pathname.startsWith("/d/") ? 3 : 1);
23
+ }
24
+
25
+
26
+ function _howto(currentSpecifier,htl,md,Inputs){return(
27
+ function howto(name, options = {}) {
28
+ if (typeof options === "string") options = {specifier: options};
29
+ const {open, imports = {d3: "d3"}, specifier = currentSpecifier} = options;
30
+ if (!name) throw new Error("missing name");
31
+ return htl.html`<details open=${open} style="max-width: 640px; background: #fffced; box-sizing: border-box; padding: 10px 20px;"><summary style="font-weight: bold; cursor: pointer; outline: none;">How do I use this code? 🤔</summary>
32
+ <div style="margin-bottom: -1em;">${md`
33
+ **To use this chart outside of Observable,** ${specifier === currentSpecifier ? "" : `go to the <a href=/${specifier}?collection=@d3/charts target=_blank>${specifier} notebook</a>, then `}copy-paste the entire function ${name} ${specifier === currentSpecifier ? "below " : ""}including the copyright notice into your application. You’ll also need to install (*e.g.*, <code>yarn add ${Object.values(imports).join(" ")}</code>) and import (*e.g.*, ${Object.entries(imports).map(([name, value]) => `<code>import \\* as ${name} from "${value}"</code>`).join(", ")}) D3; see [D3’s README](https://github.com/d3/d3/blob/main/README.md) for details. To render a chart, pass ${name} an array of <i>data</i> and any desired <i>options</i>; it will return an SVG element that you can insert into the DOM.
34
+
35
+ **To use this chart on Observable,** [import it](/@observablehq/introduction-to-imports) into your notebook:
36
+
37
+ ~~~js
38
+ import {${name}} from "${specifier}"
39
+ ~~~
40
+
41
+ ${Inputs.button("Copy code", {reduce: () => navigator.clipboard.writeText(`import {${name}} from "${specifier}"`)})}
42
+
43
+ Then call ${name}(*data*, *options*) as shown above.
44
+
45
+ To customize this chart, click the <svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M4.5 1.75C3.80964 1.75 3.25 2.30964 3.25 3C3.25 3.69036 3.80964 4.25 4.5 4.25C5.19036 4.25 5.75 3.69036 5.75 3C5.75 2.30964 5.19036 1.75 4.5 1.75ZM1.75 3C1.75 1.48122 2.98122 0.25 4.5 0.25C6.01878 0.25 7.25 1.48122 7.25 3C7.25 4.16599 6.52434 5.1625 5.5 5.56253V7H8.5C9.4199 7 10.1947 6.37895 10.4281 5.53327C9.44188 5.11546 8.75 4.13853 8.75 3C8.75 1.48122 9.98122 0.25 11.5 0.25C13.0188 0.25 14.25 1.48122 14.25 3C14.25 4.18168 13.5047 5.18928 12.4585 5.57835C12.1782 7.51343 10.5127 9 8.5 9H5.5V10.4375C6.52434 10.8375 7.25 11.834 7.25 13C7.25 14.5188 6.01878 15.75 4.5 15.75C2.98122 15.75 1.75 14.5188 1.75 13C1.75 11.834 2.47566 10.8375 3.5 10.4375L3.5 9V7V5.56253C2.47566 5.1625 1.75 4.16599 1.75 3ZM4.5 11.75C3.80964 11.75 3.25 12.3096 3.25 13C3.25 13.6904 3.80964 14.25 4.5 14.25C5.19036 14.25 5.75 13.6904 5.75 13C5.75 12.3096 5.19036 11.75 4.5 11.75ZM10.25 3C10.25 2.30964 10.8096 1.75 11.5 1.75C12.1904 1.75 12.75 2.30964 12.75 3C12.75 3.69036 12.1904 4.25 11.5 4.25C10.8096 4.25 10.25 3.69036 10.25 3Z"></path></svg> Fork button at the top of the page to create your own copy of this notebook and save your changes. To run a cell, click the play button <svg width="16" height="16" stroke="currentColor" stroke-linejoin="round" stroke-width="1.6" fill="currentColor" viewBox="-1 0 16 16"><path d=" M11.7206 6.94335 C12.2406 7.34365 12.2406 8.12786 11.7206 8.52816L5.60999 13.2321 C4.95242 13.7383 4 13.2696 4 12.4397L4 3.03178 C4 2.20194 4.95243 1.73318 5.60999 2.23937L11.7206 6.94335Z " class="jsx-3927078970"></path></svg> in the top-right corner of the editor, or use Command-S (<span style="font: 14px var(--sans-serif);">⌘S</span>) or Shift-Enter (<span style="font: 14px var(--sans-serif);">⇧↩</span>).
46
+
47
+ If you have any questions or suggestions, please sign-in to leave a comment. Click the cell menu <svg viewBox="0 0 16 16" width="16" height="16" fill="currentColor" class="pointer"><circle r="1.5" cx="8" cy="2.5"></circle><circle r="1.5" cx="8" cy="7.5"></circle><circle r="1.5" cx="8" cy="12.5"></circle></svg> to the left of any cell, then click <svg width="16" height="16" viewBox="0 0 16 16" fill="none" class="w1 h1 mr1" stroke="currentColor" stroke-width="2"><path d="M13 3L9 3L3 3C2.44772 3 2 3.44772 2 4L2 11C2 11.5523 2.44772 12 3 12L7.5 12L9.5 14L11.5 12L13 12C13.5523 12 14 11.5523 14 11L14 4C14 3.44772 13.5523 3 13 3Z"></path><line x1="5" y1="6" x2="10" y2="6"></line><line x1="5" y1="9" x2="11" y2="9"></line></svg> Add comment.
48
+ `}</div>
49
+ </details>`;
50
+ }
51
+ )}
52
+
53
+ function _7(altplot){return(
54
+ altplot(`Plot.barY(alphabet, {x: "letter", y: "frequency"}).plot()`, {open: true})
55
+ )}
56
+
57
+ function _altplot(htl,md,Inputs){return(
58
+ function altplot(code = "", {open} = {}) {
59
+ return htl.html`<details open=${open} style="max-width: 640px; background: #fffced; box-sizing: border-box; padding: 10px 20px;"><summary style="font-weight: bold; cursor: pointer; outline: none;">Is there an easier way? 🤯</summary>
60
+ <div style="margin-bottom: -1em;">${md`
61
+ Yes! While D3’s low-level abstraction is expressive, you might find it overkill for basic charts. For exploratory data analysis, or just to visualize data quickly, consider [Observable Plot](/@observablehq/plot) instead. Plot is free, [open-source](https://github.com/observablehq/plot), built on top of D3, and maintained by the same people as D3.
62
+
63
+ For example, the above chart can be written as:
64
+
65
+ ~~~js
66
+ ${code}
67
+ ~~~
68
+
69
+ ${Inputs.button("Copy code", {reduce: () => navigator.clipboard.writeText(code)})}
70
+
71
+ Try pasting this code into a new cell to see.
72
+
73
+ `}</div>
74
+ </details>`;
75
+ }
76
+ )}
77
+
78
+ function _linkplot(htl,md){return(
79
+ function linkplot(link = "", {open, title} = {}) {
80
+ return htl.html`<details open=${open} style="max-width: 640px; background: #fffced; box-sizing: border-box; padding: 10px 20px;"><summary style="font-weight: bold; cursor: pointer; outline: none;">Is there an easier way? 🤯</summary>
81
+ <div style="margin-bottom: -1em;">${md`
82
+ Yes! While D3’s low-level abstraction is expressive, you might find it overkill for basic charts. For exploratory data analysis, or just to visualize data quickly, consider [Observable Plot](/@observablehq/plot) instead. Plot is free, [open-source](https://github.com/observablehq/plot), built on top of D3, and maintained by the same people as D3.
83
+
84
+ For example, <a href=${link}>${title || link}</a> reproduces the above chart, with Plot.
85
+
86
+ `}</div>
87
+ </details>`;
88
+ }
89
+ )}
90
+
91
+ export default function define(runtime, observer) {
92
+ const main = runtime.module();
93
+ main.variable(observer()).define(["md"], _1);
94
+ main.variable(observer("viewof name")).define("viewof name", ["Inputs"], _name);
95
+ main.variable(observer("name")).define("name", ["Generators", "viewof name"], (G, _) => G.input(_));
96
+ main.variable(observer()).define(["howto","name"], _3);
97
+ main.variable(observer()).define(["howto","name"], _4);
98
+ main.variable(observer("currentSpecifier")).define("currentSpecifier", _currentSpecifier);
99
+ main.variable(observer("howto")).define("howto", ["currentSpecifier","htl","md","Inputs"], _howto);
100
+ main.variable(observer()).define(["altplot"], _7);
101
+ main.variable(observer("altplot")).define("altplot", ["htl","md","Inputs"], _altplot);
102
+ main.variable(observer("linkplot")).define("linkplot", ["htl","md"], _linkplot);
103
+ return main;
104
+ }
LICENSE.txt ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright 2017–2021 Observable, Inc.
2
+
3
+ Permission to use, copy, modify, and/or distribute this software for any
4
+ purpose with or without fee is hereby granted, provided that the above
5
+ copyright notice and this permission notice appear in all copies.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
README.md CHANGED
@@ -1,10 +1,10 @@
1
  ---
2
  title: Test D3
3
- emoji: 🏢
4
  colorFrom: blue
5
  colorTo: pink
6
  sdk: static
7
  pinned: false
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces#reference
 
1
  ---
2
  title: Test D3
3
+ emoji: 🏢
4
  colorFrom: blue
5
  colorTo: pink
6
  sdk: static
7
  pinned: false
8
  ---
9
 
10
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces#reference
a1fd3857bac219b0@480.js ADDED
@@ -0,0 +1,205 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // https://observablehq.com/@d3/treemap@480
2
+ import define1 from "./a33468b95d0b15b0@808.js";
3
+ import define2 from "./7a9e12f9fb3d8e06@459.js";
4
+
5
+ function _1(md){return(
6
+ md`# Treemap, CSV
7
+
8
+ Introduced by [Ben Shneiderman](http://www.cs.umd.edu/hcil/treemap-history/), treemaps recursively partition space into rectangles according to each node’s associated value. D3 supports several treemap tiling methods. See also [nested](/@d3/nested-treemap), [zoomable](/@d3/zoomable-treemap) and [animated](/@d3/animated-treemap) treemaps.`
9
+ )}
10
+
11
+ function _tile(Inputs,d3){return(
12
+ Inputs.select(
13
+ new Map([
14
+ ["binary", d3.treemapBinary],
15
+ ["squarify", d3.treemapSquarify],
16
+ ["slice-dice", d3.treemapSliceDice],
17
+ ["slice", d3.treemapSlice],
18
+ ["dice", d3.treemapDice]
19
+ ]),
20
+ {label: "Tiling method", value: d3.treemapBinary}
21
+ )
22
+ )}
23
+
24
+ function _key(Swatches,chart){return(
25
+ Swatches(chart.scales.color)
26
+ )}
27
+
28
+ function _chart(Treemap,flare,tile){return(
29
+ Treemap(flare, {
30
+ path: d => d.name.replace(/\./g, "/"), // e.g., "flare/animate/Easing"
31
+ value: d => d?.size, // size of each node (file); null for internal nodes (folders)
32
+ group: d => d.name.split(".")[1], // e.g., "animate" in "flare.animate.Easing"; for color
33
+ label: (d, n) => [...d.name.split(".").pop().split(/(?=[A-Z][a-z])/g), n.value.toLocaleString("en")].join("\n"),
34
+ title: (d, n) => `${d.name}\n${n.value.toLocaleString("en")}`, // text to show on hover
35
+ link: (d, n) => `https://github.com/prefuse/Flare/blob/master/flare/src${n.id}.as`,
36
+ tile, // e.g., d3.treemapBinary; set by input above
37
+ width: 1152,
38
+ height: 1152
39
+ })
40
+ )}
41
+
42
+ function _5(md){return(
43
+ md`This example uses a CSV file to represent the hierarchy as tabular data: each row in the file represents a node in the tree. If a *path* option is specified, the Treemap function can automatically impute the internal (parent) nodes and hence the CSV only needs to include leaves; however, if you use the *id* and *parentId* options instead, then the CSV file must include the internal nodes as well as the leaves. See the [JSON treemap](/@d3/json-treemap) example for using a JSON data source.`
44
+ )}
45
+
46
+ function _flare(FileAttachment){return(
47
+ FileAttachment("flare-2.csv").csv({typed: true})
48
+ )}
49
+
50
+ function _7(howto){return(
51
+ howto("Treemap")
52
+ )}
53
+
54
+ function _Treemap(d3,location){return(
55
+ function Treemap(data, { // data is either tabular (array of objects) or hierarchy (nested objects)
56
+ path, // as an alternative to id and parentId, returns an array identifier, imputing internal nodes
57
+ id = Array.isArray(data) ? d => d.id : null, // if tabular data, given a d in data, returns a unique identifier (string)
58
+ parentId = Array.isArray(data) ? d => d.parentId : null, // if tabular data, given a node d, returns its parent’s identifier
59
+ children, // if hierarchical data, given a d in data, returns its children
60
+ value, // given a node d, returns a quantitative value (for area encoding; null for count)
61
+ sort = (a, b) => d3.descending(a.value, b.value), // how to sort nodes prior to layout
62
+ label, // given a leaf node d, returns the name to display on the rectangle
63
+ group, // given a leaf node d, returns a categorical value (for color encoding)
64
+ title, // given a leaf node d, returns its hover text
65
+ link, // given a leaf node d, its link (if any)
66
+ linkTarget = "_blank", // the target attribute for links (if any)
67
+ tile = d3.treemapBinary, // treemap strategy
68
+ width = 640, // outer width, in pixels
69
+ height = 400, // outer height, in pixels
70
+ margin = 0, // shorthand for margins
71
+ marginTop = margin, // top margin, in pixels
72
+ marginRight = margin, // right margin, in pixels
73
+ marginBottom = margin, // bottom margin, in pixels
74
+ marginLeft = margin, // left margin, in pixels
75
+ padding = 1, // shorthand for inner and outer padding
76
+ paddingInner = padding, // to separate a node from its adjacent siblings
77
+ paddingOuter = padding, // shorthand for top, right, bottom, and left padding
78
+ paddingTop = paddingOuter, // to separate a node’s top edge from its children
79
+ paddingRight = paddingOuter, // to separate a node’s right edge from its children
80
+ paddingBottom = paddingOuter, // to separate a node’s bottom edge from its children
81
+ paddingLeft = paddingOuter, // to separate a node’s left edge from its children
82
+ round = true, // whether to round to exact pixels
83
+ colors = d3.schemeTableau10, // array of colors
84
+ zDomain, // array of values for the color scale
85
+ fill = "#ccc", // fill for node rects (if no group color encoding)
86
+ fillOpacity = group == null ? null : 0.6, // fill opacity for node rects
87
+ stroke, // stroke for node rects
88
+ strokeWidth, // stroke width for node rects
89
+ strokeOpacity, // stroke opacity for node rects
90
+ strokeLinejoin, // stroke line join for node rects
91
+ } = {}) {
92
+
93
+ // If id and parentId options are specified, or the path option, use d3.stratify
94
+ // to convert tabular data to a hierarchy; otherwise we assume that the data is
95
+ // specified as an object {children} with nested objects (a.k.a. the “flare.json”
96
+ // format), and use d3.hierarchy.
97
+ const root = path != null ? d3.stratify().path(path)(data)
98
+ : id != null || parentId != null ? d3.stratify().id(id).parentId(parentId)(data)
99
+ : d3.hierarchy(data, children);
100
+
101
+ // Compute the values of internal nodes by aggregating from the leaves.
102
+ value == null ? root.count() : root.sum(d => Math.max(0, value(d)));
103
+
104
+ // Prior to sorting, if a group channel is specified, construct an ordinal color scale.
105
+ const leaves = root.leaves();
106
+ const G = group == null ? null : leaves.map(d => group(d.data, d));
107
+ if (zDomain === undefined) zDomain = G;
108
+ zDomain = new d3.InternSet(zDomain);
109
+ const color = group == null ? null : d3.scaleOrdinal(zDomain, colors);
110
+
111
+ // Compute labels and titles.
112
+ const L = label == null ? null : leaves.map(d => label(d.data, d));
113
+ const T = title === undefined ? L : title == null ? null : leaves.map(d => title(d.data, d));
114
+
115
+ // Sort the leaves (typically by descending value for a pleasing layout).
116
+ if (sort != null) root.sort(sort);
117
+
118
+ // Compute the treemap layout.
119
+ d3.treemap()
120
+ .tile(tile)
121
+ .size([width - marginLeft - marginRight, height - marginTop - marginBottom])
122
+ .paddingInner(paddingInner)
123
+ .paddingTop(paddingTop)
124
+ .paddingRight(paddingRight)
125
+ .paddingBottom(paddingBottom)
126
+ .paddingLeft(paddingLeft)
127
+ .round(round)
128
+ (root);
129
+
130
+ const svg = d3.create("svg")
131
+ .attr("viewBox", [-marginLeft, -marginTop, width, height])
132
+ .attr("width", width)
133
+ .attr("height", height)
134
+ .attr("style", "max-width: 100%; height: auto; height: intrinsic;")
135
+ .attr("font-family", "sans-serif")
136
+ .attr("font-size", 10);
137
+
138
+ const node = svg.selectAll("a")
139
+ .data(leaves)
140
+ .join("a")
141
+ .attr("xlink:href", link == null ? null : (d, i) => link(d.data, d))
142
+ .attr("target", link == null ? null : linkTarget)
143
+ .attr("transform", d => `translate(${d.x0},${d.y0})`);
144
+
145
+ node.append("rect")
146
+ .attr("fill", color ? (d, i) => color(G[i]) : fill)
147
+ .attr("fill-opacity", fillOpacity)
148
+ .attr("stroke", stroke)
149
+ .attr("stroke-width", strokeWidth)
150
+ .attr("stroke-opacity", strokeOpacity)
151
+ .attr("stroke-linejoin", strokeLinejoin)
152
+ .attr("width", d => d.x1 - d.x0)
153
+ .attr("height", d => d.y1 - d.y0);
154
+
155
+ if (T) {
156
+ node.append("title").text((d, i) => T[i]);
157
+ }
158
+
159
+ if (L) {
160
+ // A unique identifier for clip paths (to avoid conflicts).
161
+ const uid = `O-${Math.random().toString(16).slice(2)}`;
162
+
163
+ node.append("clipPath")
164
+ .attr("id", (d, i) => `${uid}-clip-${i}`)
165
+ .append("rect")
166
+ .attr("width", d => d.x1 - d.x0)
167
+ .attr("height", d => d.y1 - d.y0);
168
+
169
+ node.append("text")
170
+ .attr("clip-path", (d, i) => `url(${new URL(`#${uid}-clip-${i}`, location)})`)
171
+ .selectAll("tspan")
172
+ .data((d, i) => `${L[i]}`.split(/\n/g))
173
+ .join("tspan")
174
+ .attr("x", 3)
175
+ .attr("y", (d, i, D) => `${(i === D.length - 1) * 0.3 + 1.1 + i * 0.9}em`)
176
+ .attr("fill-opacity", (d, i, D) => i === D.length - 1 ? 0.7 : null)
177
+ .text(d => d);
178
+ }
179
+
180
+ return Object.assign(svg.node(), {scales: {color}});
181
+ }
182
+ )}
183
+
184
+ export default function define(runtime, observer) {
185
+ const main = runtime.module();
186
+ function toString() { return this.url; }
187
+ const fileAttachments = new Map([
188
+ ["flare-2.csv", {url: new URL("./files/a6b0d94a7f5828fd133765a934f4c9746d2010e2f342d335923991f31b14120de96b5cb4f160d509d8dc627f0107d7f5b5070d2516f01e4c862b5b4867533000", import.meta.url), mimeType: "text/csv", toString}]
189
+ ]);
190
+ main.builtin("FileAttachment", runtime.fileAttachments(name => fileAttachments.get(name)));
191
+ main.variable(observer()).define(["md"], _1);
192
+ main.variable(observer("viewof tile")).define("viewof tile", ["Inputs","d3"], _tile);
193
+ main.variable(observer("tile")).define("tile", ["Generators", "viewof tile"], (G, _) => G.input(_));
194
+ main.variable(observer("key")).define("key", ["Swatches","chart"], _key);
195
+ main.variable(observer("chart")).define("chart", ["Treemap","flare","tile"], _chart);
196
+ main.variable(observer()).define(["md"], _5);
197
+ main.variable(observer("flare")).define("flare", ["FileAttachment"], _flare);
198
+ main.variable(observer()).define(["howto"], _7);
199
+ main.variable(observer("Treemap")).define("Treemap", ["d3","location"], _Treemap);
200
+ const child1 = runtime.module(define1);
201
+ main.import("Swatches", child1);
202
+ const child2 = runtime.module(define2);
203
+ main.import("howto", child2);
204
+ return main;
205
+ }
a33468b95d0b15b0@808.js ADDED
@@ -0,0 +1,369 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // https://observablehq.com/@d3/color-legend@808
2
+ function _1(md){return(
3
+ md`# Color Legend
4
+
5
+ A simple legend for a [color scale](/@d3/color-schemes). Supports [continuous](/@d3/continuous-scales), [sequential](/@d3/sequential-scales), [diverging](/@d3/diverging-scales), [quantize, quantile, threshold](/@d3/quantile-quantize-and-threshold-scales) and [ordinal](/@d3/d3-scaleordinal) scales. To use:
6
+
7
+ ~~~js
8
+ import {Legend, Swatches} from "@d3/color-legend"
9
+ ~~~
10
+
11
+ Then call the legend function as shown below. (For ordinal scales, also consider the swatches function.)`
12
+ )}
13
+
14
+ function _2(Legend,d3){return(
15
+ Legend(d3.scaleSequential([0, 100], d3.interpolateViridis), {
16
+ title: "Temperature (°F)"
17
+ })
18
+ )}
19
+
20
+ function _3(Legend,d3){return(
21
+ Legend(d3.scaleSequentialSqrt([0, 1], d3.interpolateTurbo), {
22
+ title: "Speed (kts)"
23
+ })
24
+ )}
25
+
26
+ function _4(Legend,d3){return(
27
+ Legend(d3.scaleDiverging([-0.1, 0, 0.1], d3.interpolatePiYG), {
28
+ title: "Daily change",
29
+ tickFormat: "+%"
30
+ })
31
+ )}
32
+
33
+ function _5(Legend,d3){return(
34
+ Legend(d3.scaleDivergingSqrt([-0.1, 0, 0.1], d3.interpolateRdBu), {
35
+ title: "Daily change",
36
+ tickFormat: "+%"
37
+ })
38
+ )}
39
+
40
+ function _6(Legend,d3){return(
41
+ Legend(d3.scaleSequentialLog([1, 100], d3.interpolateBlues), {
42
+ title: "Energy (joules)",
43
+ ticks: 10
44
+ })
45
+ )}
46
+
47
+ function _7(Legend,d3){return(
48
+ Legend(d3.scaleSequentialQuantile(d3.range(100).map(() => Math.random() ** 2), d3.interpolateBlues), {
49
+ title: "Quantile",
50
+ tickFormat: ".2f"
51
+ })
52
+ )}
53
+
54
+ function _8(Legend,d3){return(
55
+ Legend(d3.scaleSqrt([-100, 0, 100], ["blue", "white", "red"]), {
56
+ title: "Temperature (°C)"
57
+ })
58
+ )}
59
+
60
+ function _9(Legend,d3){return(
61
+ Legend(d3.scaleQuantize([1, 10], d3.schemePurples[9]), {
62
+ title: "Unemployment rate (%)"
63
+ })
64
+ )}
65
+
66
+ function _10(Legend,d3){return(
67
+ Legend(d3.scaleQuantile(d3.range(1000).map(d3.randomNormal(100, 20)), d3.schemeSpectral[9]), {
68
+ title: "Height (cm)",
69
+ tickFormat: ".0f"
70
+ })
71
+ )}
72
+
73
+ function _11(Legend,d3){return(
74
+ Legend(d3.scaleThreshold([2.5, 3.1, 3.5, 3.9, 6, 7, 8, 9.5], d3.schemeRdBu[9]), {
75
+ title: "Unemployment rate (%)",
76
+ tickSize: 0
77
+ })
78
+ )}
79
+
80
+ function _12(Legend,d3){return(
81
+ Legend(d3.scaleOrdinal(["<10", "10-19", "20-29", "30-39", "40-49", "50-59", "60-69", "70-79", "≥80"], d3.schemeSpectral[10]), {
82
+ title: "Age (years)",
83
+ tickSize: 0
84
+ })
85
+ )}
86
+
87
+ function _13(md){return(
88
+ md`But wait, there’s more!
89
+
90
+ How about swatches for ordinal color scales? Both variable-width swatches and [column layout](https://developer.mozilla.org/en-US/docs/Web/CSS/columns) are supported.`
91
+ )}
92
+
93
+ function _14(Swatches,d3){return(
94
+ Swatches(d3.scaleOrdinal(["blueberries", "oranges", "apples"], d3.schemeCategory10))
95
+ )}
96
+
97
+ function _15(Swatches,d3){return(
98
+ Swatches(d3.scaleOrdinal(["Wholesale and Retail Trade", "Manufacturing", "Leisure and hospitality", "Business services", "Construction", "Education and Health", "Government", "Finance", "Self-employed", "Other"], d3.schemeTableau10), {
99
+ columns: "180px"
100
+ })
101
+ )}
102
+
103
+ function _16(md){return(
104
+ md`---
105
+
106
+ ## Implementation`
107
+ )}
108
+
109
+ function _Legend(d3){return(
110
+ function Legend(color, {
111
+ title,
112
+ tickSize = 6,
113
+ width = 320,
114
+ height = 44 + tickSize,
115
+ marginTop = 18,
116
+ marginRight = 0,
117
+ marginBottom = 16 + tickSize,
118
+ marginLeft = 0,
119
+ ticks = width / 64,
120
+ tickFormat,
121
+ tickValues
122
+ } = {}) {
123
+
124
+ function ramp(color, n = 256) {
125
+ const canvas = document.createElement("canvas");
126
+ canvas.width = n;
127
+ canvas.height = 1;
128
+ const context = canvas.getContext("2d");
129
+ for (let i = 0; i < n; ++i) {
130
+ context.fillStyle = color(i / (n - 1));
131
+ context.fillRect(i, 0, 1, 1);
132
+ }
133
+ return canvas;
134
+ }
135
+
136
+ const svg = d3.create("svg")
137
+ .attr("width", width)
138
+ .attr("height", height)
139
+ .attr("viewBox", [0, 0, width, height])
140
+ .style("overflow", "visible")
141
+ .style("display", "block");
142
+
143
+ let tickAdjust = g => g.selectAll(".tick line").attr("y1", marginTop + marginBottom - height);
144
+ let x;
145
+
146
+ // Continuous
147
+ if (color.interpolate) {
148
+ const n = Math.min(color.domain().length, color.range().length);
149
+
150
+ x = color.copy().rangeRound(d3.quantize(d3.interpolate(marginLeft, width - marginRight), n));
151
+
152
+ svg.append("image")
153
+ .attr("x", marginLeft)
154
+ .attr("y", marginTop)
155
+ .attr("width", width - marginLeft - marginRight)
156
+ .attr("height", height - marginTop - marginBottom)
157
+ .attr("preserveAspectRatio", "none")
158
+ .attr("xlink:href", ramp(color.copy().domain(d3.quantize(d3.interpolate(0, 1), n))).toDataURL());
159
+ }
160
+
161
+ // Sequential
162
+ else if (color.interpolator) {
163
+ x = Object.assign(color.copy()
164
+ .interpolator(d3.interpolateRound(marginLeft, width - marginRight)),
165
+ {range() { return [marginLeft, width - marginRight]; }});
166
+
167
+ svg.append("image")
168
+ .attr("x", marginLeft)
169
+ .attr("y", marginTop)
170
+ .attr("width", width - marginLeft - marginRight)
171
+ .attr("height", height - marginTop - marginBottom)
172
+ .attr("preserveAspectRatio", "none")
173
+ .attr("xlink:href", ramp(color.interpolator()).toDataURL());
174
+
175
+ // scaleSequentialQuantile doesn’t implement ticks or tickFormat.
176
+ if (!x.ticks) {
177
+ if (tickValues === undefined) {
178
+ const n = Math.round(ticks + 1);
179
+ tickValues = d3.range(n).map(i => d3.quantile(color.domain(), i / (n - 1)));
180
+ }
181
+ if (typeof tickFormat !== "function") {
182
+ tickFormat = d3.format(tickFormat === undefined ? ",f" : tickFormat);
183
+ }
184
+ }
185
+ }
186
+
187
+ // Threshold
188
+ else if (color.invertExtent) {
189
+ const thresholds
190
+ = color.thresholds ? color.thresholds() // scaleQuantize
191
+ : color.quantiles ? color.quantiles() // scaleQuantile
192
+ : color.domain(); // scaleThreshold
193
+
194
+ const thresholdFormat
195
+ = tickFormat === undefined ? d => d
196
+ : typeof tickFormat === "string" ? d3.format(tickFormat)
197
+ : tickFormat;
198
+
199
+ x = d3.scaleLinear()
200
+ .domain([-1, color.range().length - 1])
201
+ .rangeRound([marginLeft, width - marginRight]);
202
+
203
+ svg.append("g")
204
+ .selectAll("rect")
205
+ .data(color.range())
206
+ .join("rect")
207
+ .attr("x", (d, i) => x(i - 1))
208
+ .attr("y", marginTop)
209
+ .attr("width", (d, i) => x(i) - x(i - 1))
210
+ .attr("height", height - marginTop - marginBottom)
211
+ .attr("fill", d => d);
212
+
213
+ tickValues = d3.range(thresholds.length);
214
+ tickFormat = i => thresholdFormat(thresholds[i], i);
215
+ }
216
+
217
+ // Ordinal
218
+ else {
219
+ x = d3.scaleBand()
220
+ .domain(color.domain())
221
+ .rangeRound([marginLeft, width - marginRight]);
222
+
223
+ svg.append("g")
224
+ .selectAll("rect")
225
+ .data(color.domain())
226
+ .join("rect")
227
+ .attr("x", x)
228
+ .attr("y", marginTop)
229
+ .attr("width", Math.max(0, x.bandwidth() - 1))
230
+ .attr("height", height - marginTop - marginBottom)
231
+ .attr("fill", color);
232
+
233
+ tickAdjust = () => {};
234
+ }
235
+
236
+ svg.append("g")
237
+ .attr("transform", `translate(0,${height - marginBottom})`)
238
+ .call(d3.axisBottom(x)
239
+ .ticks(ticks, typeof tickFormat === "string" ? tickFormat : undefined)
240
+ .tickFormat(typeof tickFormat === "function" ? tickFormat : undefined)
241
+ .tickSize(tickSize)
242
+ .tickValues(tickValues))
243
+ .call(tickAdjust)
244
+ .call(g => g.select(".domain").remove())
245
+ .call(g => g.append("text")
246
+ .attr("x", marginLeft)
247
+ .attr("y", marginTop + marginBottom - height - 6)
248
+ .attr("fill", "currentColor")
249
+ .attr("text-anchor", "start")
250
+ .attr("font-weight", "bold")
251
+ .attr("class", "title")
252
+ .text(title));
253
+
254
+ return svg.node();
255
+ }
256
+ )}
257
+
258
+ function _legend(Legend){return(
259
+ function legend({color, ...options}) {
260
+ return Legend(color, options);
261
+ }
262
+ )}
263
+
264
+ function _Swatches(d3,htl){return(
265
+ function Swatches(color, {
266
+ columns = null,
267
+ format,
268
+ unknown: formatUnknown,
269
+ swatchSize = 15,
270
+ swatchWidth = swatchSize,
271
+ swatchHeight = swatchSize,
272
+ marginLeft = 0
273
+ } = {}) {
274
+ const id = `-swatches-${Math.random().toString(16).slice(2)}`;
275
+ const unknown = formatUnknown == null ? undefined : color.unknown();
276
+ const unknowns = unknown == null || unknown === d3.scaleImplicit ? [] : [unknown];
277
+ const domain = color.domain().concat(unknowns);
278
+ if (format === undefined) format = x => x === unknown ? formatUnknown : x;
279
+
280
+ function entity(character) {
281
+ return `&#${character.charCodeAt(0).toString()};`;
282
+ }
283
+
284
+ if (columns !== null) return htl.html`<div style="display: flex; align-items: center; margin-left: ${+marginLeft}px; min-height: 33px; font: 10px sans-serif;">
285
+ <style>
286
+
287
+ .${id}-item {
288
+ break-inside: avoid;
289
+ display: flex;
290
+ align-items: center;
291
+ padding-bottom: 1px;
292
+ }
293
+
294
+ .${id}-label {
295
+ white-space: nowrap;
296
+ overflow: hidden;
297
+ text-overflow: ellipsis;
298
+ max-width: calc(100% - ${+swatchWidth}px - 0.5em);
299
+ }
300
+
301
+ .${id}-swatch {
302
+ width: ${+swatchWidth}px;
303
+ height: ${+swatchHeight}px;
304
+ margin: 0 0.5em 0 0;
305
+ }
306
+
307
+ </style>
308
+ <div style=${{width: "100%", columns}}>${domain.map(value => {
309
+ const label = `${format(value)}`;
310
+ return htl.html`<div class=${id}-item>
311
+ <div class=${id}-swatch style=${{background: color(value)}}></div>
312
+ <div class=${id}-label title=${label}>${label}</div>
313
+ </div>`;
314
+ })}
315
+ </div>
316
+ </div>`;
317
+
318
+ return htl.html`<div style="display: flex; align-items: center; min-height: 33px; margin-left: ${+marginLeft}px; font: 10px sans-serif;">
319
+ <style>
320
+
321
+ .${id} {
322
+ display: inline-flex;
323
+ align-items: center;
324
+ margin-right: 1em;
325
+ }
326
+
327
+ .${id}::before {
328
+ content: "";
329
+ width: ${+swatchWidth}px;
330
+ height: ${+swatchHeight}px;
331
+ margin-right: 0.5em;
332
+ background: var(--color);
333
+ }
334
+
335
+ </style>
336
+ <div>${domain.map(value => htl.html`<span class="${id}" style="--color: ${color(value)}">${format(value)}</span>`)}</div>`;
337
+ }
338
+ )}
339
+
340
+ function _swatches(Swatches){return(
341
+ function swatches({color, ...options}) {
342
+ return Swatches(color, options);
343
+ }
344
+ )}
345
+
346
+ export default function define(runtime, observer) {
347
+ const main = runtime.module();
348
+ main.variable(observer()).define(["md"], _1);
349
+ main.variable(observer()).define(["Legend","d3"], _2);
350
+ main.variable(observer()).define(["Legend","d3"], _3);
351
+ main.variable(observer()).define(["Legend","d3"], _4);
352
+ main.variable(observer()).define(["Legend","d3"], _5);
353
+ main.variable(observer()).define(["Legend","d3"], _6);
354
+ main.variable(observer()).define(["Legend","d3"], _7);
355
+ main.variable(observer()).define(["Legend","d3"], _8);
356
+ main.variable(observer()).define(["Legend","d3"], _9);
357
+ main.variable(observer()).define(["Legend","d3"], _10);
358
+ main.variable(observer()).define(["Legend","d3"], _11);
359
+ main.variable(observer()).define(["Legend","d3"], _12);
360
+ main.variable(observer()).define(["md"], _13);
361
+ main.variable(observer()).define(["Swatches","d3"], _14);
362
+ main.variable(observer()).define(["Swatches","d3"], _15);
363
+ main.variable(observer()).define(["md"], _16);
364
+ main.variable(observer("Legend")).define("Legend", ["d3"], _Legend);
365
+ main.variable(observer("legend")).define("legend", ["Legend"], _legend);
366
+ main.variable(observer("Swatches")).define("Swatches", ["d3","htl"], _Swatches);
367
+ main.variable(observer("swatches")).define("swatches", ["Swatches"], _swatches);
368
+ return main;
369
+ }
files/a6b0d94a7f5828fd133765a934f4c9746d2010e2f342d335923991f31b14120de96b5cb4f160d509d8dc627f0107d7f5b5070d2516f01e4c862b5b4867533000 ADDED
@@ -0,0 +1,253 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name,size
2
+ flare,
3
+ flare.analytics,
4
+ flare.analytics.cluster,
5
+ flare.analytics.cluster.AgglomerativeCluster,3938
6
+ flare.analytics.cluster.CommunityStructure,3812
7
+ flare.analytics.cluster.HierarchicalCluster,6714
8
+ flare.analytics.cluster.MergeEdge,743
9
+ flare.analytics.graph,
10
+ flare.analytics.graph.BetweennessCentrality,3534
11
+ flare.analytics.graph.LinkDistance,5731
12
+ flare.analytics.graph.MaxFlowMinCut,7840
13
+ flare.analytics.graph.ShortestPaths,5914
14
+ flare.analytics.graph.SpanningTree,3416
15
+ flare.analytics.optimization,
16
+ flare.analytics.optimization.AspectRatioBanker,7074
17
+ flare.animate,
18
+ flare.animate.Easing,17010
19
+ flare.animate.FunctionSequence,5842
20
+ flare.animate.interpolate,
21
+ flare.animate.interpolate.ArrayInterpolator,1983
22
+ flare.animate.interpolate.ColorInterpolator,2047
23
+ flare.animate.interpolate.DateInterpolator,1375
24
+ flare.animate.interpolate.Interpolator,8746
25
+ flare.animate.interpolate.MatrixInterpolator,2202
26
+ flare.animate.interpolate.NumberInterpolator,1382
27
+ flare.animate.interpolate.ObjectInterpolator,1629
28
+ flare.animate.interpolate.PointInterpolator,1675
29
+ flare.animate.interpolate.RectangleInterpolator,2042
30
+ flare.animate.ISchedulable,1041
31
+ flare.animate.Parallel,5176
32
+ flare.animate.Pause,449
33
+ flare.animate.Scheduler,5593
34
+ flare.animate.Sequence,5534
35
+ flare.animate.Transition,9201
36
+ flare.animate.Transitioner,19975
37
+ flare.animate.TransitionEvent,1116
38
+ flare.animate.Tween,6006
39
+ flare.data,
40
+ flare.data.converters,
41
+ flare.data.converters.Converters,721
42
+ flare.data.converters.DelimitedTextConverter,4294
43
+ flare.data.converters.GraphMLConverter,9800
44
+ flare.data.converters.IDataConverter,1314
45
+ flare.data.converters.JSONConverter,2220
46
+ flare.data.DataField,1759
47
+ flare.data.DataSchema,2165
48
+ flare.data.DataSet,586
49
+ flare.data.DataSource,3331
50
+ flare.data.DataTable,772
51
+ flare.data.DataUtil,3322
52
+ flare.display,
53
+ flare.display.DirtySprite,8833
54
+ flare.display.LineSprite,1732
55
+ flare.display.RectSprite,3623
56
+ flare.display.TextSprite,10066
57
+ flare.flex,
58
+ flare.flex.FlareVis,4116
59
+ flare.physics,
60
+ flare.physics.DragForce,1082
61
+ flare.physics.GravityForce,1336
62
+ flare.physics.IForce,319
63
+ flare.physics.NBodyForce,10498
64
+ flare.physics.Particle,2822
65
+ flare.physics.Simulation,9983
66
+ flare.physics.Spring,2213
67
+ flare.physics.SpringForce,1681
68
+ flare.query,
69
+ flare.query.AggregateExpression,1616
70
+ flare.query.And,1027
71
+ flare.query.Arithmetic,3891
72
+ flare.query.Average,891
73
+ flare.query.BinaryExpression,2893
74
+ flare.query.Comparison,5103
75
+ flare.query.CompositeExpression,3677
76
+ flare.query.Count,781
77
+ flare.query.DateUtil,4141
78
+ flare.query.Distinct,933
79
+ flare.query.Expression,5130
80
+ flare.query.ExpressionIterator,3617
81
+ flare.query.Fn,3240
82
+ flare.query.If,2732
83
+ flare.query.IsA,2039
84
+ flare.query.Literal,1214
85
+ flare.query.Match,3748
86
+ flare.query.Maximum,843
87
+ flare.query.methods,
88
+ flare.query.methods.add,593
89
+ flare.query.methods.and,330
90
+ flare.query.methods.average,287
91
+ flare.query.methods.count,277
92
+ flare.query.methods.distinct,292
93
+ flare.query.methods.div,595
94
+ flare.query.methods.eq,594
95
+ flare.query.methods.fn,460
96
+ flare.query.methods.gt,603
97
+ flare.query.methods.gte,625
98
+ flare.query.methods.iff,748
99
+ flare.query.methods.isa,461
100
+ flare.query.methods.lt,597
101
+ flare.query.methods.lte,619
102
+ flare.query.methods.max,283
103
+ flare.query.methods.min,283
104
+ flare.query.methods.mod,591
105
+ flare.query.methods.mul,603
106
+ flare.query.methods.neq,599
107
+ flare.query.methods.not,386
108
+ flare.query.methods.or,323
109
+ flare.query.methods.orderby,307
110
+ flare.query.methods.range,772
111
+ flare.query.methods.select,296
112
+ flare.query.methods.stddev,363
113
+ flare.query.methods.sub,600
114
+ flare.query.methods.sum,280
115
+ flare.query.methods.update,307
116
+ flare.query.methods.variance,335
117
+ flare.query.methods.where,299
118
+ flare.query.methods.xor,354
119
+ flare.query.methods._,264
120
+ flare.query.Minimum,843
121
+ flare.query.Not,1554
122
+ flare.query.Or,970
123
+ flare.query.Query,13896
124
+ flare.query.Range,1594
125
+ flare.query.StringUtil,4130
126
+ flare.query.Sum,791
127
+ flare.query.Variable,1124
128
+ flare.query.Variance,1876
129
+ flare.query.Xor,1101
130
+ flare.scale,
131
+ flare.scale.IScaleMap,2105
132
+ flare.scale.LinearScale,1316
133
+ flare.scale.LogScale,3151
134
+ flare.scale.OrdinalScale,3770
135
+ flare.scale.QuantileScale,2435
136
+ flare.scale.QuantitativeScale,4839
137
+ flare.scale.RootScale,1756
138
+ flare.scale.Scale,4268
139
+ flare.scale.ScaleType,1821
140
+ flare.scale.TimeScale,5833
141
+ flare.util,
142
+ flare.util.Arrays,8258
143
+ flare.util.Colors,10001
144
+ flare.util.Dates,8217
145
+ flare.util.Displays,12555
146
+ flare.util.Filter,2324
147
+ flare.util.Geometry,10993
148
+ flare.util.heap,
149
+ flare.util.heap.FibonacciHeap,9354
150
+ flare.util.heap.HeapNode,1233
151
+ flare.util.IEvaluable,335
152
+ flare.util.IPredicate,383
153
+ flare.util.IValueProxy,874
154
+ flare.util.math,
155
+ flare.util.math.DenseMatrix,3165
156
+ flare.util.math.IMatrix,2815
157
+ flare.util.math.SparseMatrix,3366
158
+ flare.util.Maths,17705
159
+ flare.util.Orientation,1486
160
+ flare.util.palette,
161
+ flare.util.palette.ColorPalette,6367
162
+ flare.util.palette.Palette,1229
163
+ flare.util.palette.ShapePalette,2059
164
+ flare.util.palette.SizePalette,2291
165
+ flare.util.Property,5559
166
+ flare.util.Shapes,19118
167
+ flare.util.Sort,6887
168
+ flare.util.Stats,6557
169
+ flare.util.Strings,22026
170
+ flare.vis,
171
+ flare.vis.axis,
172
+ flare.vis.axis.Axes,1302
173
+ flare.vis.axis.Axis,24593
174
+ flare.vis.axis.AxisGridLine,652
175
+ flare.vis.axis.AxisLabel,636
176
+ flare.vis.axis.CartesianAxes,6703
177
+ flare.vis.controls,
178
+ flare.vis.controls.AnchorControl,2138
179
+ flare.vis.controls.ClickControl,3824
180
+ flare.vis.controls.Control,1353
181
+ flare.vis.controls.ControlList,4665
182
+ flare.vis.controls.DragControl,2649
183
+ flare.vis.controls.ExpandControl,2832
184
+ flare.vis.controls.HoverControl,4896
185
+ flare.vis.controls.IControl,763
186
+ flare.vis.controls.PanZoomControl,5222
187
+ flare.vis.controls.SelectionControl,7862
188
+ flare.vis.controls.TooltipControl,8435
189
+ flare.vis.data,
190
+ flare.vis.data.Data,20544
191
+ flare.vis.data.DataList,19788
192
+ flare.vis.data.DataSprite,10349
193
+ flare.vis.data.EdgeSprite,3301
194
+ flare.vis.data.NodeSprite,19382
195
+ flare.vis.data.render,
196
+ flare.vis.data.render.ArrowType,698
197
+ flare.vis.data.render.EdgeRenderer,5569
198
+ flare.vis.data.render.IRenderer,353
199
+ flare.vis.data.render.ShapeRenderer,2247
200
+ flare.vis.data.ScaleBinding,11275
201
+ flare.vis.data.Tree,7147
202
+ flare.vis.data.TreeBuilder,9930
203
+ flare.vis.events,
204
+ flare.vis.events.DataEvent,2313
205
+ flare.vis.events.SelectionEvent,1880
206
+ flare.vis.events.TooltipEvent,1701
207
+ flare.vis.events.VisualizationEvent,1117
208
+ flare.vis.legend,
209
+ flare.vis.legend.Legend,20859
210
+ flare.vis.legend.LegendItem,4614
211
+ flare.vis.legend.LegendRange,10530
212
+ flare.vis.operator,
213
+ flare.vis.operator.distortion,
214
+ flare.vis.operator.distortion.BifocalDistortion,4461
215
+ flare.vis.operator.distortion.Distortion,6314
216
+ flare.vis.operator.distortion.FisheyeDistortion,3444
217
+ flare.vis.operator.encoder,
218
+ flare.vis.operator.encoder.ColorEncoder,3179
219
+ flare.vis.operator.encoder.Encoder,4060
220
+ flare.vis.operator.encoder.PropertyEncoder,4138
221
+ flare.vis.operator.encoder.ShapeEncoder,1690
222
+ flare.vis.operator.encoder.SizeEncoder,1830
223
+ flare.vis.operator.filter,
224
+ flare.vis.operator.filter.FisheyeTreeFilter,5219
225
+ flare.vis.operator.filter.GraphDistanceFilter,3165
226
+ flare.vis.operator.filter.VisibilityFilter,3509
227
+ flare.vis.operator.IOperator,1286
228
+ flare.vis.operator.label,
229
+ flare.vis.operator.label.Labeler,9956
230
+ flare.vis.operator.label.RadialLabeler,3899
231
+ flare.vis.operator.label.StackedAreaLabeler,3202
232
+ flare.vis.operator.layout,
233
+ flare.vis.operator.layout.AxisLayout,6725
234
+ flare.vis.operator.layout.BundledEdgeRouter,3727
235
+ flare.vis.operator.layout.CircleLayout,9317
236
+ flare.vis.operator.layout.CirclePackingLayout,12003
237
+ flare.vis.operator.layout.DendrogramLayout,4853
238
+ flare.vis.operator.layout.ForceDirectedLayout,8411
239
+ flare.vis.operator.layout.IcicleTreeLayout,4864
240
+ flare.vis.operator.layout.IndentedTreeLayout,3174
241
+ flare.vis.operator.layout.Layout,7881
242
+ flare.vis.operator.layout.NodeLinkTreeLayout,12870
243
+ flare.vis.operator.layout.PieLayout,2728
244
+ flare.vis.operator.layout.RadialTreeLayout,12348
245
+ flare.vis.operator.layout.RandomLayout,870
246
+ flare.vis.operator.layout.StackedAreaLayout,9121
247
+ flare.vis.operator.layout.TreeMapLayout,9191
248
+ flare.vis.operator.Operator,2490
249
+ flare.vis.operator.OperatorList,5248
250
+ flare.vis.operator.OperatorSequence,4190
251
+ flare.vis.operator.OperatorSwitch,2581
252
+ flare.vis.operator.SortOperator,2023
253
+ flare.vis.Visualization,16540
index.html CHANGED
@@ -1,24 +1,14 @@
1
  <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>
13
- You can modify this app directly by editing <i>index.html</i> in the
14
- Files and versions tab.
15
- </p>
16
- <p>
17
- Also don't forget to check the
18
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank"
19
- >Spaces documentation</a
20
- >.
21
- </p>
22
- </div>
23
- </body>
24
- </html>
 
1
  <!DOCTYPE html>
2
+ <meta charset="utf-8">
3
+ <title>Treemap, CSV</title>
4
+ <link rel="stylesheet" type="text/css" href="./inspector.css">
5
+ <body>
6
+ <script type="module">
7
+
8
+ import define from "./index.js";
9
+ import {Runtime, Library, Inspector} from "./runtime.js";
10
+
11
+ const runtime = new Runtime();
12
+ const main = runtime.module(define, Inspector.into(document.body));
13
+
14
+ </script>
 
 
 
 
 
 
 
 
 
 
index.js ADDED
@@ -0,0 +1 @@
 
 
1
+ export {default} from "./a1fd3857bac219b0@480.js";
inspector.css ADDED
@@ -0,0 +1 @@
 
 
1
+ :root{--syntax_normal:#1b1e23;--syntax_comment:#a9b0bc;--syntax_number:#20a5ba;--syntax_keyword:#c30771;--syntax_atom:#10a778;--syntax_string:#008ec4;--syntax_error:#ffbedc;--syntax_unknown_variable:#838383;--syntax_known_variable:#005f87;--syntax_matchbracket:#20bbfc;--syntax_key:#6636b4;--mono_fonts:82%/1.5 Menlo,Consolas,monospace}.observablehq--collapsed,.observablehq--expanded,.observablehq--function,.observablehq--gray,.observablehq--import,.observablehq--string:after,.observablehq--string:before{color:var(--syntax_normal)}.observablehq--collapsed,.observablehq--inspect a{cursor:pointer}.observablehq--field{text-indent:-1em;margin-left:1em}.observablehq--empty{color:var(--syntax_comment)}.observablehq--blue,.observablehq--keyword{color:#3182bd}.observablehq--forbidden,.observablehq--pink{color:#e377c2}.observablehq--orange{color:#e6550d}.observablehq--boolean,.observablehq--null,.observablehq--undefined{color:var(--syntax_atom)}.observablehq--bigint,.observablehq--date,.observablehq--green,.observablehq--number,.observablehq--regexp,.observablehq--symbol{color:var(--syntax_number)}.observablehq--index,.observablehq--key{color:var(--syntax_key)}.observablehq--prototype-key{color:#aaa}.observablehq--empty{font-style:oblique}.observablehq--purple,.observablehq--string{color:var(--syntax_string)}.observablehq--error,.observablehq--red{color:#e7040f}.observablehq--inspect{font:var(--mono_fonts);overflow-x:auto;display:block;white-space:pre}.observablehq--error .observablehq--inspect{word-break:break-all;white-space:pre-wrap}
package.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@d3/treemap",
3
+ "main": "a1fd3857bac219b0@480.js",
4
+ "version": "480.0.0",
5
+ "homepage": "https://observablehq.com/@d3/treemap",
6
+ "author": {
7
+ "name": "D3",
8
+ "url": "https://observablehq.com/@d3"
9
+ },
10
+ "type": "module",
11
+ "peerDependencies": {
12
+ "@observablehq/runtime": "4"
13
+ }
14
+ }
runtime.js ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ // @observablehq/runtime v4.21.0 Copyright 2022 Observable, Inc.
2
+ function e(e,t,n){n=n||{};var r=e.ownerDocument,i=r.defaultView.CustomEvent;"function"==typeof i?i=new i(t,{detail:n}):((i=r.createEvent("Event")).initEvent(t,!1,!1),i.detail=n),e.dispatchEvent(i)}function t(e){return Array.isArray(e)||e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array}function n(e){return e===(0|e)+""}function r(e){const t=document.createElement("span");return t.className="observablehq--cellname",t.textContent=`${e} = `,t}const i=Symbol.prototype.toString;function o(e){return i.call(e)}const{getOwnPropertySymbols:a,prototype:{hasOwnProperty:s}}=Object,{toStringTag:c}=Symbol,l={},u=a;function d(e,t){return s.call(e,t)}function f(e){return e[c]||e.constructor&&e.constructor.name||"Object"}function p(e,t){try{const n=e[t];return n&&n.constructor,n}catch(e){return l}}const h=[{symbol:"@@__IMMUTABLE_INDEXED__@@",name:"Indexed",modifier:!0},{symbol:"@@__IMMUTABLE_KEYED__@@",name:"Keyed",modifier:!0},{symbol:"@@__IMMUTABLE_LIST__@@",name:"List",arrayish:!0},{symbol:"@@__IMMUTABLE_MAP__@@",name:"Map"},{symbol:"@@__IMMUTABLE_ORDERED__@@",name:"Ordered",modifier:!0,prefix:!0},{symbol:"@@__IMMUTABLE_RECORD__@@",name:"Record"},{symbol:"@@__IMMUTABLE_SET__@@",name:"Set",arrayish:!0,setish:!0},{symbol:"@@__IMMUTABLE_STACK__@@",name:"Stack",arrayish:!0}];function m(e){try{let t=h.filter((({symbol:t})=>!0===e[t]));if(!t.length)return;const n=t.find((e=>!e.modifier)),r="Map"===n.name&&t.find((e=>e.modifier&&e.prefix)),i=t.some((e=>e.arrayish)),o=t.some((e=>e.setish));return{name:`${r?r.name:""}${n.name}`,symbols:t,arrayish:i&&!o,setish:o}}catch(e){return null}}const{getPrototypeOf:b,getOwnPropertyDescriptors:v}=Object,_=b({});function w(n,i,o,a){let s,c,l,u,d=t(n);n instanceof Map?n instanceof n.constructor?(s=`Map(${n.size})`,c=y):(s="Map()",c=N):n instanceof Set?n instanceof n.constructor?(s=`Set(${n.size})`,c=g):(s="Set()",c=N):d?(s=`${n.constructor.name}(${n.length})`,c=E):(u=m(n))?(s=`Immutable.${u.name}${"Record"===u.name?"":`(${n.size})`}`,d=u.arrayish,c=u.arrayish?C:u.setish?x:$):a?(s=f(n),c=j):(s=f(n),c=N);const p=document.createElement("span");p.className="observablehq--expanded",o&&p.appendChild(r(o));const h=p.appendChild(document.createElement("a"));h.innerHTML="<svg width=8 height=8 class='observablehq--caret'>\n <path d='M4 7L0 1h8z' fill='currentColor' />\n </svg>",h.appendChild(document.createTextNode(`${s}${d?" [":" {"}`)),h.addEventListener("mouseup",(function(e){e.stopPropagation(),ae(p,O(n,null,o,a))})),c=c(n);for(let e=0;!(l=c.next()).done&&e<20;++e)p.appendChild(l.value);if(!l.done){const t=p.appendChild(document.createElement("a"));t.className="observablehq--field",t.style.display="block",t.appendChild(document.createTextNode(" … more")),t.addEventListener("mouseup",(function(t){t.stopPropagation(),p.insertBefore(l.value,p.lastChild.previousSibling);for(let e=0;!(l=c.next()).done&&e<19;++e)p.insertBefore(l.value,p.lastChild.previousSibling);l.done&&p.removeChild(p.lastChild.previousSibling),e(p,"load")}))}return p.appendChild(document.createTextNode(d?"]":"}")),p}function*y(e){for(const[t,n]of e)yield q(t,n);yield*N(e)}function*g(e){for(const t of e)yield T(t);yield*N(e)}function*x(e){for(const t of e)yield T(t)}function*E(e){for(let t=0,n=e.length;t<n;++t)t in e&&(yield S(t,p(e,t),"observablehq--index"));for(const t in e)!n(t)&&d(e,t)&&(yield S(t,p(e,t),"observablehq--key"));for(const t of u(e))yield S(o(t),p(e,t),"observablehq--symbol")}function*C(e){let t=0;for(const n=e.size;t<n;++t)yield S(t,e.get(t),!0)}function*j(e){for(const t in v(e))yield S(t,p(e,t),"observablehq--key");for(const t of u(e))yield S(o(t),p(e,t),"observablehq--symbol");const t=b(e);t&&t!==_&&(yield P(t))}function*N(e){for(const t in e)d(e,t)&&(yield S(t,p(e,t),"observablehq--key"));for(const t of u(e))yield S(o(t),p(e,t),"observablehq--symbol");const t=b(e);t&&t!==_&&(yield P(t))}function*$(e){for(const[t,n]of e)yield S(t,n,"observablehq--key")}function P(e){const t=document.createElement("div"),n=t.appendChild(document.createElement("span"));return t.className="observablehq--field",n.className="observablehq--prototype-key",n.textContent=" <prototype>",t.appendChild(document.createTextNode(": ")),t.appendChild(oe(e,void 0,void 0,void 0,!0)),t}function S(e,t,n){const r=document.createElement("div"),i=r.appendChild(document.createElement("span"));return r.className="observablehq--field",i.className=n,i.textContent=` ${e}`,r.appendChild(document.createTextNode(": ")),r.appendChild(oe(t)),r}function q(e,t){const n=document.createElement("div");return n.className="observablehq--field",n.appendChild(document.createTextNode(" ")),n.appendChild(oe(e)),n.appendChild(document.createTextNode(" => ")),n.appendChild(oe(t)),n}function T(e){const t=document.createElement("div");return t.className="observablehq--field",t.appendChild(document.createTextNode(" ")),t.appendChild(oe(e)),t}function A(e){const t=window.getSelection();return"Range"===t.type&&(t.containsNode(e,!0)||t.anchorNode.isSelfOrDescendant(e)||t.focusNode.isSelfOrDescendant(e))}function O(e,n,i,o){let a,s,c,l,u=t(e);if(e instanceof Map?e instanceof e.constructor?(a=`Map(${e.size})`,s=L):(a="Map()",s=D):e instanceof Set?e instanceof e.constructor?(a=`Set(${e.size})`,s=M):(a="Set()",s=D):u?(a=`${e.constructor.name}(${e.length})`,s=R):(l=m(e))?(a=`Immutable.${l.name}${"Record"===l.name?"":`(${e.size})`}`,u=l.arrayish,s=l.arrayish?U:l.setish?k:F):(a=f(e),s=D),n){const t=document.createElement("span");return t.className="observablehq--shallow",i&&t.appendChild(r(i)),t.appendChild(document.createTextNode(a)),t.addEventListener("mouseup",(function(n){A(t)||(n.stopPropagation(),ae(t,O(e)))})),t}const d=document.createElement("span");d.className="observablehq--collapsed",i&&d.appendChild(r(i));const p=d.appendChild(document.createElement("a"));p.innerHTML="<svg width=8 height=8 class='observablehq--caret'>\n <path d='M7 4L1 8V0z' fill='currentColor' />\n </svg>",p.appendChild(document.createTextNode(`${a}${u?" [":" {"}`)),d.addEventListener("mouseup",(function(t){A(d)||(t.stopPropagation(),ae(d,w(e,0,i,o)))}),!0),s=s(e);for(let e=0;!(c=s.next()).done&&e<20;++e)e>0&&d.appendChild(document.createTextNode(", ")),d.appendChild(c.value);return c.done||d.appendChild(document.createTextNode(", …")),d.appendChild(document.createTextNode(u?"]":"}")),d}function*L(e){for(const[t,n]of e)yield B(t,n);yield*D(e)}function*M(e){for(const t of e)yield oe(t,!0);yield*D(e)}function*k(e){for(const t of e)yield oe(t,!0)}function*U(e){let t=-1,n=0;for(const r=e.size;n<r;++n)n>t+1&&(yield I(n-t-1)),yield oe(e.get(n),!0),t=n;n>t+1&&(yield I(n-t-1))}function*R(e){let t=-1,r=0;for(const n=e.length;r<n;++r)r in e&&(r>t+1&&(yield I(r-t-1)),yield oe(p(e,r),!0),t=r);r>t+1&&(yield I(r-t-1));for(const t in e)!n(t)&&d(e,t)&&(yield z(t,p(e,t),"observablehq--key"));for(const t of u(e))yield z(o(t),p(e,t),"observablehq--symbol")}function*D(e){for(const t in e)d(e,t)&&(yield z(t,p(e,t),"observablehq--key"));for(const t of u(e))yield z(o(t),p(e,t),"observablehq--symbol")}function*F(e){for(const[t,n]of e)yield z(t,n,"observablehq--key")}function I(e){const t=document.createElement("span");return t.className="observablehq--empty",t.textContent=1===e?"empty":`empty × ${e}`,t}function z(e,t,n){const r=document.createDocumentFragment(),i=r.appendChild(document.createElement("span"));return i.className=n,i.textContent=e,r.appendChild(document.createTextNode(": ")),r.appendChild(oe(t,!0)),r}function B(e,t){const n=document.createDocumentFragment();return n.appendChild(oe(e,!0)),n.appendChild(document.createTextNode(" => ")),n.appendChild(oe(t,!0)),n}function H(e,t){if(e instanceof Date||(e=new Date(+e)),isNaN(e))return"function"==typeof t?t(e):t;const n=e.getUTCHours(),r=e.getUTCMinutes(),i=e.getUTCSeconds(),o=e.getUTCMilliseconds();return`${a=e.getUTCFullYear(),a<0?`-${W(-a,6)}`:a>9999?`+${W(a,6)}`:W(a,4)}-${W(e.getUTCMonth()+1,2)}-${W(e.getUTCDate(),2)}${n||r||i||o?`T${W(n,2)}:${W(r,2)}${i||o?`:${W(i,2)}${o?`.${W(o,3)}`:""}`:""}Z`:""}`;var a}function W(e,t){return`${e}`.padStart(t,"0")}var Z=Error.prototype.toString;var V=RegExp.prototype.toString;function J(e){return e.replace(/[\\`\x00-\x09\x0b-\x19]|\${/g,Y)}function Y(e){var t=e.charCodeAt(0);switch(t){case 8:return"\\b";case 9:return"\\t";case 11:return"\\v";case 12:return"\\f";case 13:return"\\r"}return t<16?"\\x0"+t.toString(16):t<32?"\\x"+t.toString(16):"\\"+e}function G(e,t){for(var n=0;t.exec(e);)++n;return n}var K=Function.prototype.toString,Q={prefix:"async ƒ"},X={prefix:"async ƒ*"},ee={prefix:"class"},te={prefix:"ƒ"},ne={prefix:"ƒ*"};function re(e,t,n){var i=document.createElement("span");i.className="observablehq--function",n&&i.appendChild(r(n));var o=i.appendChild(document.createElement("span"));return o.className="observablehq--keyword",o.textContent=e.prefix,i.appendChild(document.createTextNode(t)),i}const{prototype:{toString:ie}}=Object;function oe(e,t,n,i,a){let s=typeof e;switch(s){case"boolean":case"undefined":e+="";break;case"number":e=0===e&&1/e<0?"-0":e+"";break;case"bigint":e+="n";break;case"symbol":e=o(e);break;case"function":return function(e,t){var n,r,i=K.call(e);switch(e.constructor&&e.constructor.name){case"AsyncFunction":n=Q;break;case"AsyncGeneratorFunction":n=X;break;case"GeneratorFunction":n=ne;break;default:n=/^class\b/.test(i)?ee:te}return n===ee?re(n,"",t):(r=/^(?:async\s*)?(\w+)\s*=>/.exec(i))?re(n,"("+r[1]+")",t):(r=/^(?:async\s*)?\(\s*(\w+(?:\s*,\s*\w+)*)?\s*\)/.exec(i))||(r=/^(?:async\s*)?function(?:\s*\*)?(?:\s*\w+)?\s*\(\s*(\w+(?:\s*,\s*\w+)*)?\s*\)/.exec(i))?re(n,r[1]?"("+r[1].replace(/\s*,\s*/g,", ")+")":"()",t):re(n,"(…)",t)}(e,i);case"string":return function(e,t,n,i){if(!1===t){if(G(e,/["\n]/g)<=G(e,/`|\${/g)){const t=document.createElement("span");i&&t.appendChild(r(i));const n=t.appendChild(document.createElement("span"));return n.className="observablehq--string",n.textContent=JSON.stringify(e),t}const o=e.split("\n");if(o.length>20&&!n){const n=document.createElement("div");i&&n.appendChild(r(i));const a=n.appendChild(document.createElement("span"));a.className="observablehq--string",a.textContent="`"+J(o.slice(0,20).join("\n"));const s=n.appendChild(document.createElement("span")),c=o.length-20;return s.textContent=`Show ${c} truncated line${c>1?"s":""}`,s.className="observablehq--string-expand",s.addEventListener("mouseup",(function(r){r.stopPropagation(),ae(n,oe(e,t,!0,i))})),n}const a=document.createElement("span");i&&a.appendChild(r(i));const s=a.appendChild(document.createElement("span"));return s.className="observablehq--string"+(n?" observablehq--expanded":""),s.textContent="`"+J(e)+"`",a}const o=document.createElement("span");i&&o.appendChild(r(i));const a=o.appendChild(document.createElement("span"));return a.className="observablehq--string",a.textContent=JSON.stringify(e.length>100?`${e.slice(0,50)}…${e.slice(-49)}`:e),o}(e,t,n,i);default:if(null===e){s=null,e="null";break}if(e instanceof Date){s="date",e=H(e,"Invalid Date");break}if(e===l){s="forbidden",e="[forbidden]";break}switch(ie.call(e)){case"[object RegExp]":s="regexp",e=function(e){return V.call(e)}(e);break;case"[object Error]":case"[object DOMException]":s="error",e=function(e){return e.stack||Z.call(e)}(e);break;default:return(n?w:O)(e,t,i,a)}}const c=document.createElement("span");i&&c.appendChild(r(i));const u=c.appendChild(document.createElement("span"));return u.className=`observablehq--${s}`,u.textContent=e,c}function ae(t,n){t.classList.contains("observablehq--inspect")&&n.classList.add("observablehq--inspect"),t.parentNode.replaceChild(n,t),e(n,"load")}const se=/\s+\(\d+:\d+\)$/m;class ce{constructor(e){if(!e)throw new Error("invalid node");this._node=e,e.classList.add("observablehq")}pending(){const{_node:e}=this;e.classList.remove("observablehq--error"),e.classList.add("observablehq--running")}fulfilled(t,n){const{_node:r}=this;if((!function(e){return(e instanceof Element||e instanceof Text)&&e instanceof e.constructor}(t)||t.parentNode&&t.parentNode!==r)&&(t=oe(t,!1,r.firstChild&&r.firstChild.classList&&r.firstChild.classList.contains("observablehq--expanded"),n)).classList.add("observablehq--inspect"),r.classList.remove("observablehq--running","observablehq--error"),r.firstChild!==t)if(r.firstChild){for(;r.lastChild!==r.firstChild;)r.removeChild(r.lastChild);r.replaceChild(t,r.firstChild)}else r.appendChild(t);e(r,"update")}rejected(t,n){const{_node:i}=this;for(i.classList.remove("observablehq--running"),i.classList.add("observablehq--error");i.lastChild;)i.removeChild(i.lastChild);var o=document.createElement("div");o.className="observablehq--inspect",n&&o.appendChild(r(n)),o.appendChild(document.createTextNode((t+"").replace(se,""))),i.appendChild(o),e(i,"error",{error:t})}}ce.into=function(e){if("string"==typeof e&&null==(e=document.querySelector(e)))throw new Error("container not found");return function(){return new ce(e.appendChild(document.createElement("div")))}};var le={},ue={};function de(e){return new Function("d","return {"+e.map((function(e,t){return JSON.stringify(e)+": d["+t+'] || ""'})).join(",")+"}")}function fe(e){var t=Object.create(null),n=[];return e.forEach((function(e){for(var r in e)r in t||n.push(t[r]=r)})),n}function pe(e,t){var n=e+"",r=n.length;return r<t?new Array(t-r+1).join(0)+n:n}function he(e){var t,n=e.getUTCHours(),r=e.getUTCMinutes(),i=e.getUTCSeconds(),o=e.getUTCMilliseconds();return isNaN(e)?"Invalid Date":((t=e.getUTCFullYear())<0?"-"+pe(-t,6):t>9999?"+"+pe(t,6):pe(t,4))+"-"+pe(e.getUTCMonth()+1,2)+"-"+pe(e.getUTCDate(),2)+(o?"T"+pe(n,2)+":"+pe(r,2)+":"+pe(i,2)+"."+pe(o,3)+"Z":i?"T"+pe(n,2)+":"+pe(r,2)+":"+pe(i,2)+"Z":r||n?"T"+pe(n,2)+":"+pe(r,2)+"Z":"")}function me(e){var t=new RegExp('["'+e+"\n\r]"),n=e.charCodeAt(0);function r(e,t){var r,i=[],o=e.length,a=0,s=0,c=o<=0,l=!1;function u(){if(c)return ue;if(l)return l=!1,le;var t,r,i=a;if(34===e.charCodeAt(i)){for(;a++<o&&34!==e.charCodeAt(a)||34===e.charCodeAt(++a););return(t=a)>=o?c=!0:10===(r=e.charCodeAt(a++))?l=!0:13===r&&(l=!0,10===e.charCodeAt(a)&&++a),e.slice(i+1,t-1).replace(/""/g,'"')}for(;a<o;){if(10===(r=e.charCodeAt(t=a++)))l=!0;else if(13===r)l=!0,10===e.charCodeAt(a)&&++a;else if(r!==n)continue;return e.slice(i,t)}return c=!0,e.slice(i,o)}for(10===e.charCodeAt(o-1)&&--o,13===e.charCodeAt(o-1)&&--o;(r=u())!==ue;){for(var d=[];r!==le&&r!==ue;)d.push(r),r=u();t&&null==(d=t(d,s++))||i.push(d)}return i}function i(t,n){return t.map((function(t){return n.map((function(e){return a(t[e])})).join(e)}))}function o(t){return t.map(a).join(e)}function a(e){return null==e?"":e instanceof Date?he(e):t.test(e+="")?'"'+e.replace(/"/g,'""')+'"':e}return{parse:function(e,t){var n,i,o=r(e,(function(e,r){if(n)return n(e,r-1);i=e,n=t?function(e,t){var n=de(e);return function(r,i){return t(n(r),i,e)}}(e,t):de(e)}));return o.columns=i||[],o},parseRows:r,format:function(t,n){return null==n&&(n=fe(t)),[n.map(a).join(e)].concat(i(t,n)).join("\n")},formatBody:function(e,t){return null==t&&(t=fe(e)),i(e,t).join("\n")},formatRows:function(e){return e.map(o).join("\n")},formatRow:o,formatValue:a}}var be=me(","),ve=be.parse,_e=be.parseRows,we=me("\t"),ye=we.parse,ge=we.parseRows;function xe(e){for(var t in e){var n,r,i=e[t].trim();if(i)if("true"===i)i=!0;else if("false"===i)i=!1;else if("NaN"===i)i=NaN;else if(isNaN(n=+i)){if(!(r=i.match(/^([-+]\d{2})?\d{4}(-\d{2}(-\d{2})?)?(T\d{2}:\d{2}(:\d{2}(\.\d{3})?)?(Z|[-+]\d{2}:\d{2})?)?$/)))continue;Ee&&r[4]&&!r[7]&&(i=i.replace(/-/g,"/").replace(/T/," ")),i=new Date(i)}else i=n;else i=null;e[t]=i}return e}const Ee=new Date("2019-01-01T00:00").getHours()||new Date("2019-07-01T00:00").getHours(),Ce=new Map,je=[],Ne=je.map,$e=je.some,Pe=je.hasOwnProperty,Se="https://cdn.jsdelivr.net/npm/",qe=/^((?:@[^/@]+\/)?[^/@]+)(?:@([^/]+))?(?:\/(.*))?$/,Te=/^\d+\.\d+\.\d+(-[\w-.+]+)?$/,Ae=/\.[^/]*$/,Oe=["unpkg","jsdelivr","browser","main"];class RequireError extends Error{constructor(e){super(e)}}function Le(e){const t=qe.exec(e);return t&&{name:t[1],version:t[2],path:t[3]}}function Me(e){const t=`${Se}${e.name}${e.version?`@${e.version}`:""}/package.json`;let n=Ce.get(t);return n||Ce.set(t,n=fetch(t).then((e=>{if(!e.ok)throw new RequireError("unable to load package.json");return e.redirected&&!Ce.has(e.url)&&Ce.set(e.url,n),e.json()}))),n}RequireError.prototype.name=RequireError.name;var ke=Ue((async function(e,t){if(e.startsWith(Se)&&(e=e.substring(Se.length)),/^(\w+:)|\/\//i.test(e))return e;if(/^[.]{0,2}\//i.test(e))return new URL(e,null==t?location:t).href;if(!e.length||/^[\s._]/.test(e)||/\s$/.test(e))throw new RequireError("illegal name");const n=Le(e);if(!n)return`${Se}${e}`;if(!n.version&&null!=t&&t.startsWith(Se)){const e=await Me(Le(t.substring(Se.length)));n.version=e.dependencies&&e.dependencies[n.name]||e.peerDependencies&&e.peerDependencies[n.name]}if(n.path&&!Ae.test(n.path)&&(n.path+=".js"),n.path&&n.version&&Te.test(n.version))return`${Se}${n.name}@${n.version}/${n.path}`;const r=await Me(n);return`${Se}${r.name}@${r.version}/${n.path||function(e){for(const t of Oe){const n=e[t];if("string"==typeof n)return Ae.test(n)?n:`${n}.js`}}(r)||"index.js"}`}));function Ue(e){const t=new Map,n=i(null);function r(e){if("string"!=typeof e)return e;let n=t.get(e);return n||t.set(e,n=new Promise(((t,n)=>{const r=document.createElement("script");r.onload=()=>{try{t(je.pop()(i(e)))}catch(e){n(new RequireError("invalid module"))}r.remove()},r.onerror=()=>{n(new RequireError("unable to load module")),r.remove()},r.async=!0,r.src=e,window.define=Ie,document.head.appendChild(r)}))),n}function i(t){return n=>Promise.resolve(e(n,t)).then(r)}function o(e){return arguments.length>1?Promise.all(Ne.call(arguments,n)).then(Re):n(e)}return o.alias=function(t){return Ue(((n,r)=>n in t&&(r=null,"string"!=typeof(n=t[n]))?n:e(n,r)))},o.resolve=e,o}function Re(e){const t={};for(const n of e)for(const e in n)Pe.call(n,e)&&(null==n[e]?Object.defineProperty(t,e,{get:De(n,e)}):t[e]=n[e]);return t}function De(e,t){return()=>e[t]}function Fe(e){return"exports"===(e+="")||"module"===e}function Ie(e,t,n){const r=arguments.length;r<2?(n=e,t=[]):r<3&&(n=t,t="string"==typeof e?[]:e),je.push($e.call(t,Fe)?e=>{const r={},i={exports:r};return Promise.all(Ne.call(t,(t=>"exports"===(t+="")?r:"module"===t?i:e(t)))).then((e=>(n.apply(null,e),i.exports)))}:e=>Promise.all(Ne.call(t,e)).then((e=>"function"==typeof n?n.apply(null,e):n)))}function ze(e,t,n){return{resolve:(r=n)=>`https://cdn.jsdelivr.net/npm/${e}@${t}/${r}`}}Ie.amd={};const Be=ze("d3","7.4.4","dist/d3.min.js"),He=ze("@observablehq/inputs","0.10.4","dist/inputs.min.js"),We=ze("@observablehq/plot","0.4.3","dist/plot.umd.min.js"),Ze=ze("@observablehq/graphviz","0.2.1","dist/graphviz.min.js"),Ve=ze("@observablehq/highlight.js","2.0.0","highlight.min.js"),Je=ze("@observablehq/katex","0.11.1","dist/katex.min.js"),Ye=ze("lodash","4.17.21","lodash.min.js"),Ge=ze("htl","0.3.1","dist/htl.min.js"),Ke=ze("jszip","3.9.1","dist/jszip.min.js"),Qe=ze("marked","0.3.12","marked.min.js"),Xe=ze("sql.js","1.6.2","dist/sql-wasm.js"),et=ze("vega","5.22.1","build/vega.min.js"),tt=ze("vega-lite","5.2.0","build/vega-lite.min.js"),nt=ze("vega-lite-api","5.0.0","build/vega-lite-api.min.js"),rt=ze("apache-arrow","4.0.1","Arrow.es2015.min.js"),it=ze("arquero","4.8.8","dist/arquero.min.js"),ot=ze("topojson-client","3.1.0","dist/topojson-client.min.js"),at=ze("exceljs","4.3.0","dist/exceljs.min.js"),st=ze("mermaid","9.0.0","dist/mermaid.min.js"),ct=ze("leaflet","1.8.0","dist/leaflet.js");async function lt(e){return(await e(Xe.resolve()))({locateFile:e=>Xe.resolve(`dist/${e}`)})}class SQLiteDatabaseClient{constructor(e){Object.defineProperties(this,{_db:{value:e}})}static async open(e){const[t,n]=await Promise.all([lt(ke),Promise.resolve(e).then(ut)]);return new SQLiteDatabaseClient(new t.Database(n))}async query(e,t){return await async function(e,t,n){const[r]=await e.exec(t,n);if(!r)return[];const{columns:i,values:o}=r,a=o.map((e=>Object.fromEntries(e.map(((e,t)=>[i[t],e])))));return a.columns=i,a}(this._db,e,t)}async queryRow(e,t){return(await this.query(e,t))[0]||null}async explain(e,t){return dt("pre",{className:"observablehq--inspect"},[ft((await this.query(`EXPLAIN QUERY PLAN ${e}`,t)).map((e=>e.detail)).join("\n"))])}async describe(e){const t=await(void 0===e?this.query("SELECT name FROM sqlite_master WHERE type = 'table'"):this.query("SELECT * FROM pragma_table_info(?)",[e]));if(!t.length)throw new Error("Not found");const{columns:n}=t;return dt("table",{value:t},[dt("thead",[dt("tr",n.map((e=>dt("th",[ft(e)]))))]),dt("tbody",t.map((e=>dt("tr",n.map((t=>dt("td",[ft(e[t])])))))))])}async sql(e,...t){return this.query(e.join("?"),t)}}function ut(e){return"string"==typeof e?fetch(e).then(ut):e instanceof Response||e instanceof Blob?e.arrayBuffer().then(ut):e instanceof ArrayBuffer?new Uint8Array(e):e}function dt(e,t,n){2===arguments.length&&(n=t,t=void 0);const r=document.createElement(e);if(void 0!==t)for(const e in t)r[e]=t[e];if(void 0!==n)for(const e of n)r.appendChild(e);return r}function ft(e){return document.createTextNode(e)}Object.defineProperty(SQLiteDatabaseClient.prototype,"dialect",{value:"sqlite"});class Workbook{constructor(e){Object.defineProperties(this,{_:{value:e},sheetNames:{value:e.worksheets.map((e=>e.name)),enumerable:!0}})}sheet(e,t){const n="number"==typeof e?this.sheetNames[e]:this.sheetNames.includes(e+="")?e:null;if(null==n)throw new Error(`Sheet not found: ${e}`);return function(e,{range:t,headers:n}={}){let[[r,i],[o,a]]=function(e=":",{columnCount:t,rowCount:n}){if(!(e+="").match(/^[A-Z]*\d*:[A-Z]*\d*$/))throw new Error("Malformed range specifier");const[[r=0,i=0],[o=t-1,a=n-1]]=e.split(":").map(bt);return[[r,i],[o,a]]}(t,e);const s=n?e._rows[i++]:null;let c=new Set(["#"]);for(let e=r;e<=o;e++){const t=s?pt(s.findCell(e+1)):null;let n=t&&t+""||mt(e);for(;c.has(n);)n+="_";c.add(n)}c=new Array(r).concat(Array.from(c));const l=new Array(a-i+1);for(let t=i;t<=a;t++){const n=l[t-i]=Object.create(null,{"#":{value:t+1}}),a=e.getRow(t+1);if(a.hasValues)for(let e=r;e<=o;e++){const t=pt(a.findCell(e+1));null!=t&&(n[c[e+1]]=t)}}return l.columns=c.filter((()=>!0)),l}(this._.getWorksheet(n),t)}}function pt(e){if(!e)return;const{value:t}=e;if(t&&"object"==typeof t&&!(t instanceof Date)){if(t.formula||t.sharedFormula)return t.result&&t.result.error?NaN:t.result;if(t.richText)return ht(t);if(t.text){let{text:e}=t;return e.richText&&(e=ht(e)),t.hyperlink&&t.hyperlink!==e?`${t.hyperlink} ${e}`:e}return t}return t}function ht(e){return e.richText.map((e=>e.text)).join("")}function mt(e){let t="";e++;do{t=String.fromCharCode(64+(e%26||26))+t}while(e=Math.floor((e-1)/26));return t}function bt(e){const[,t,n]=e.match(/^([A-Z]*)(\d*)$/);let r=0;if(t)for(let e=0;e<t.length;e++)r+=Math.pow(26,t.length-e-1)*(t.charCodeAt(e)-64);return[r?r-1:void 0,n?+n-1:void 0]}async function vt(e){const t=await fetch(await e.url());if(!t.ok)throw new Error(`Unable to load file: ${e.name}`);return t}async function _t(e,t,{array:n=!1,typed:r=!1}={}){const i=await e.text();return("\t"===t?n?ge:ye:n?_e:ve)(i,r&&xe)}class wt{constructor(e,t){Object.defineProperty(this,"name",{value:e,enumerable:!0}),void 0!==t&&Object.defineProperty(this,"mimeType",{value:t+"",enumerable:!0})}async blob(){return(await vt(this)).blob()}async arrayBuffer(){return(await vt(this)).arrayBuffer()}async text(){return(await vt(this)).text()}async json(){return(await vt(this)).json()}async stream(){return(await vt(this)).body}async csv(e){return _t(this,",",e)}async tsv(e){return _t(this,"\t",e)}async image(e){const t=await this.url();return new Promise(((n,r)=>{const i=new Image;new URL(t,document.baseURI).origin!==new URL(location).origin&&(i.crossOrigin="anonymous"),Object.assign(i,e),i.onload=()=>n(i),i.onerror=()=>r(new Error(`Unable to load file: ${this.name}`)),i.src=t}))}async arrow(){const[e,t]=await Promise.all([ke(rt.resolve()),vt(this)]);return e.Table.from(t)}async sqlite(){return SQLiteDatabaseClient.open(vt(this))}async zip(){const[e,t]=await Promise.all([ke(Ke.resolve()),this.arrayBuffer()]);return new ZipArchive(await e.loadAsync(t))}async xml(e="application/xml"){return(new DOMParser).parseFromString(await this.text(),e)}async html(){return this.xml("text/html")}async xlsx(){const[e,t]=await Promise.all([ke(at.resolve()),this.arrayBuffer()]);return new Workbook(await(new e.Workbook).xlsx.load(t))}}class FileAttachment extends wt{constructor(e,t,n){super(t,n),Object.defineProperty(this,"_url",{value:e})}async url(){return await this._url+""}}function yt(e){throw new Error(`File not found: ${e}`)}class ZipArchive{constructor(e){Object.defineProperty(this,"_",{value:e}),this.filenames=Object.keys(e.files).filter((t=>!e.files[t].dir))}file(e){const t=this._.file(e+="");if(!t||t.dir)throw new Error(`file not found: ${e}`);return new ZipArchiveEntry(t)}}class ZipArchiveEntry extends wt{constructor(e){super(e.name),Object.defineProperty(this,"_",{value:e}),Object.defineProperty(this,"_url",{writable:!0})}async url(){return this._url||(this._url=this.blob().then(URL.createObjectURL))}async blob(){return this._.async("blob")}async arrayBuffer(){return this._.async("arraybuffer")}async text(){return this._.async("text")}async json(){return JSON.parse(await this.text())}}var gt={math:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg",xhtml:"http://www.w3.org/1999/xhtml",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};var xt=0;function Et(e){return new Ct("O-"+(null==e?"":e+"-")+ ++xt)}function Ct(e){this.id=e,this.href=new URL(`#${e}`,location)+""}Ct.prototype.toString=function(){return"url("+this.href+")"};var jt={canvas:function(e,t){var n=document.createElement("canvas");return n.width=e,n.height=t,n},context2d:function(e,t,n){null==n&&(n=devicePixelRatio);var r=document.createElement("canvas");r.width=e*n,r.height=t*n,r.style.width=e+"px";var i=r.getContext("2d");return i.scale(n,n),i},download:function(e,t="untitled",n="Save"){const r=document.createElement("a"),i=r.appendChild(document.createElement("button"));async function o(){await new Promise(requestAnimationFrame),URL.revokeObjectURL(r.href),r.removeAttribute("href"),i.textContent=n,i.disabled=!1}return i.textContent=n,r.download=t,r.onclick=async t=>{if(i.disabled=!0,r.href)return o();i.textContent="Saving…";try{const t=await("function"==typeof e?e():e);i.textContent="Download",r.href=URL.createObjectURL(t)}catch(e){i.textContent=n}if(t.eventPhase)return o();i.disabled=!1},r},element:function(e,t){var n,r=e+="",i=r.indexOf(":");i>=0&&"xmlns"!==(r=e.slice(0,i))&&(e=e.slice(i+1));var o=gt.hasOwnProperty(r)?document.createElementNS(gt[r],e):document.createElement(e);if(t)for(var a in t)i=(r=a).indexOf(":"),n=t[a],i>=0&&"xmlns"!==(r=a.slice(0,i))&&(a=a.slice(i+1)),gt.hasOwnProperty(r)?o.setAttributeNS(gt[r],a,n):o.setAttribute(a,n);return o},input:function(e){var t=document.createElement("input");return null!=e&&(t.type=e),t},range:function(e,t,n){1===arguments.length&&(t=e,e=null);var r=document.createElement("input");return r.min=e=null==e?0:+e,r.max=t=null==t?1:+t,r.step=null==n?"any":n=+n,r.type="range",r},select:function(e){var t=document.createElement("select");return Array.prototype.forEach.call(e,(function(e){var n=document.createElement("option");n.value=n.textContent=e,t.appendChild(n)})),t},svg:function(e,t){var n=document.createElementNS("http://www.w3.org/2000/svg","svg");return n.setAttribute("viewBox",[0,0,e,t]),n.setAttribute("width",e),n.setAttribute("height",t),n},text:function(e){return document.createTextNode(e)},uid:Et};var Nt={buffer:function(e){return new Promise((function(t,n){var r=new FileReader;r.onload=function(){t(r.result)},r.onerror=n,r.readAsArrayBuffer(e)}))},text:function(e){return new Promise((function(t,n){var r=new FileReader;r.onload=function(){t(r.result)},r.onerror=n,r.readAsText(e)}))},url:function(e){return new Promise((function(t,n){var r=new FileReader;r.onload=function(){t(r.result)},r.onerror=n,r.readAsDataURL(e)}))}};function $t(){return this}function Pt(e,t){let n=!1;if("function"!=typeof t)throw new Error("dispose is not a function");return{[Symbol.iterator]:$t,next:()=>n?{done:!0}:(n=!0,{done:!1,value:e}),return:()=>(n=!0,t(e),{done:!0}),throw:()=>({done:n=!0})}}function St(e){let t,n,r=!1;const i=e((function(e){n?(n(e),n=null):r=!0;return t=e}));if(null!=i&&"function"!=typeof i)throw new Error("function"==typeof i.then?"async initializers are not supported":"initializer returned something, but not a dispose function");return{[Symbol.iterator]:$t,throw:()=>({done:!0}),return:()=>(null!=i&&i(),{done:!0}),next:function(){return{done:!1,value:r?(r=!1,Promise.resolve(t)):new Promise((e=>n=e))}}}}function qt(e){switch(e.type){case"range":case"number":return e.valueAsNumber;case"date":return e.valueAsDate;case"checkbox":return e.checked;case"file":return e.multiple?e.files:e.files[0];case"select-multiple":return Array.from(e.selectedOptions,(e=>e.value));default:return e.value}}var Tt={disposable:Pt,filter:function*(e,t){for(var n,r=-1;!(n=e.next()).done;)t(n.value,++r)&&(yield n.value)},input:function(e){return St((function(t){var n=function(e){switch(e.type){case"button":case"submit":case"checkbox":return"click";case"file":return"change";default:return"input"}}(e),r=qt(e);function i(){t(qt(e))}return e.addEventListener(n,i),void 0!==r&&t(r),function(){e.removeEventListener(n,i)}}))},map:function*(e,t){for(var n,r=-1;!(n=e.next()).done;)yield t(n.value,++r)},observe:St,queue:function(e){let t;const n=[],r=e((function(e){n.push(e),t&&(t(n.shift()),t=null);return e}));if(null!=r&&"function"!=typeof r)throw new Error("function"==typeof r.then?"async initializers are not supported":"initializer returned something, but not a dispose function");return{[Symbol.iterator]:$t,throw:()=>({done:!0}),return:()=>(null!=r&&r(),{done:!0}),next:function(){return{done:!1,value:n.length?Promise.resolve(n.shift()):new Promise((e=>t=e))}}}},range:function*(e,t,n){e=+e,t=+t,n=(i=arguments.length)<2?(t=e,e=0,1):i<3?1:+n;for(var r=-1,i=0|Math.max(0,Math.ceil((t-e)/n));++r<i;)yield e+r*n},valueAt:function(e,t){if(!(!isFinite(t=+t)||t<0||t!=t|0))for(var n,r=-1;!(n=e.next()).done;)if(++r===t)return n.value},worker:function(e){const t=URL.createObjectURL(new Blob([e],{type:"text/javascript"})),n=new Worker(t);return Pt(n,(()=>{n.terminate(),URL.revokeObjectURL(t)}))}};function At(e,t){return function(n){var r,i,o,a,s,c,l,u,d=n[0],f=[],p=null,h=-1;for(s=1,c=arguments.length;s<c;++s){if((r=arguments[s])instanceof Node)f[++h]=r,d+="\x3c!--o:"+h+"--\x3e";else if(Array.isArray(r)){for(l=0,u=r.length;l<u;++l)(i=r[l])instanceof Node?(null===p&&(f[++h]=p=document.createDocumentFragment(),d+="\x3c!--o:"+h+"--\x3e"),p.appendChild(i)):(p=null,d+=i);p=null}else d+=r;d+=n[s]}if(p=e(d),++h>0){for(o=new Array(h),a=document.createTreeWalker(p,NodeFilter.SHOW_COMMENT,null,!1);a.nextNode();)i=a.currentNode,/^o:/.test(i.nodeValue)&&(o[+i.nodeValue.slice(2)]=i);for(s=0;s<h;++s)(i=o[s])&&i.parentNode.replaceChild(f[s],i)}return 1===p.childNodes.length?p.removeChild(p.firstChild):11===p.nodeType?((i=t()).appendChild(p),i):p}}var Ot=At((function(e){var t=document.createElement("template");return t.innerHTML=e.trim(),document.importNode(t.content,!0)}),(function(){return document.createElement("span")}));function Lt(e){let t;Object.defineProperties(this,{generator:{value:St((e=>{t=e}))},value:{get:()=>e,set:n=>t(e=n)}}),void 0!==e&&t(e)}function*Mt(){for(;;)yield Date.now()}var kt=new Map;function Ut(e,t){var n;return(n=kt.get(e=+e))?n.then((()=>t)):(n=Date.now())>=e?Promise.resolve(t):function(e,t){var n=new Promise((function(n){kt.delete(t);var r=t-e;if(!(r>0))throw new Error("invalid time");if(r>2147483647)throw new Error("too long to wait");setTimeout(n,r)}));return kt.set(t,n),n}(n,e).then((()=>t))}var Rt={delay:function(e,t){return new Promise((function(n){setTimeout((function(){n(t)}),e)}))},tick:function(e,t){return Ut(Math.ceil((Date.now()+1)/e)*e,t)},when:Ut};function Dt(e,t){if(/^(\w+:)|\/\//i.test(e))return e;if(/^[.]{0,2}\//i.test(e))return new URL(e,null==t?location:t).href;if(!e.length||/^[\s._]/.test(e)||/\s$/.test(e))throw new Error("illegal name");return"https://unpkg.com/"+e}function Ft(e){return null==e?ke:Ue(e)}var It=At((function(e){var t=document.createElementNS("http://www.w3.org/2000/svg","g");return t.innerHTML=e.trim(),t}),(function(){return document.createElementNS("http://www.w3.org/2000/svg","g")})),zt=String.raw;function Bt(){return St((function(e){var t=e(document.body.clientWidth);function n(){var n=document.body.clientWidth;n!==t&&e(t=n)}return window.addEventListener("resize",n),function(){window.removeEventListener("resize",n)}}))}var Ht=Object.assign((function(e){const t=Ft(e);var n;Object.defineProperties(this,(n={FileAttachment:()=>yt,Mutable:()=>Lt,now:Mt,width:Bt,dot:()=>t(Ze.resolve()),htl:()=>t(Ge.resolve()),html:()=>Ot,md:()=>function(e){return e(Qe.resolve()).then((function(t){return At((function(n){var r=document.createElement("div");r.innerHTML=t(n,{langPrefix:""}).trim();var i=r.querySelectorAll("pre code[class]");return i.length>0&&e(Ve.resolve()).then((function(t){i.forEach((function(n){function r(){t.highlightBlock(n),n.parentNode.classList.add("observablehq--md-pre")}t.getLanguage(n.className)?r():e(Ve.resolve("async-languages/index.js")).then((r=>{if(r.has(n.className))return e(Ve.resolve("async-languages/"+r.get(n.className))).then((e=>{t.registerLanguage(n.className,e)}))})).then(r,r)}))})),r}),(function(){return document.createElement("div")}))}))}(t),svg:()=>It,tex:()=>function(e){return Promise.all([e(Je.resolve()),(t=Je.resolve("dist/katex.min.css"),new Promise((function(e,n){var r=document.createElement("link");r.rel="stylesheet",r.href=t,r.onerror=n,r.onload=e,document.head.appendChild(r)})))]).then((function(e){var t=e[0],n=r();function r(e){return function(){var n=document.createElement("div");return t.render(zt.apply(String,arguments),n,e),n.removeChild(n.firstChild)}}return n.options=r,n.block=r({displayMode:!0}),n}));var t}(t),_:()=>t(Ye.resolve()),aq:()=>t.alias({"apache-arrow":rt.resolve()})(it.resolve()),Arrow:()=>t(rt.resolve()),d3:()=>t(Be.resolve()),Inputs:()=>t(He.resolve()).then((e=>({...e,file:e.fileOf(wt)}))),L:()=>async function(e){const t=await e(ct.resolve());if(!t._style){const e=document.createElement("link");e.rel="stylesheet",e.href=ct.resolve("dist/leaflet.css"),t._style=document.head.appendChild(e)}return t}(t),mermaid:()=>async function(e){const t=await e(st.resolve());return t.initialize({securityLevel:"loose",theme:"neutral"}),function(){const e=document.createElement("div");return e.innerHTML=t.render(Et().id,String.raw.apply(String,arguments)),e.removeChild(e.firstChild)}}(t),Plot:()=>t(We.resolve()),require:()=>t,resolve:()=>Dt,SQLite:()=>lt(t),SQLiteDatabaseClient:()=>SQLiteDatabaseClient,topojson:()=>t(ot.resolve()),vl:()=>async function(e){const[t,n,r]=await Promise.all([et,tt,nt].map((t=>e(t.resolve()))));return r.register(t,n)}(t),aapl:()=>new FileAttachment("https://static.observableusercontent.com/files/3ccff97fd2d93da734e76829b2b066eafdaac6a1fafdec0faf6ebc443271cfc109d29e80dd217468fcb2aff1e6bffdc73f356cc48feb657f35378e6abbbb63b9").csv({typed:!0}),alphabet:()=>new FileAttachment("https://static.observableusercontent.com/files/75d52e6c3130b1cae83cda89305e17b50f33e7420ef205587a135e8562bcfd22e483cf4fa2fb5df6dff66f9c5d19740be1cfaf47406286e2eb6574b49ffc685d").csv({typed:!0}),cars:()=>new FileAttachment("https://static.observableusercontent.com/files/048ec3dfd528110c0665dfa363dd28bc516ffb7247231f3ab25005036717f5c4c232a5efc7bb74bc03037155cb72b1abe85a33d86eb9f1a336196030443be4f6").csv({typed:!0}),citywages:()=>new FileAttachment("https://static.observableusercontent.com/files/39837ec5121fcc163131dbc2fe8c1a2e0b3423a5d1e96b5ce371e2ac2e20a290d78b71a4fb08b9fa6a0107776e17fb78af313b8ea70f4cc6648fad68ddf06f7a").csv({typed:!0}),diamonds:()=>new FileAttachment("https://static.observableusercontent.com/files/87942b1f5d061a21fa4bb8f2162db44e3ef0f7391301f867ab5ba718b225a63091af20675f0bfe7f922db097b217b377135203a7eab34651e21a8d09f4e37252").csv({typed:!0}),flare:()=>new FileAttachment("https://static.observableusercontent.com/files/a6b0d94a7f5828fd133765a934f4c9746d2010e2f342d335923991f31b14120de96b5cb4f160d509d8dc627f0107d7f5b5070d2516f01e4c862b5b4867533000").csv({typed:!0}),industries:()=>new FileAttachment("https://static.observableusercontent.com/files/76f13741128340cc88798c0a0b7fa5a2df8370f57554000774ab8ee9ae785ffa2903010cad670d4939af3e9c17e5e18e7e05ed2b38b848ac2fc1a0066aa0005f").csv({typed:!0}),miserables:()=>new FileAttachment("https://static.observableusercontent.com/files/31d904f6e21d42d4963ece9c8cc4fbd75efcbdc404bf511bc79906f0a1be68b5a01e935f65123670ed04e35ca8cae3c2b943f82bf8db49c5a67c85cbb58db052").json(),olympians:()=>new FileAttachment("https://static.observableusercontent.com/files/31ca24545a0603dce099d10ee89ee5ae72d29fa55e8fc7c9ffb5ded87ac83060d80f1d9e21f4ae8eb04c1e8940b7287d179fe8060d887fb1f055f430e210007c").csv({typed:!0}),penguins:()=>new FileAttachment("https://static.observableusercontent.com/files/715db1223e067f00500780077febc6cebbdd90c151d3d78317c802732252052ab0e367039872ab9c77d6ef99e5f55a0724b35ddc898a1c99cb14c31a379af80a").csv({typed:!0}),weather:()=>new FileAttachment("https://static.observableusercontent.com/files/693a46b22b33db0f042728700e0c73e836fa13d55446df89120682d55339c6db7cc9e574d3d73f24ecc9bc7eb9ac9a1e7e104a1ee52c00aab1e77eb102913c1f").csv({typed:!0}),DOM:jt,Files:Nt,Generators:Tt,Promises:Rt},Object.fromEntries(Object.entries(n).map(Wt))))}),{resolve:ke.resolve});function Wt([e,t]){return[e,{value:t,writable:!0,enumerable:!0}]}function Zt(e,t){this.message=e+"",this.input=t}Zt.prototype=Object.create(Error.prototype),Zt.prototype.name="RuntimeError",Zt.prototype.constructor=Zt;var Vt=Array.prototype,Jt=Vt.map,Yt=Vt.forEach;function Gt(e){return function(){return e}}function Kt(e){return e}function Qt(){}var Xt={};function en(e,t,n){var r;n||(n=Xt),Object.defineProperties(this,{_observer:{value:n,writable:!0},_definition:{value:rn,writable:!0},_duplicate:{value:void 0,writable:!0},_duplicates:{value:void 0,writable:!0},_indegree:{value:NaN,writable:!0},_inputs:{value:[],writable:!0},_invalidate:{value:Qt,writable:!0},_module:{value:t},_name:{value:null,writable:!0},_outputs:{value:new Set,writable:!0},_promise:{value:Promise.resolve(void 0),writable:!0},_reachable:{value:n!==Xt,writable:!0},_rejector:{value:(r=this,function(e){if(e===rn)throw new Zt(r._name+" is not defined",r._name);if(e instanceof Error&&e.message)throw new Zt(e.message,r._name);throw new Zt(r._name+" could not be resolved",r._name)})},_type:{value:e},_value:{value:void 0,writable:!0},_version:{value:0,writable:!0}})}function tn(e){e._module._runtime._dirty.add(e),e._outputs.add(this)}function nn(e){e._module._runtime._dirty.add(e),e._outputs.delete(this)}function rn(){throw rn}function on(e){return function(){throw new Zt(e+" is defined more than once")}}function an(e,t,n){var r=this._module._scope,i=this._module._runtime;if(this._inputs.forEach(nn,this),t.forEach(tn,this),this._inputs=t,this._definition=n,this._value=void 0,n===Qt?i._variables.delete(this):i._variables.add(this),e!==this._name||r.get(e)!==this){var o,a;if(this._name)if(this._outputs.size)r.delete(this._name),(a=this._module._resolve(this._name))._outputs=this._outputs,this._outputs=new Set,a._outputs.forEach((function(e){e._inputs[e._inputs.indexOf(this)]=a}),this),a._outputs.forEach(i._updates.add,i._updates),i._dirty.add(a).add(this),r.set(this._name,a);else if((a=r.get(this._name))===this)r.delete(this._name);else{if(3!==a._type)throw new Error;a._duplicates.delete(this),this._duplicate=void 0,1===a._duplicates.size&&(a=a._duplicates.keys().next().value,o=r.get(this._name),a._outputs=o._outputs,o._outputs=new Set,a._outputs.forEach((function(e){e._inputs[e._inputs.indexOf(o)]=a})),a._definition=a._duplicate,a._duplicate=void 0,i._dirty.add(o).add(a),i._updates.add(a),r.set(this._name,a))}if(this._outputs.size)throw new Error;e&&((a=r.get(e))?3===a._type?(this._definition=on(e),this._duplicate=n,a._duplicates.add(this)):2===a._type?(this._outputs=a._outputs,a._outputs=new Set,this._outputs.forEach((function(e){e._inputs[e._inputs.indexOf(a)]=this}),this),i._dirty.add(a).add(this),r.set(e,this)):(a._duplicate=a._definition,this._duplicate=n,(o=new en(3,this._module))._name=e,o._definition=this._definition=a._definition=on(e),o._outputs=a._outputs,a._outputs=new Set,o._outputs.forEach((function(e){e._inputs[e._inputs.indexOf(a)]=o})),o._duplicates=new Set([this,a]),i._dirty.add(a).add(o),i._updates.add(a).add(o),r.set(e,o)):r.set(e,this)),this._name=e}return i._updates.add(this),i._compute(),this}function sn(e,t=[]){Object.defineProperties(this,{_runtime:{value:e},_scope:{value:new Map},_builtins:{value:new Map([["invalidation",un],["visibility",dn],...t])},_source:{value:null,writable:!0}})}function cn(e){return e._name}Object.defineProperties(en.prototype,{_pending:{value:function(){this._observer.pending&&this._observer.pending()},writable:!0,configurable:!0},_fulfilled:{value:function(e){this._observer.fulfilled&&this._observer.fulfilled(e,this._name)},writable:!0,configurable:!0},_rejected:{value:function(e){this._observer.rejected&&this._observer.rejected(e,this._name)},writable:!0,configurable:!0},define:{value:function(e,t,n){switch(arguments.length){case 1:n=e,e=t=null;break;case 2:n=t,"string"==typeof e?t=null:(t=e,e=null)}return an.call(this,null==e?null:e+"",null==t?[]:Jt.call(t,this._module._resolve,this._module),"function"==typeof n?n:Gt(n))},writable:!0,configurable:!0},delete:{value:function(){return an.call(this,null,[],Qt)},writable:!0,configurable:!0},import:{value:function(e,t,n){arguments.length<3&&(n=t,t=e);return an.call(this,t+"",[n._resolve(e+"")],Kt)},writable:!0,configurable:!0}}),Object.defineProperties(sn.prototype,{_copy:{value:function(e,t){e._source=this,t.set(this,e);for(const[o,a]of this._scope){var n=e._scope.get(o);if(!n||1!==n._type)if(a._definition===Kt){var r=a._inputs[0],i=r._module;e.import(r._name,o,t.get(i)||(i._source?i._copy(new sn(e._runtime,e._builtins),t):i))}else e.define(o,a._inputs.map(cn),a._definition)}return e},writable:!0,configurable:!0},_resolve:{value:function(e){var t,n=this._scope.get(e);if(!n)if(n=new en(2,this),this._builtins.has(e))n.define(e,Gt(this._builtins.get(e)));else if(this._runtime._builtin._scope.has(e))n.import(e,this._runtime._builtin);else{try{t=this._runtime._global(e)}catch(t){return n.define(e,(r=t,function(){throw r}))}void 0===t?this._scope.set(n._name=e,n):n.define(e,Gt(t))}var r;return n},writable:!0,configurable:!0},redefine:{value:function(e){var t=this._scope.get(e);if(!t)throw new Zt(e+" is not defined");if(3===t._type)throw new Zt(e+" is defined more than once");return t.define.apply(t,arguments)},writable:!0,configurable:!0},define:{value:function(){var e=new en(1,this);return e.define.apply(e,arguments)},writable:!0,configurable:!0},derive:{value:function(e,t){var n=new sn(this._runtime,this._builtins);return n._source=this,Yt.call(e,(function(e){"object"!=typeof e&&(e={name:e+""}),null==e.alias&&(e.alias=e.name),n.import(e.name,e.alias,t)})),Promise.resolve().then((()=>{const e=new Set([this]);for(const t of e)for(const n of t._scope.values())if(n._definition===Kt){const t=n._inputs[0]._module,r=t._source||t;if(r===this)return void console.warn("circular module definition; ignoring");e.add(r)}this._copy(n,new Map)})),n},writable:!0,configurable:!0},import:{value:function(){var e=new en(1,this);return e.import.apply(e,arguments)},writable:!0,configurable:!0},value:{value:async function(e){var t=this._scope.get(e);if(!t)throw new Zt(e+" is not defined");t._observer===Xt&&(t._observer=!0,this._runtime._dirty.add(t));return await this._runtime._compute(),t._promise},writable:!0,configurable:!0},variable:{value:function(e){return new en(1,this,e)},writable:!0,configurable:!0},builtin:{value:function(e,t){this._builtins.set(e,t)},writable:!0,configurable:!0}});const ln="function"==typeof requestAnimationFrame?requestAnimationFrame:"function"==typeof setImmediate?setImmediate:e=>setTimeout(e,0);var un={},dn={};function fn(e=new Ht,t=gn){var n=this.module();if(Object.defineProperties(this,{_dirty:{value:new Set},_updates:{value:new Set},_precomputes:{value:[],writable:!0},_computing:{value:null,writable:!0},_init:{value:null,writable:!0},_modules:{value:new Map},_variables:{value:new Set},_disposed:{value:!1,writable:!0},_builtin:{value:n},_global:{value:t}}),e)for(var r in e)new en(2,n).define(r,[],e[r])}function pn(e){const t=new Set(e._inputs);for(const n of t){if(n===e)return!0;n._inputs.forEach(t.add,t)}return!1}function hn(e){++e._indegree}function mn(e){--e._indegree}function bn(e){return e._promise.catch(e._rejector)}function vn(e){return new Promise((function(t){e._invalidate=t}))}function _n(e,t){let n,r,i="function"==typeof IntersectionObserver&&t._observer&&t._observer._node,o=!i,a=Qt,s=Qt;return i&&(r=new IntersectionObserver((([e])=>(o=e.isIntersecting)&&(n=null,a()))),r.observe(i),e.then((()=>(r.disconnect(),r=null,s())))),function(e){return o?Promise.resolve(e):r?(n||(n=new Promise(((e,t)=>(a=e,s=t)))),n.then((()=>e))):Promise.reject()}}function wn(e){e._invalidate(),e._invalidate=Qt,e._pending();const t=e._value,n=++e._version;let r=null;const i=e._promise=(e._inputs.length?Promise.all(e._inputs.map(bn)).then((function(i){if(e._version!==n)return;for(var o=0,a=i.length;o<a;++o)switch(i[o]){case un:i[o]=r=vn(e);break;case dn:r||(r=vn(e)),i[o]=_n(r,e)}return e._definition.apply(t,i)})):new Promise((n=>n(e._definition.call(t))))).then((function(t){if(function(e){return e&&"function"==typeof e.next&&"function"==typeof e.return}(t))return e._version!==n?void t.return():((r||vn(e)).then((i=t,function(){i.return()})),function(e,t,n){const r=e._module._runtime;let i;function o(e){return new Promise((e=>e(n.next(i)))).then((({done:t,value:n})=>t?void 0:Promise.resolve(n).then(e)))}function a(){const n=o((o=>{if(e._version===t)return i=o,s(o,n).then((()=>r._precompute(a))),e._fulfilled(o),o}));n.catch((r=>{e._version===t&&(s(void 0,n),e._rejected(r))}))}function s(t,n){return e._value=t,e._promise=n,e._outputs.forEach(r._updates.add,r._updates),r._compute()}return o((n=>{if(e._version===t)return i=n,r._precompute(a),n}))}(e,n,t));var i;return t}));i.then((t=>{e._version===n&&(e._value=t,e._fulfilled(t))}),(t=>{e._version===n&&(e._value=void 0,e._rejected(t))}))}function yn(e,t){e._invalidate(),e._invalidate=Qt,e._pending(),++e._version,e._indegree=NaN,(e._promise=Promise.reject(t)).catch(Qt),e._value=void 0,e._rejected(t)}function gn(e){return window[e]}Object.defineProperties(fn,{load:{value:function(e,t,n){if("function"==typeof t&&(n=t,t=null),"function"!=typeof n)throw new Error("invalid observer");null==t&&(t=new Ht);const{modules:r,id:i}=e,o=new Map,a=new fn(t),s=c(i);function c(e){let t=o.get(e);return t||o.set(e,t=a.module()),t}for(const e of r){const t=c(e.id);let r=0;for(const i of e.variables)i.from?t.import(i.remote,i.name,c(i.from)):t===s?t.variable(n(i,r,e.variables)).define(i.name,i.inputs,i.value):t.define(i.name,i.inputs,i.value),++r}return a},writable:!0,configurable:!0}}),Object.defineProperties(fn.prototype,{_precompute:{value:function(e){this._precomputes.push(e),this._compute()},writable:!0,configurable:!0},_compute:{value:function(){return this._computing||(this._computing=this._computeSoon())},writable:!0,configurable:!0},_computeSoon:{value:function(){return new Promise(ln).then((()=>this._disposed?void 0:this._computeNow()))},writable:!0,configurable:!0},_computeNow:{value:async function(){var e,t,n=[],r=this._precomputes;if(r.length){this._precomputes=[];for(const e of r)e();await function(e=0){let t=Promise.resolve();for(let n=0;n<e;++n)t=t.then((()=>{}));return t}(3)}(e=new Set(this._dirty)).forEach((function(t){t._inputs.forEach(e.add,e);const n=function(e){if(e._observer!==Xt)return!0;var t=new Set(e._outputs);for(const e of t){if(e._observer!==Xt)return!0;e._outputs.forEach(t.add,t)}return!1}(t);n>t._reachable?this._updates.add(t):n<t._reachable&&t._invalidate(),t._reachable=n}),this),(e=new Set(this._updates)).forEach((function(t){t._reachable?(t._indegree=0,t._outputs.forEach(e.add,e)):(t._indegree=NaN,e.delete(t))})),this._computing=null,this._updates.clear(),this._dirty.clear(),e.forEach((function(e){e._outputs.forEach(hn)}));do{for(e.forEach((function(e){0===e._indegree&&n.push(e)}));t=n.pop();)wn(t),t._outputs.forEach(i),e.delete(t);e.forEach((function(t){pn(t)&&(yn(t,new Zt("circular definition")),t._outputs.forEach(mn),e.delete(t))}))}while(e.size);function i(e){0==--e._indegree&&n.push(e)}},writable:!0,configurable:!0},dispose:{value:function(){this._computing=Promise.resolve(),this._disposed=!0,this._variables.forEach((e=>{e._invalidate(),e._version=NaN}))},writable:!0,configurable:!0},module:{value:function(e,t=Qt){let n;if(void 0===e)return(n=this._init)?(this._init=null,n):new sn(this);if(n=this._modules.get(e),n)return n;this._init=n=new sn(this),this._modules.set(e,n);try{e(this,t)}finally{this._init=null}return n},writable:!0,configurable:!0},fileAttachments:{value:function(e){return Object.assign((t=>{const n=e(t+="");if(null==n)throw new Error(`File not found: ${t}`);if("object"==typeof n&&"url"in n){const{url:e,mimeType:r}=n;return new FileAttachment(e,t,r)}return new FileAttachment(n,t)}),{prototype:FileAttachment.prototype})},writable:!0,configurable:!0}});export{ce as Inspector,Ht as Library,fn as Runtime,Zt as RuntimeError};