@vite-hub/ui 0.1.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +244 -18
- package/dist/attachments-BzTwqRTU.js +90 -0
- package/dist/choices-input-ByXJvDn1.d.ts +94 -0
- package/dist/{code-view-J4OsgEdh.js → code-view-D0bqhogi.js} +20 -4
- package/dist/colors-BghReA9C-CjF9gnmy.js +28 -0
- package/dist/comment-composer-Cc8Jvu6u.d.ts +243 -0
- package/dist/comment-composer-jYv2ULNP.js +591 -0
- package/dist/comment-layer-ClH4MLj4.d.ts +165 -0
- package/dist/comment-list-B8hphLfS.d.ts +62 -0
- package/dist/comment-marks.css +234 -0
- package/dist/comment-panel-fcKSKwLC.d.ts +197 -0
- package/dist/comment-person-CLPlW_SS.js +40 -0
- package/dist/comment-pin-CvwgRSDR.d.ts +68 -0
- package/dist/comment-row-Bbm9WwuF.js +39 -0
- package/dist/comment-thread-CoTLrdal.d.ts +368 -0
- package/dist/comment-visibility-DsVuVndP.d.ts +40 -0
- package/dist/{comments-ChNJkV1d.d.ts → comments-Bx2WRsYy.d.ts} +69 -7
- package/dist/{comments-C08J3z4e.js → comments-CkWc2Khc.js} +155 -60
- package/dist/comments-context-C2lOZyQ5.js +38 -0
- package/dist/config-DgxBW013.d.ts +80 -0
- package/dist/config-Dk67emQt.js +63 -0
- package/dist/copy-button-CRN3kmSD.js +253 -0
- package/dist/draw-DzSmD7uo-Dwz8zoH2.js +72976 -0
- package/dist/editor-C_wt4RRV.js +582 -0
- package/dist/error-diagnostics-SXtnk6bz.js +38 -0
- package/dist/{file-tree-C1pv4_AI.js → file-tree-C4OYgbV-.js} +292 -145
- package/dist/{file-tree-Ctb8hZ_g.d.ts → file-tree-DlT9RGhu.d.ts} +51 -15
- package/dist/format-Du58PlsG.js +18 -0
- package/dist/handlers-DMl-Na3x.js +182 -0
- package/dist/headless.d.ts +5 -176
- package/dist/headless.js +5 -3
- package/dist/icon-swap.css +69 -0
- package/dist/{image-preview-VfknBEFu.js → image-preview-C9tdkmEj.js} +8 -5
- package/dist/{index-DcH0QSI5.d.ts → index-BD1e8vx5.d.ts} +8 -0
- package/dist/{code-view-vDM-hph-.d.ts → index-CNY1uNTh.d.ts} +14 -228
- package/dist/index.d.ts +53 -56
- package/dist/index.js +677 -25
- package/dist/markdown-editor-CMbNZOdN.js +2394 -0
- package/dist/markdown-editor-DqdZfIEn.d.ts +195 -0
- package/dist/markdown-editor.d.ts +108 -0
- package/dist/markdown-editor.js +3 -0
- package/dist/message-scroller-Bm1YWTeY.d.ts +175 -0
- package/dist/nuxt-ui-DSQFzq3s.js +38 -0
- package/dist/nuxt.d.ts +84 -2
- package/dist/nuxt.js +237 -35
- package/dist/parts/components/agent-session.d.ts +254 -0
- package/dist/parts/components/agent-session.js +640 -0
- package/dist/{attachment-BBndG9_P.d.ts → parts/components/attachment.d.ts} +13 -14
- package/dist/{attachment-B3dXC7jM.js → parts/components/attachment.js} +6 -4
- package/dist/{avatar-stack.d.ts → parts/components/avatar-stack.d.ts} +1 -1
- package/dist/{avatar-stack-DM6HRnc0.js → parts/components/avatar-stack.js} +2 -5
- package/dist/{bubble-BJH2rfii.d.ts → parts/components/bubble.d.ts} +8 -9
- package/dist/{bubble-BPyFQlW7.js → parts/components/bubble.js} +2 -2
- package/dist/{chat-message-mpDmZbIC.d.ts → parts/components/chat-message.d.ts} +2 -3
- package/dist/{chat-message-BNK9G7xF.js → parts/components/chat-message.js} +4 -4
- package/dist/{chat-session-D6C7VJBR.d.ts → parts/components/chat-session.d.ts} +3 -4
- package/dist/{chat-session-DYEHB1HC.js → parts/components/chat-session.js} +2 -2
- package/dist/{chat-B9HlZWA2.d.ts → parts/components/chat.d.ts} +8 -4
- package/dist/{chat-BoFHlu9V.js → parts/components/chat.js} +42 -9
- package/dist/{highlighted-code-Dzf6o54i.d.ts → parts/components/code-block.d.ts} +16 -24
- package/dist/{code-block-Br-02hn-.js → parts/components/code-block.js} +9 -38
- package/dist/parts/components/code-view.d.ts +270 -0
- package/dist/parts/components/code-view.js +2 -0
- package/dist/parts/components/comment-composer.d.ts +2 -0
- package/dist/parts/components/comment-composer.js +2 -0
- package/dist/parts/components/comment-layer.d.ts +2 -0
- package/dist/parts/components/comment-layer.js +618 -0
- package/dist/parts/components/comment-list.d.ts +2 -0
- package/dist/parts/components/comment-list.js +167 -0
- package/dist/parts/components/comment-panel.d.ts +2 -0
- package/dist/parts/components/comment-panel.js +299 -0
- package/dist/parts/components/comment-pin.d.ts +2 -0
- package/dist/parts/components/comment-pin.js +75 -0
- package/dist/parts/components/comment-thread.d.ts +2 -0
- package/dist/parts/components/comment-thread.js +571 -0
- package/dist/parts/components/comments.d.ts +7 -0
- package/dist/parts/components/comments.js +8 -0
- package/dist/{connection-status-DjGBw6xX.d.ts → parts/components/connection-status.d.ts} +6 -7
- package/dist/{connection-status-CzuWBENf.js → parts/components/connection-status.js} +1 -1
- package/dist/parts/components/copy-button.d.ts +118 -0
- package/dist/parts/components/copy-button.js +2 -0
- package/dist/parts/components/device-frame.d.ts +130 -0
- package/dist/parts/components/device-frame.js +471 -0
- package/dist/parts/components/file-tree.d.ts +2 -0
- package/dist/parts/components/file-tree.js +2 -0
- package/dist/parts/components/filter-search.d.ts +47 -0
- package/dist/parts/components/filter-search.js +58 -0
- package/dist/parts/components/markdown-editor.d.ts +2 -0
- package/dist/parts/components/markdown-editor.js +2 -0
- package/dist/parts/components/markdown-renderer.d.ts +52 -0
- package/dist/parts/components/markdown-renderer.js +23077 -0
- package/dist/{markdown-Dse5ldJe.d.ts → parts/components/markdown.d.ts} +7 -7
- package/dist/parts/components/markdown.js +47 -0
- package/dist/{marker-ea-tvx-J.d.ts → parts/components/marker.d.ts} +5 -6
- package/dist/{marker-Di2ZG_k1.js → parts/components/marker.js} +2 -2
- package/dist/{message-parts-BBFUkluC.d.ts → parts/components/message-parts.d.ts} +2 -3
- package/dist/{message-parts-DQnfioAH.js → parts/components/message-parts.js} +6 -6
- package/dist/{message-CW_paC1k.d.ts → parts/components/message.d.ts} +8 -9
- package/dist/{message-DiyBthIq.js → parts/components/message.js} +2 -2
- package/dist/parts/components/patch-parsers.d.ts +2 -0
- package/dist/parts/components/patch-parsers.js +2 -0
- package/dist/{prompt-input-Cy_Ue6B5.d.ts → parts/components/prompt-input.d.ts} +54 -11
- package/dist/{prompt-input-BbnCb80O.js → parts/components/prompt-input.js} +66 -111
- package/dist/parts/components/relative-time.d.ts +73 -0
- package/dist/parts/components/relative-time.js +2 -0
- package/dist/parts/components/status.d.ts +60 -0
- package/dist/parts/components/status.js +48 -0
- package/dist/{sync-status-refELOZn.d.ts → parts/components/sync-status.d.ts} +5 -6
- package/dist/{sync-status-BpxYdZIJ.js → parts/components/sync-status.js} +1 -1
- package/dist/{tool-list-E7CA52rz.d.ts → parts/components/tool-list.d.ts} +3 -4
- package/dist/{tool-list-BdSr5CT4.js → parts/components/tool-list.js} +7 -38
- package/dist/{trace-run-COeXn46Z.d.ts → parts/components/trace-run.d.ts} +3 -4
- package/dist/{trace-run-BIQ17CED.js → parts/components/trace-run.js} +15 -23
- package/dist/{trace-V7rM3Pyd.d.ts → parts/components/trace.d.ts} +10 -11
- package/dist/{trace-llBCDiSW.js → parts/components/trace.js} +20 -13
- package/dist/parts/composables/attachments.d.ts +32 -0
- package/dist/parts/composables/attachments.js +2 -0
- package/dist/parts/composables/highlighted-code.d.ts +9 -0
- package/dist/{highlighted-code-Ck4zexJX.js → parts/composables/highlighted-code.js} +5 -2
- package/dist/parts/headless/choices-input.d.ts +2 -0
- package/dist/parts/headless/choices-input.js +162 -0
- package/dist/parts/headless/comment-visibility.d.ts +2 -0
- package/dist/parts/headless/comment-visibility.js +128 -0
- package/dist/parts/headless/comments.d.ts +2 -0
- package/dist/parts/headless/comments.js +2 -0
- package/dist/parts/headless/message-scroller.d.ts +2 -0
- package/dist/{message-scroller-CX6NJTdm.js → parts/headless/message-scroller.js} +2 -2
- package/dist/parts/playground/highlight.d.ts +5 -0
- package/dist/parts/playground/highlight.js +23 -0
- package/dist/parts/playground/paths.d.ts +4 -0
- package/dist/parts/playground/paths.js +7 -0
- package/dist/parts/playground/playground-render.d.ts +126 -0
- package/dist/parts/playground/playground-render.js +356 -0
- package/dist/parts/playground/share.d.ts +2 -0
- package/dist/parts/playground/share.js +92 -0
- package/dist/parts/playground/zip.d.ts +6 -0
- package/dist/parts/playground/zip.js +76 -0
- package/dist/parts/workspace/browser-support-notice.d.ts +76 -0
- package/dist/parts/workspace/browser-support-notice.js +105 -0
- package/dist/parts/workspace/codemirror.d.ts +16 -0
- package/dist/parts/workspace/codemirror.js +243 -0
- package/dist/parts/workspace/connect-panel.d.ts +129 -0
- package/dist/parts/workspace/connect-panel.js +285 -0
- package/dist/parts/workspace/connect-store.d.ts +26 -0
- package/dist/parts/workspace/connect-store.js +59 -0
- package/dist/parts/workspace/icons.d.ts +34 -0
- package/dist/parts/workspace/icons.js +46 -0
- package/dist/parts/workspace/playground-container.d.ts +192 -0
- package/dist/parts/workspace/playground-container.js +603 -0
- package/dist/parts/workspace/workspace-boot-status.d.ts +75 -0
- package/dist/parts/workspace/workspace-boot-status.js +207 -0
- package/dist/parts/workspace/workspace-editor.d.ts +43 -0
- package/dist/parts/workspace/workspace-editor.js +54 -0
- package/dist/parts/workspace/workspace-file-tree.d.ts +53 -0
- package/dist/parts/workspace/workspace-file-tree.js +68 -0
- package/dist/parts/workspace/workspace-preview.d.ts +72 -0
- package/dist/parts/workspace/workspace-preview.js +307 -0
- package/dist/parts/workspace/workspace-shell.d.ts +88 -0
- package/dist/parts/workspace/workspace-shell.js +291 -0
- package/dist/parts/workspace/workspace-terminal.d.ts +39 -0
- package/dist/parts/workspace/workspace-terminal.js +130 -0
- package/dist/payload-text-sjkYAwvw.js +32 -0
- package/dist/{pierre-code-view-T7V67hwT.js → pierre-code-view-xgBL6DO7.js} +209 -86
- package/dist/{pierre-dark-DDWDl8g6.js → pierre-dark-CzUmjETS.js} +3 -1
- package/dist/{pierre-light-CWhW4NrH.js → pierre-light-Dn6E0sWv.js} +3 -1
- package/dist/playground.d.ts +4 -0
- package/dist/playground.js +4 -0
- package/dist/relative-time-BVmjOsYG.js +309 -0
- package/dist/rolldown-runtime-C9mWXvCC.js +29 -0
- package/dist/runtime/nuxt-plugin.js +23 -4
- package/dist/sankey-CAYwt82B-D4uDQoMR.js +2887 -0
- package/dist/share-DM4eNy4q.d.ts +37 -0
- package/dist/{slot-part-C7Ocxn3b.js → slot-part-Doic71uh.js} +7 -1
- package/dist/styles.css +2465 -594
- package/dist/temml-BilSAAws.js +12362 -0
- package/dist/theme-focus-ring.css +42 -0
- package/dist/theme.css +376 -0
- package/dist/theme.d.ts +355 -0
- package/dist/theme.js +265 -0
- package/dist/{types-CqDwuJAm.d.ts → types-Dyr6CfBW.d.ts} +1 -1
- package/dist/vue-BDmSCtay.js +30779 -0
- package/dist/vue-DGstVdGn.js +2492 -0
- package/dist/workspace.d.ts +15 -0
- package/dist/workspace.js +12 -0
- package/package.json +136 -150
- package/dist/andromeeda-BASpqCeJ.js +0 -4
- package/dist/attachment.d.ts +0 -2
- package/dist/attachment.js +0 -2
- package/dist/aurora-x-DugsLcii.js +0 -4
- package/dist/avatar-stack.js +0 -2
- package/dist/ayu-dark-BT3qdi3o.js +0 -4
- package/dist/ayu-light-BVZyHoh9.js +0 -4
- package/dist/ayu-mirage-XFwUVZQZ.js +0 -4
- package/dist/bubble.d.ts +0 -2
- package/dist/bubble.js +0 -2
- package/dist/catppuccin-frappe-D20KODDN.js +0 -4
- package/dist/catppuccin-latte-eGLVHIUJ.js +0 -4
- package/dist/catppuccin-macchiato-bQGch4PY.js +0 -4
- package/dist/catppuccin-mocha-Bes8-0Mr.js +0 -4
- package/dist/chat-message.d.ts +0 -2
- package/dist/chat-message.js +0 -2
- package/dist/chat-session.d.ts +0 -2
- package/dist/chat-session.js +0 -2
- package/dist/chat.d.ts +0 -2
- package/dist/chat.js +0 -2
- package/dist/code-block.d.ts +0 -2
- package/dist/code-block.js +0 -3
- package/dist/code-view.d.ts +0 -2
- package/dist/code-view.js +0 -2
- package/dist/comment-layer-CBlxJ8eK.js +0 -1113
- package/dist/comments-Cq5eewsu.d.ts +0 -537
- package/dist/comments.d.ts +0 -2
- package/dist/comments.js +0 -2
- package/dist/config-Bux_AJzm.d.ts +0 -29
- package/dist/config-bHqE4JOs.js +0 -38
- package/dist/connection-status.d.ts +0 -2
- package/dist/connection-status.js +0 -2
- package/dist/dark-plus-BGuiqa1B.js +0 -4
- package/dist/dracula-0CVA2XY5.js +0 -4
- package/dist/dracula-soft-Dk9bpbVU.js +0 -4
- package/dist/error-diagnostics-B4hMpJRL.js +0 -13
- package/dist/everforest-dark-CRjTbhh5.js +0 -4
- package/dist/everforest-light-CEeYFLn8.js +0 -4
- package/dist/file-diff.d.ts +0 -2
- package/dist/file-diff.js +0 -2
- package/dist/file-tree.d.ts +0 -2
- package/dist/file-tree.js +0 -2
- package/dist/file-view.d.ts +0 -2
- package/dist/file-view.js +0 -2
- package/dist/github-dark-BXgKmOw_.js +0 -4
- package/dist/github-dark-default-DzJQXksd.js +0 -4
- package/dist/github-dark-dimmed-B1pEmGtS.js +0 -4
- package/dist/github-dark-high-contrast-BkHIa6jc.js +0 -4
- package/dist/github-light-BKRlUbaB.js +0 -4
- package/dist/github-light-default-BU3eYkzs.js +0 -4
- package/dist/github-light-high-contrast-B3MumDcI.js +0 -4
- package/dist/gruvbox-dark-hard-B0ecF443.js +0 -4
- package/dist/gruvbox-dark-medium-BQnpC39k.js +0 -4
- package/dist/gruvbox-dark-soft-DFZUgESr.js +0 -4
- package/dist/gruvbox-light-hard-CuB_LOJr.js +0 -4
- package/dist/gruvbox-light-medium-idDHgxjs.js +0 -4
- package/dist/gruvbox-light-soft-CfWH49MY.js +0 -4
- package/dist/horizon-bright-Ba6M8QSV.js +0 -4
- package/dist/horizon-h92C5OlZ.js +0 -4
- package/dist/houston-EQnPegWq.js +0 -4
- package/dist/kanagawa-dragon-DgDvwi3B.js +0 -4
- package/dist/kanagawa-lotus-BgoQro20.js +0 -4
- package/dist/kanagawa-wave-DgXEowHs.js +0 -4
- package/dist/laserwave-IxBH_3yW.js +0 -4
- package/dist/light-plus-S8JBx6is.js +0 -4
- package/dist/markdown-BoLBN0qH.js +0 -197
- package/dist/markdown.d.ts +0 -2
- package/dist/markdown.js +0 -2
- package/dist/marker.d.ts +0 -2
- package/dist/marker.js +0 -2
- package/dist/material-theme-D1f3HBq-.js +0 -4
- package/dist/material-theme-darker-ExzYhT0j.js +0 -4
- package/dist/material-theme-lighter-D6gH9nnA.js +0 -4
- package/dist/material-theme-ocean-D1w5BPAa.js +0 -4
- package/dist/material-theme-palenight-CkqWmVpF.js +0 -4
- package/dist/message-parts.d.ts +0 -2
- package/dist/message-parts.js +0 -2
- package/dist/message.d.ts +0 -2
- package/dist/message.js +0 -2
- package/dist/min-dark-npsJH98j.js +0 -4
- package/dist/min-light-DUk1XsVt.js +0 -4
- package/dist/monokai-CfFRWUNl.js +0 -4
- package/dist/multi-file-diff.d.ts +0 -2
- package/dist/multi-file-diff.js +0 -2
- package/dist/night-owl-BS7V-av_.js +0 -4
- package/dist/night-owl-light-CZtRawYE.js +0 -4
- package/dist/nord-BFh54Nqz.js +0 -4
- package/dist/one-dark-pro-zDovGosB.js +0 -4
- package/dist/one-light-gmHK3iK6.js +0 -4
- package/dist/patch-diff.d.ts +0 -2
- package/dist/patch-diff.js +0 -2
- package/dist/plastic-DtdaCjub.js +0 -4
- package/dist/poimandres-Hdda6aHK.js +0 -4
- package/dist/primitive-rail.d.ts +0 -222
- package/dist/primitive-rail.js +0 -348
- package/dist/prompt-input.d.ts +0 -2
- package/dist/prompt-input.js +0 -2
- package/dist/red-VqZFRByZ.js +0 -4
- package/dist/rose-pine-DiTkEueR.js +0 -4
- package/dist/rose-pine-dawn-tfo5y2X0.js +0 -4
- package/dist/rose-pine-moon-C0gON9XN.js +0 -4
- package/dist/runtime-type-DlCscMfw.js +0 -59
- package/dist/slack-dark-v8P_eXr6.js +0 -4
- package/dist/slack-ochin-D8SyEdKz.js +0 -4
- package/dist/snazzy-light-BtkQkvXb.js +0 -4
- package/dist/solarized-dark-B8nAdMfM.js +0 -4
- package/dist/solarized-light-B-3F1INj.js +0 -4
- package/dist/sync-status.d.ts +0 -2
- package/dist/sync-status.js +0 -2
- package/dist/synthwave-84-DcsXCF_c.js +0 -4
- package/dist/tokyo-night-Bvpqduda.js +0 -4
- package/dist/tool-list.d.ts +0 -2
- package/dist/tool-list.js +0 -2
- package/dist/trace-run.d.ts +0 -2
- package/dist/trace-run.js +0 -2
- package/dist/trace.d.ts +0 -2
- package/dist/trace.js +0 -2
- package/dist/unresolved-file.d.ts +0 -2
- package/dist/unresolved-file.js +0 -2
- package/dist/vesper-CfxmMOy3.js +0 -4
- package/dist/vitesse-black-D9-_1mjV.js +0 -4
- package/dist/vitesse-dark-DlSMLlr9.js +0 -4
- package/dist/vitesse-light-KRWWWztf.js +0 -4
|
@@ -0,0 +1,2887 @@
|
|
|
1
|
+
import { t as __commonJSMin } from "./rolldown-runtime-C9mWXvCC.js";
|
|
2
|
+
import { n as SERIES, t as INK } from "./colors-BghReA9C-CjF9gnmy.js";
|
|
3
|
+
import { PADDING, boxes, format, render } from "./draw-DzSmD7uo-Dwz8zoH2.js";
|
|
4
|
+
//#region ../../node_modules/.pnpm/d3-array@2.12.1/node_modules/d3-array/dist/d3-array.js
|
|
5
|
+
var require_d3_array = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
6
|
+
(function(global, factory) {
|
|
7
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.d3 = global.d3 || {}));
|
|
8
|
+
})(exports, (function(exports$4) {
|
|
9
|
+
"use strict";
|
|
10
|
+
function ascending(a, b) {
|
|
11
|
+
return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
|
|
12
|
+
}
|
|
13
|
+
function bisector(f) {
|
|
14
|
+
let delta = f;
|
|
15
|
+
let compare = f;
|
|
16
|
+
if (f.length === 1) {
|
|
17
|
+
delta = (d, x) => f(d) - x;
|
|
18
|
+
compare = ascendingComparator(f);
|
|
19
|
+
}
|
|
20
|
+
function left(a, x, lo, hi) {
|
|
21
|
+
if (lo == null) lo = 0;
|
|
22
|
+
if (hi == null) hi = a.length;
|
|
23
|
+
while (lo < hi) {
|
|
24
|
+
const mid = lo + hi >>> 1;
|
|
25
|
+
if (compare(a[mid], x) < 0) lo = mid + 1;
|
|
26
|
+
else hi = mid;
|
|
27
|
+
}
|
|
28
|
+
return lo;
|
|
29
|
+
}
|
|
30
|
+
function right(a, x, lo, hi) {
|
|
31
|
+
if (lo == null) lo = 0;
|
|
32
|
+
if (hi == null) hi = a.length;
|
|
33
|
+
while (lo < hi) {
|
|
34
|
+
const mid = lo + hi >>> 1;
|
|
35
|
+
if (compare(a[mid], x) > 0) hi = mid;
|
|
36
|
+
else lo = mid + 1;
|
|
37
|
+
}
|
|
38
|
+
return lo;
|
|
39
|
+
}
|
|
40
|
+
function center(a, x, lo, hi) {
|
|
41
|
+
if (lo == null) lo = 0;
|
|
42
|
+
if (hi == null) hi = a.length;
|
|
43
|
+
const i = left(a, x, lo, hi - 1);
|
|
44
|
+
return i > lo && delta(a[i - 1], x) > -delta(a[i], x) ? i - 1 : i;
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
left,
|
|
48
|
+
center,
|
|
49
|
+
right
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function ascendingComparator(f) {
|
|
53
|
+
return (d, x) => ascending(f(d), x);
|
|
54
|
+
}
|
|
55
|
+
function number(x) {
|
|
56
|
+
return x === null ? NaN : +x;
|
|
57
|
+
}
|
|
58
|
+
function* numbers(values, valueof) {
|
|
59
|
+
if (valueof === void 0) {
|
|
60
|
+
for (let value of values) if (value != null && (value = +value) >= value) yield value;
|
|
61
|
+
} else {
|
|
62
|
+
let index = -1;
|
|
63
|
+
for (let value of values) if ((value = valueof(value, ++index, values)) != null && (value = +value) >= value) yield value;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const ascendingBisect = bisector(ascending);
|
|
67
|
+
const bisectRight = ascendingBisect.right;
|
|
68
|
+
const bisectLeft = ascendingBisect.left;
|
|
69
|
+
const bisectCenter = bisector(number).center;
|
|
70
|
+
function count(values, valueof) {
|
|
71
|
+
let count = 0;
|
|
72
|
+
if (valueof === void 0) {
|
|
73
|
+
for (let value of values) if (value != null && (value = +value) >= value) ++count;
|
|
74
|
+
} else {
|
|
75
|
+
let index = -1;
|
|
76
|
+
for (let value of values) if ((value = valueof(value, ++index, values)) != null && (value = +value) >= value) ++count;
|
|
77
|
+
}
|
|
78
|
+
return count;
|
|
79
|
+
}
|
|
80
|
+
function length$1(array) {
|
|
81
|
+
return array.length | 0;
|
|
82
|
+
}
|
|
83
|
+
function empty(length) {
|
|
84
|
+
return !(length > 0);
|
|
85
|
+
}
|
|
86
|
+
function arrayify(values) {
|
|
87
|
+
return typeof values !== "object" || "length" in values ? values : Array.from(values);
|
|
88
|
+
}
|
|
89
|
+
function reducer(reduce) {
|
|
90
|
+
return (values) => reduce(...values);
|
|
91
|
+
}
|
|
92
|
+
function cross(...values) {
|
|
93
|
+
const reduce = typeof values[values.length - 1] === "function" && reducer(values.pop());
|
|
94
|
+
values = values.map(arrayify);
|
|
95
|
+
const lengths = values.map(length$1);
|
|
96
|
+
const j = values.length - 1;
|
|
97
|
+
const index = new Array(j + 1).fill(0);
|
|
98
|
+
const product = [];
|
|
99
|
+
if (j < 0 || lengths.some(empty)) return product;
|
|
100
|
+
while (true) {
|
|
101
|
+
product.push(index.map((j, i) => values[i][j]));
|
|
102
|
+
let i = j;
|
|
103
|
+
while (++index[i] === lengths[i]) {
|
|
104
|
+
if (i === 0) return reduce ? product.map(reduce) : product;
|
|
105
|
+
index[i--] = 0;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function cumsum(values, valueof) {
|
|
110
|
+
var sum = 0, index = 0;
|
|
111
|
+
return Float64Array.from(values, valueof === void 0 ? (v) => sum += +v || 0 : (v) => sum += +valueof(v, index++, values) || 0);
|
|
112
|
+
}
|
|
113
|
+
function descending(a, b) {
|
|
114
|
+
return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN;
|
|
115
|
+
}
|
|
116
|
+
function variance(values, valueof) {
|
|
117
|
+
let count = 0;
|
|
118
|
+
let delta;
|
|
119
|
+
let mean = 0;
|
|
120
|
+
let sum = 0;
|
|
121
|
+
if (valueof === void 0) {
|
|
122
|
+
for (let value of values) if (value != null && (value = +value) >= value) {
|
|
123
|
+
delta = value - mean;
|
|
124
|
+
mean += delta / ++count;
|
|
125
|
+
sum += delta * (value - mean);
|
|
126
|
+
}
|
|
127
|
+
} else {
|
|
128
|
+
let index = -1;
|
|
129
|
+
for (let value of values) if ((value = valueof(value, ++index, values)) != null && (value = +value) >= value) {
|
|
130
|
+
delta = value - mean;
|
|
131
|
+
mean += delta / ++count;
|
|
132
|
+
sum += delta * (value - mean);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (count > 1) return sum / (count - 1);
|
|
136
|
+
}
|
|
137
|
+
function deviation(values, valueof) {
|
|
138
|
+
const v = variance(values, valueof);
|
|
139
|
+
return v ? Math.sqrt(v) : v;
|
|
140
|
+
}
|
|
141
|
+
function extent(values, valueof) {
|
|
142
|
+
let min;
|
|
143
|
+
let max;
|
|
144
|
+
if (valueof === void 0) {
|
|
145
|
+
for (const value of values) if (value != null) {
|
|
146
|
+
if (min === void 0) {
|
|
147
|
+
if (value >= value) min = max = value;
|
|
148
|
+
} else {
|
|
149
|
+
if (min > value) min = value;
|
|
150
|
+
if (max < value) max = value;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
} else {
|
|
154
|
+
let index = -1;
|
|
155
|
+
for (let value of values) if ((value = valueof(value, ++index, values)) != null) {
|
|
156
|
+
if (min === void 0) {
|
|
157
|
+
if (value >= value) min = max = value;
|
|
158
|
+
} else {
|
|
159
|
+
if (min > value) min = value;
|
|
160
|
+
if (max < value) max = value;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return [min, max];
|
|
165
|
+
}
|
|
166
|
+
class Adder {
|
|
167
|
+
constructor() {
|
|
168
|
+
this._partials = /* @__PURE__ */ new Float64Array(32);
|
|
169
|
+
this._n = 0;
|
|
170
|
+
}
|
|
171
|
+
add(x) {
|
|
172
|
+
const p = this._partials;
|
|
173
|
+
let i = 0;
|
|
174
|
+
for (let j = 0; j < this._n && j < 32; j++) {
|
|
175
|
+
const y = p[j], hi = x + y, lo = Math.abs(x) < Math.abs(y) ? x - (hi - y) : y - (hi - x);
|
|
176
|
+
if (lo) p[i++] = lo;
|
|
177
|
+
x = hi;
|
|
178
|
+
}
|
|
179
|
+
p[i] = x;
|
|
180
|
+
this._n = i + 1;
|
|
181
|
+
return this;
|
|
182
|
+
}
|
|
183
|
+
valueOf() {
|
|
184
|
+
const p = this._partials;
|
|
185
|
+
let n = this._n, x, y, lo, hi = 0;
|
|
186
|
+
if (n > 0) {
|
|
187
|
+
hi = p[--n];
|
|
188
|
+
while (n > 0) {
|
|
189
|
+
x = hi;
|
|
190
|
+
y = p[--n];
|
|
191
|
+
hi = x + y;
|
|
192
|
+
lo = y - (hi - x);
|
|
193
|
+
if (lo) break;
|
|
194
|
+
}
|
|
195
|
+
if (n > 0 && (lo < 0 && p[n - 1] < 0 || lo > 0 && p[n - 1] > 0)) {
|
|
196
|
+
y = lo * 2;
|
|
197
|
+
x = hi + y;
|
|
198
|
+
if (y == x - hi) hi = x;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return hi;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
function fsum(values, valueof) {
|
|
205
|
+
const adder = new Adder();
|
|
206
|
+
if (valueof === void 0) {
|
|
207
|
+
for (let value of values) if (value = +value) adder.add(value);
|
|
208
|
+
} else {
|
|
209
|
+
let index = -1;
|
|
210
|
+
for (let value of values) if (value = +valueof(value, ++index, values)) adder.add(value);
|
|
211
|
+
}
|
|
212
|
+
return +adder;
|
|
213
|
+
}
|
|
214
|
+
function fcumsum(values, valueof) {
|
|
215
|
+
const adder = new Adder();
|
|
216
|
+
let index = -1;
|
|
217
|
+
return Float64Array.from(values, valueof === void 0 ? (v) => adder.add(+v || 0) : (v) => adder.add(+valueof(v, ++index, values) || 0));
|
|
218
|
+
}
|
|
219
|
+
class InternMap extends Map {
|
|
220
|
+
constructor(entries, key = keyof) {
|
|
221
|
+
super();
|
|
222
|
+
Object.defineProperties(this, {
|
|
223
|
+
_intern: { value: /* @__PURE__ */ new Map() },
|
|
224
|
+
_key: { value: key }
|
|
225
|
+
});
|
|
226
|
+
if (entries != null) for (const [key, value] of entries) this.set(key, value);
|
|
227
|
+
}
|
|
228
|
+
get(key) {
|
|
229
|
+
return super.get(intern_get(this, key));
|
|
230
|
+
}
|
|
231
|
+
has(key) {
|
|
232
|
+
return super.has(intern_get(this, key));
|
|
233
|
+
}
|
|
234
|
+
set(key, value) {
|
|
235
|
+
return super.set(intern_set(this, key), value);
|
|
236
|
+
}
|
|
237
|
+
delete(key) {
|
|
238
|
+
return super.delete(intern_delete(this, key));
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
class InternSet extends Set {
|
|
242
|
+
constructor(values, key = keyof) {
|
|
243
|
+
super();
|
|
244
|
+
Object.defineProperties(this, {
|
|
245
|
+
_intern: { value: /* @__PURE__ */ new Map() },
|
|
246
|
+
_key: { value: key }
|
|
247
|
+
});
|
|
248
|
+
if (values != null) for (const value of values) this.add(value);
|
|
249
|
+
}
|
|
250
|
+
has(value) {
|
|
251
|
+
return super.has(intern_get(this, value));
|
|
252
|
+
}
|
|
253
|
+
add(value) {
|
|
254
|
+
return super.add(intern_set(this, value));
|
|
255
|
+
}
|
|
256
|
+
delete(value) {
|
|
257
|
+
return super.delete(intern_delete(this, value));
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
function intern_get({ _intern, _key }, value) {
|
|
261
|
+
const key = _key(value);
|
|
262
|
+
return _intern.has(key) ? _intern.get(key) : value;
|
|
263
|
+
}
|
|
264
|
+
function intern_set({ _intern, _key }, value) {
|
|
265
|
+
const key = _key(value);
|
|
266
|
+
if (_intern.has(key)) return _intern.get(key);
|
|
267
|
+
_intern.set(key, value);
|
|
268
|
+
return value;
|
|
269
|
+
}
|
|
270
|
+
function intern_delete({ _intern, _key }, value) {
|
|
271
|
+
const key = _key(value);
|
|
272
|
+
if (_intern.has(key)) {
|
|
273
|
+
value = _intern.get(value);
|
|
274
|
+
_intern.delete(key);
|
|
275
|
+
}
|
|
276
|
+
return value;
|
|
277
|
+
}
|
|
278
|
+
function keyof(value) {
|
|
279
|
+
return value !== null && typeof value === "object" ? value.valueOf() : value;
|
|
280
|
+
}
|
|
281
|
+
function identity(x) {
|
|
282
|
+
return x;
|
|
283
|
+
}
|
|
284
|
+
function group(values, ...keys) {
|
|
285
|
+
return nest(values, identity, identity, keys);
|
|
286
|
+
}
|
|
287
|
+
function groups(values, ...keys) {
|
|
288
|
+
return nest(values, Array.from, identity, keys);
|
|
289
|
+
}
|
|
290
|
+
function rollup(values, reduce, ...keys) {
|
|
291
|
+
return nest(values, identity, reduce, keys);
|
|
292
|
+
}
|
|
293
|
+
function rollups(values, reduce, ...keys) {
|
|
294
|
+
return nest(values, Array.from, reduce, keys);
|
|
295
|
+
}
|
|
296
|
+
function index(values, ...keys) {
|
|
297
|
+
return nest(values, identity, unique, keys);
|
|
298
|
+
}
|
|
299
|
+
function indexes(values, ...keys) {
|
|
300
|
+
return nest(values, Array.from, unique, keys);
|
|
301
|
+
}
|
|
302
|
+
function unique(values) {
|
|
303
|
+
if (values.length !== 1) throw new Error("duplicate key");
|
|
304
|
+
return values[0];
|
|
305
|
+
}
|
|
306
|
+
function nest(values, map, reduce, keys) {
|
|
307
|
+
return (function regroup(values, i) {
|
|
308
|
+
if (i >= keys.length) return reduce(values);
|
|
309
|
+
const groups = new InternMap();
|
|
310
|
+
const keyof = keys[i++];
|
|
311
|
+
let index = -1;
|
|
312
|
+
for (const value of values) {
|
|
313
|
+
const key = keyof(value, ++index, values);
|
|
314
|
+
const group = groups.get(key);
|
|
315
|
+
if (group) group.push(value);
|
|
316
|
+
else groups.set(key, [value]);
|
|
317
|
+
}
|
|
318
|
+
for (const [key, values] of groups) groups.set(key, regroup(values, i));
|
|
319
|
+
return map(groups);
|
|
320
|
+
})(values, 0);
|
|
321
|
+
}
|
|
322
|
+
function permute(source, keys) {
|
|
323
|
+
return Array.from(keys, (key) => source[key]);
|
|
324
|
+
}
|
|
325
|
+
function sort(values, ...F) {
|
|
326
|
+
if (typeof values[Symbol.iterator] !== "function") throw new TypeError("values is not iterable");
|
|
327
|
+
values = Array.from(values);
|
|
328
|
+
let [f = ascending] = F;
|
|
329
|
+
if (f.length === 1 || F.length > 1) {
|
|
330
|
+
const index = Uint32Array.from(values, (d, i) => i);
|
|
331
|
+
if (F.length > 1) {
|
|
332
|
+
F = F.map((f) => values.map(f));
|
|
333
|
+
index.sort((i, j) => {
|
|
334
|
+
for (const f of F) {
|
|
335
|
+
const c = ascending(f[i], f[j]);
|
|
336
|
+
if (c) return c;
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
} else {
|
|
340
|
+
f = values.map(f);
|
|
341
|
+
index.sort((i, j) => ascending(f[i], f[j]));
|
|
342
|
+
}
|
|
343
|
+
return permute(values, index);
|
|
344
|
+
}
|
|
345
|
+
return values.sort(f);
|
|
346
|
+
}
|
|
347
|
+
function groupSort(values, reduce, key) {
|
|
348
|
+
return (reduce.length === 1 ? sort(rollup(values, reduce, key), (([ak, av], [bk, bv]) => ascending(av, bv) || ascending(ak, bk))) : sort(group(values, key), (([ak, av], [bk, bv]) => reduce(av, bv) || ascending(ak, bk)))).map(([key]) => key);
|
|
349
|
+
}
|
|
350
|
+
var slice = Array.prototype.slice;
|
|
351
|
+
function constant(x) {
|
|
352
|
+
return function() {
|
|
353
|
+
return x;
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
var e10 = Math.sqrt(50), e5 = Math.sqrt(10), e2 = Math.sqrt(2);
|
|
357
|
+
function ticks(start, stop, count) {
|
|
358
|
+
var reverse, i = -1, n, ticks, step;
|
|
359
|
+
stop = +stop, start = +start, count = +count;
|
|
360
|
+
if (start === stop && count > 0) return [start];
|
|
361
|
+
if (reverse = stop < start) n = start, start = stop, stop = n;
|
|
362
|
+
if ((step = tickIncrement(start, stop, count)) === 0 || !isFinite(step)) return [];
|
|
363
|
+
if (step > 0) {
|
|
364
|
+
let r0 = Math.round(start / step), r1 = Math.round(stop / step);
|
|
365
|
+
if (r0 * step < start) ++r0;
|
|
366
|
+
if (r1 * step > stop) --r1;
|
|
367
|
+
ticks = new Array(n = r1 - r0 + 1);
|
|
368
|
+
while (++i < n) ticks[i] = (r0 + i) * step;
|
|
369
|
+
} else {
|
|
370
|
+
step = -step;
|
|
371
|
+
let r0 = Math.round(start * step), r1 = Math.round(stop * step);
|
|
372
|
+
if (r0 / step < start) ++r0;
|
|
373
|
+
if (r1 / step > stop) --r1;
|
|
374
|
+
ticks = new Array(n = r1 - r0 + 1);
|
|
375
|
+
while (++i < n) ticks[i] = (r0 + i) / step;
|
|
376
|
+
}
|
|
377
|
+
if (reverse) ticks.reverse();
|
|
378
|
+
return ticks;
|
|
379
|
+
}
|
|
380
|
+
function tickIncrement(start, stop, count) {
|
|
381
|
+
var step = (stop - start) / Math.max(0, count), power = Math.floor(Math.log(step) / Math.LN10), error = step / Math.pow(10, power);
|
|
382
|
+
return power >= 0 ? (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1) * Math.pow(10, power) : -Math.pow(10, -power) / (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1);
|
|
383
|
+
}
|
|
384
|
+
function tickStep(start, stop, count) {
|
|
385
|
+
var step0 = Math.abs(stop - start) / Math.max(0, count), step1 = Math.pow(10, Math.floor(Math.log(step0) / Math.LN10)), error = step0 / step1;
|
|
386
|
+
if (error >= e10) step1 *= 10;
|
|
387
|
+
else if (error >= e5) step1 *= 5;
|
|
388
|
+
else if (error >= e2) step1 *= 2;
|
|
389
|
+
return stop < start ? -step1 : step1;
|
|
390
|
+
}
|
|
391
|
+
function nice(start, stop, count) {
|
|
392
|
+
let prestep;
|
|
393
|
+
while (true) {
|
|
394
|
+
const step = tickIncrement(start, stop, count);
|
|
395
|
+
if (step === prestep || step === 0 || !isFinite(step)) return [start, stop];
|
|
396
|
+
else if (step > 0) {
|
|
397
|
+
start = Math.floor(start / step) * step;
|
|
398
|
+
stop = Math.ceil(stop / step) * step;
|
|
399
|
+
} else if (step < 0) {
|
|
400
|
+
start = Math.ceil(start * step) / step;
|
|
401
|
+
stop = Math.floor(stop * step) / step;
|
|
402
|
+
}
|
|
403
|
+
prestep = step;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
function sturges(values) {
|
|
407
|
+
return Math.ceil(Math.log(count(values)) / Math.LN2) + 1;
|
|
408
|
+
}
|
|
409
|
+
function bin() {
|
|
410
|
+
var value = identity, domain = extent, threshold = sturges;
|
|
411
|
+
function histogram(data) {
|
|
412
|
+
if (!Array.isArray(data)) data = Array.from(data);
|
|
413
|
+
var i, n = data.length, x, values = new Array(n);
|
|
414
|
+
for (i = 0; i < n; ++i) values[i] = value(data[i], i, data);
|
|
415
|
+
var xz = domain(values), x0 = xz[0], x1 = xz[1], tz = threshold(values, x0, x1);
|
|
416
|
+
if (!Array.isArray(tz)) {
|
|
417
|
+
const max = x1, tn = +tz;
|
|
418
|
+
if (domain === extent) [x0, x1] = nice(x0, x1, tn);
|
|
419
|
+
tz = ticks(x0, x1, tn);
|
|
420
|
+
if (tz[tz.length - 1] >= x1) {
|
|
421
|
+
if (max >= x1 && domain === extent) {
|
|
422
|
+
const step = tickIncrement(x0, x1, tn);
|
|
423
|
+
if (isFinite(step)) {
|
|
424
|
+
if (step > 0) x1 = (Math.floor(x1 / step) + 1) * step;
|
|
425
|
+
else if (step < 0) x1 = (Math.ceil(x1 * -step) + 1) / -step;
|
|
426
|
+
}
|
|
427
|
+
} else tz.pop();
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
var m = tz.length;
|
|
431
|
+
while (tz[0] <= x0) tz.shift(), --m;
|
|
432
|
+
while (tz[m - 1] > x1) tz.pop(), --m;
|
|
433
|
+
var bins = new Array(m + 1), bin;
|
|
434
|
+
for (i = 0; i <= m; ++i) {
|
|
435
|
+
bin = bins[i] = [];
|
|
436
|
+
bin.x0 = i > 0 ? tz[i - 1] : x0;
|
|
437
|
+
bin.x1 = i < m ? tz[i] : x1;
|
|
438
|
+
}
|
|
439
|
+
for (i = 0; i < n; ++i) {
|
|
440
|
+
x = values[i];
|
|
441
|
+
if (x0 <= x && x <= x1) bins[bisectRight(tz, x, 0, m)].push(data[i]);
|
|
442
|
+
}
|
|
443
|
+
return bins;
|
|
444
|
+
}
|
|
445
|
+
histogram.value = function(_) {
|
|
446
|
+
return arguments.length ? (value = typeof _ === "function" ? _ : constant(_), histogram) : value;
|
|
447
|
+
};
|
|
448
|
+
histogram.domain = function(_) {
|
|
449
|
+
return arguments.length ? (domain = typeof _ === "function" ? _ : constant([_[0], _[1]]), histogram) : domain;
|
|
450
|
+
};
|
|
451
|
+
histogram.thresholds = function(_) {
|
|
452
|
+
return arguments.length ? (threshold = typeof _ === "function" ? _ : Array.isArray(_) ? constant(slice.call(_)) : constant(_), histogram) : threshold;
|
|
453
|
+
};
|
|
454
|
+
return histogram;
|
|
455
|
+
}
|
|
456
|
+
function max(values, valueof) {
|
|
457
|
+
let max;
|
|
458
|
+
if (valueof === void 0) {
|
|
459
|
+
for (const value of values) if (value != null && (max < value || max === void 0 && value >= value)) max = value;
|
|
460
|
+
} else {
|
|
461
|
+
let index = -1;
|
|
462
|
+
for (let value of values) if ((value = valueof(value, ++index, values)) != null && (max < value || max === void 0 && value >= value)) max = value;
|
|
463
|
+
}
|
|
464
|
+
return max;
|
|
465
|
+
}
|
|
466
|
+
function min(values, valueof) {
|
|
467
|
+
let min;
|
|
468
|
+
if (valueof === void 0) {
|
|
469
|
+
for (const value of values) if (value != null && (min > value || min === void 0 && value >= value)) min = value;
|
|
470
|
+
} else {
|
|
471
|
+
let index = -1;
|
|
472
|
+
for (let value of values) if ((value = valueof(value, ++index, values)) != null && (min > value || min === void 0 && value >= value)) min = value;
|
|
473
|
+
}
|
|
474
|
+
return min;
|
|
475
|
+
}
|
|
476
|
+
function quickselect(array, k, left = 0, right = array.length - 1, compare = ascending) {
|
|
477
|
+
while (right > left) {
|
|
478
|
+
if (right - left > 600) {
|
|
479
|
+
const n = right - left + 1;
|
|
480
|
+
const m = k - left + 1;
|
|
481
|
+
const z = Math.log(n);
|
|
482
|
+
const s = .5 * Math.exp(2 * z / 3);
|
|
483
|
+
const sd = .5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1);
|
|
484
|
+
quickselect(array, k, Math.max(left, Math.floor(k - m * s / n + sd)), Math.min(right, Math.floor(k + (n - m) * s / n + sd)), compare);
|
|
485
|
+
}
|
|
486
|
+
const t = array[k];
|
|
487
|
+
let i = left;
|
|
488
|
+
let j = right;
|
|
489
|
+
swap(array, left, k);
|
|
490
|
+
if (compare(array[right], t) > 0) swap(array, left, right);
|
|
491
|
+
while (i < j) {
|
|
492
|
+
swap(array, i, j), ++i, --j;
|
|
493
|
+
while (compare(array[i], t) < 0) ++i;
|
|
494
|
+
while (compare(array[j], t) > 0) --j;
|
|
495
|
+
}
|
|
496
|
+
if (compare(array[left], t) === 0) swap(array, left, j);
|
|
497
|
+
else ++j, swap(array, j, right);
|
|
498
|
+
if (j <= k) left = j + 1;
|
|
499
|
+
if (k <= j) right = j - 1;
|
|
500
|
+
}
|
|
501
|
+
return array;
|
|
502
|
+
}
|
|
503
|
+
function swap(array, i, j) {
|
|
504
|
+
const t = array[i];
|
|
505
|
+
array[i] = array[j];
|
|
506
|
+
array[j] = t;
|
|
507
|
+
}
|
|
508
|
+
function quantile(values, p, valueof) {
|
|
509
|
+
values = Float64Array.from(numbers(values, valueof));
|
|
510
|
+
if (!(n = values.length)) return;
|
|
511
|
+
if ((p = +p) <= 0 || n < 2) return min(values);
|
|
512
|
+
if (p >= 1) return max(values);
|
|
513
|
+
var n, i = (n - 1) * p, i0 = Math.floor(i), value0 = max(quickselect(values, i0).subarray(0, i0 + 1));
|
|
514
|
+
return value0 + (min(values.subarray(i0 + 1)) - value0) * (i - i0);
|
|
515
|
+
}
|
|
516
|
+
function quantileSorted(values, p, valueof = number) {
|
|
517
|
+
if (!(n = values.length)) return;
|
|
518
|
+
if ((p = +p) <= 0 || n < 2) return +valueof(values[0], 0, values);
|
|
519
|
+
if (p >= 1) return +valueof(values[n - 1], n - 1, values);
|
|
520
|
+
var n, i = (n - 1) * p, i0 = Math.floor(i), value0 = +valueof(values[i0], i0, values);
|
|
521
|
+
return value0 + (+valueof(values[i0 + 1], i0 + 1, values) - value0) * (i - i0);
|
|
522
|
+
}
|
|
523
|
+
function freedmanDiaconis(values, min, max) {
|
|
524
|
+
return Math.ceil((max - min) / (2 * (quantile(values, .75) - quantile(values, .25)) * Math.pow(count(values), -1 / 3)));
|
|
525
|
+
}
|
|
526
|
+
function scott(values, min, max) {
|
|
527
|
+
return Math.ceil((max - min) / (3.5 * deviation(values) * Math.pow(count(values), -1 / 3)));
|
|
528
|
+
}
|
|
529
|
+
function maxIndex(values, valueof) {
|
|
530
|
+
let max;
|
|
531
|
+
let maxIndex = -1;
|
|
532
|
+
let index = -1;
|
|
533
|
+
if (valueof === void 0) for (const value of values) {
|
|
534
|
+
++index;
|
|
535
|
+
if (value != null && (max < value || max === void 0 && value >= value)) max = value, maxIndex = index;
|
|
536
|
+
}
|
|
537
|
+
else for (let value of values) if ((value = valueof(value, ++index, values)) != null && (max < value || max === void 0 && value >= value)) max = value, maxIndex = index;
|
|
538
|
+
return maxIndex;
|
|
539
|
+
}
|
|
540
|
+
function mean(values, valueof) {
|
|
541
|
+
let count = 0;
|
|
542
|
+
let sum = 0;
|
|
543
|
+
if (valueof === void 0) {
|
|
544
|
+
for (let value of values) if (value != null && (value = +value) >= value) ++count, sum += value;
|
|
545
|
+
} else {
|
|
546
|
+
let index = -1;
|
|
547
|
+
for (let value of values) if ((value = valueof(value, ++index, values)) != null && (value = +value) >= value) ++count, sum += value;
|
|
548
|
+
}
|
|
549
|
+
if (count) return sum / count;
|
|
550
|
+
}
|
|
551
|
+
function median(values, valueof) {
|
|
552
|
+
return quantile(values, .5, valueof);
|
|
553
|
+
}
|
|
554
|
+
function* flatten(arrays) {
|
|
555
|
+
for (const array of arrays) yield* array;
|
|
556
|
+
}
|
|
557
|
+
function merge(arrays) {
|
|
558
|
+
return Array.from(flatten(arrays));
|
|
559
|
+
}
|
|
560
|
+
function minIndex(values, valueof) {
|
|
561
|
+
let min;
|
|
562
|
+
let minIndex = -1;
|
|
563
|
+
let index = -1;
|
|
564
|
+
if (valueof === void 0) for (const value of values) {
|
|
565
|
+
++index;
|
|
566
|
+
if (value != null && (min > value || min === void 0 && value >= value)) min = value, minIndex = index;
|
|
567
|
+
}
|
|
568
|
+
else for (let value of values) if ((value = valueof(value, ++index, values)) != null && (min > value || min === void 0 && value >= value)) min = value, minIndex = index;
|
|
569
|
+
return minIndex;
|
|
570
|
+
}
|
|
571
|
+
function pairs(values, pairof = pair) {
|
|
572
|
+
const pairs = [];
|
|
573
|
+
let previous;
|
|
574
|
+
let first = false;
|
|
575
|
+
for (const value of values) {
|
|
576
|
+
if (first) pairs.push(pairof(previous, value));
|
|
577
|
+
previous = value;
|
|
578
|
+
first = true;
|
|
579
|
+
}
|
|
580
|
+
return pairs;
|
|
581
|
+
}
|
|
582
|
+
function pair(a, b) {
|
|
583
|
+
return [a, b];
|
|
584
|
+
}
|
|
585
|
+
function range(start, stop, step) {
|
|
586
|
+
start = +start, stop = +stop, step = (n = arguments.length) < 2 ? (stop = start, start = 0, 1) : n < 3 ? 1 : +step;
|
|
587
|
+
var i = -1, n = Math.max(0, Math.ceil((stop - start) / step)) | 0, range = new Array(n);
|
|
588
|
+
while (++i < n) range[i] = start + i * step;
|
|
589
|
+
return range;
|
|
590
|
+
}
|
|
591
|
+
function least(values, compare = ascending) {
|
|
592
|
+
let min;
|
|
593
|
+
let defined = false;
|
|
594
|
+
if (compare.length === 1) {
|
|
595
|
+
let minValue;
|
|
596
|
+
for (const element of values) {
|
|
597
|
+
const value = compare(element);
|
|
598
|
+
if (defined ? ascending(value, minValue) < 0 : ascending(value, value) === 0) {
|
|
599
|
+
min = element;
|
|
600
|
+
minValue = value;
|
|
601
|
+
defined = true;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
} else for (const value of values) if (defined ? compare(value, min) < 0 : compare(value, value) === 0) {
|
|
605
|
+
min = value;
|
|
606
|
+
defined = true;
|
|
607
|
+
}
|
|
608
|
+
return min;
|
|
609
|
+
}
|
|
610
|
+
function leastIndex(values, compare = ascending) {
|
|
611
|
+
if (compare.length === 1) return minIndex(values, compare);
|
|
612
|
+
let minValue;
|
|
613
|
+
let min = -1;
|
|
614
|
+
let index = -1;
|
|
615
|
+
for (const value of values) {
|
|
616
|
+
++index;
|
|
617
|
+
if (min < 0 ? compare(value, value) === 0 : compare(value, minValue) < 0) {
|
|
618
|
+
minValue = value;
|
|
619
|
+
min = index;
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
return min;
|
|
623
|
+
}
|
|
624
|
+
function greatest(values, compare = ascending) {
|
|
625
|
+
let max;
|
|
626
|
+
let defined = false;
|
|
627
|
+
if (compare.length === 1) {
|
|
628
|
+
let maxValue;
|
|
629
|
+
for (const element of values) {
|
|
630
|
+
const value = compare(element);
|
|
631
|
+
if (defined ? ascending(value, maxValue) > 0 : ascending(value, value) === 0) {
|
|
632
|
+
max = element;
|
|
633
|
+
maxValue = value;
|
|
634
|
+
defined = true;
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
} else for (const value of values) if (defined ? compare(value, max) > 0 : compare(value, value) === 0) {
|
|
638
|
+
max = value;
|
|
639
|
+
defined = true;
|
|
640
|
+
}
|
|
641
|
+
return max;
|
|
642
|
+
}
|
|
643
|
+
function greatestIndex(values, compare = ascending) {
|
|
644
|
+
if (compare.length === 1) return maxIndex(values, compare);
|
|
645
|
+
let maxValue;
|
|
646
|
+
let max = -1;
|
|
647
|
+
let index = -1;
|
|
648
|
+
for (const value of values) {
|
|
649
|
+
++index;
|
|
650
|
+
if (max < 0 ? compare(value, value) === 0 : compare(value, maxValue) > 0) {
|
|
651
|
+
maxValue = value;
|
|
652
|
+
max = index;
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
return max;
|
|
656
|
+
}
|
|
657
|
+
function scan(values, compare) {
|
|
658
|
+
const index = leastIndex(values, compare);
|
|
659
|
+
return index < 0 ? void 0 : index;
|
|
660
|
+
}
|
|
661
|
+
var shuffle = shuffler(Math.random);
|
|
662
|
+
function shuffler(random) {
|
|
663
|
+
return function shuffle(array, i0 = 0, i1 = array.length) {
|
|
664
|
+
let m = i1 - (i0 = +i0);
|
|
665
|
+
while (m) {
|
|
666
|
+
const i = random() * m-- | 0, t = array[m + i0];
|
|
667
|
+
array[m + i0] = array[i + i0];
|
|
668
|
+
array[i + i0] = t;
|
|
669
|
+
}
|
|
670
|
+
return array;
|
|
671
|
+
};
|
|
672
|
+
}
|
|
673
|
+
function sum(values, valueof) {
|
|
674
|
+
let sum = 0;
|
|
675
|
+
if (valueof === void 0) {
|
|
676
|
+
for (let value of values) if (value = +value) sum += value;
|
|
677
|
+
} else {
|
|
678
|
+
let index = -1;
|
|
679
|
+
for (let value of values) if (value = +valueof(value, ++index, values)) sum += value;
|
|
680
|
+
}
|
|
681
|
+
return sum;
|
|
682
|
+
}
|
|
683
|
+
function transpose(matrix) {
|
|
684
|
+
if (!(n = matrix.length)) return [];
|
|
685
|
+
for (var i = -1, m = min(matrix, length), transpose = new Array(m); ++i < m;) for (var j = -1, n, row = transpose[i] = new Array(n); ++j < n;) row[j] = matrix[j][i];
|
|
686
|
+
return transpose;
|
|
687
|
+
}
|
|
688
|
+
function length(d) {
|
|
689
|
+
return d.length;
|
|
690
|
+
}
|
|
691
|
+
function zip() {
|
|
692
|
+
return transpose(arguments);
|
|
693
|
+
}
|
|
694
|
+
function every(values, test) {
|
|
695
|
+
if (typeof test !== "function") throw new TypeError("test is not a function");
|
|
696
|
+
let index = -1;
|
|
697
|
+
for (const value of values) if (!test(value, ++index, values)) return false;
|
|
698
|
+
return true;
|
|
699
|
+
}
|
|
700
|
+
function some(values, test) {
|
|
701
|
+
if (typeof test !== "function") throw new TypeError("test is not a function");
|
|
702
|
+
let index = -1;
|
|
703
|
+
for (const value of values) if (test(value, ++index, values)) return true;
|
|
704
|
+
return false;
|
|
705
|
+
}
|
|
706
|
+
function filter(values, test) {
|
|
707
|
+
if (typeof test !== "function") throw new TypeError("test is not a function");
|
|
708
|
+
const array = [];
|
|
709
|
+
let index = -1;
|
|
710
|
+
for (const value of values) if (test(value, ++index, values)) array.push(value);
|
|
711
|
+
return array;
|
|
712
|
+
}
|
|
713
|
+
function map(values, mapper) {
|
|
714
|
+
if (typeof values[Symbol.iterator] !== "function") throw new TypeError("values is not iterable");
|
|
715
|
+
if (typeof mapper !== "function") throw new TypeError("mapper is not a function");
|
|
716
|
+
return Array.from(values, (value, index) => mapper(value, index, values));
|
|
717
|
+
}
|
|
718
|
+
function reduce(values, reducer, value) {
|
|
719
|
+
if (typeof reducer !== "function") throw new TypeError("reducer is not a function");
|
|
720
|
+
const iterator = values[Symbol.iterator]();
|
|
721
|
+
let done, next, index = -1;
|
|
722
|
+
if (arguments.length < 3) {
|
|
723
|
+
({done, value} = iterator.next());
|
|
724
|
+
if (done) return;
|
|
725
|
+
++index;
|
|
726
|
+
}
|
|
727
|
+
while ({done, value: next} = iterator.next(), !done) value = reducer(value, next, ++index, values);
|
|
728
|
+
return value;
|
|
729
|
+
}
|
|
730
|
+
function reverse(values) {
|
|
731
|
+
if (typeof values[Symbol.iterator] !== "function") throw new TypeError("values is not iterable");
|
|
732
|
+
return Array.from(values).reverse();
|
|
733
|
+
}
|
|
734
|
+
function difference(values, ...others) {
|
|
735
|
+
values = new Set(values);
|
|
736
|
+
for (const other of others) for (const value of other) values.delete(value);
|
|
737
|
+
return values;
|
|
738
|
+
}
|
|
739
|
+
function disjoint(values, other) {
|
|
740
|
+
const iterator = other[Symbol.iterator](), set = /* @__PURE__ */ new Set();
|
|
741
|
+
for (const v of values) {
|
|
742
|
+
if (set.has(v)) return false;
|
|
743
|
+
let value, done;
|
|
744
|
+
while ({value, done} = iterator.next()) {
|
|
745
|
+
if (done) break;
|
|
746
|
+
if (Object.is(v, value)) return false;
|
|
747
|
+
set.add(value);
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
return true;
|
|
751
|
+
}
|
|
752
|
+
function set(values) {
|
|
753
|
+
return values instanceof Set ? values : new Set(values);
|
|
754
|
+
}
|
|
755
|
+
function intersection(values, ...others) {
|
|
756
|
+
values = new Set(values);
|
|
757
|
+
others = others.map(set);
|
|
758
|
+
out: for (const value of values) for (const other of others) if (!other.has(value)) {
|
|
759
|
+
values.delete(value);
|
|
760
|
+
continue out;
|
|
761
|
+
}
|
|
762
|
+
return values;
|
|
763
|
+
}
|
|
764
|
+
function superset(values, other) {
|
|
765
|
+
const iterator = values[Symbol.iterator](), set = /* @__PURE__ */ new Set();
|
|
766
|
+
for (const o of other) {
|
|
767
|
+
if (set.has(o)) continue;
|
|
768
|
+
let value, done;
|
|
769
|
+
while ({value, done} = iterator.next()) {
|
|
770
|
+
if (done) return false;
|
|
771
|
+
set.add(value);
|
|
772
|
+
if (Object.is(o, value)) break;
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
return true;
|
|
776
|
+
}
|
|
777
|
+
function subset(values, other) {
|
|
778
|
+
return superset(other, values);
|
|
779
|
+
}
|
|
780
|
+
function union(...others) {
|
|
781
|
+
const set = /* @__PURE__ */ new Set();
|
|
782
|
+
for (const other of others) for (const o of other) set.add(o);
|
|
783
|
+
return set;
|
|
784
|
+
}
|
|
785
|
+
exports$4.Adder = Adder;
|
|
786
|
+
exports$4.InternMap = InternMap;
|
|
787
|
+
exports$4.InternSet = InternSet;
|
|
788
|
+
exports$4.ascending = ascending;
|
|
789
|
+
exports$4.bin = bin;
|
|
790
|
+
exports$4.bisect = bisectRight;
|
|
791
|
+
exports$4.bisectCenter = bisectCenter;
|
|
792
|
+
exports$4.bisectLeft = bisectLeft;
|
|
793
|
+
exports$4.bisectRight = bisectRight;
|
|
794
|
+
exports$4.bisector = bisector;
|
|
795
|
+
exports$4.count = count;
|
|
796
|
+
exports$4.cross = cross;
|
|
797
|
+
exports$4.cumsum = cumsum;
|
|
798
|
+
exports$4.descending = descending;
|
|
799
|
+
exports$4.deviation = deviation;
|
|
800
|
+
exports$4.difference = difference;
|
|
801
|
+
exports$4.disjoint = disjoint;
|
|
802
|
+
exports$4.every = every;
|
|
803
|
+
exports$4.extent = extent;
|
|
804
|
+
exports$4.fcumsum = fcumsum;
|
|
805
|
+
exports$4.filter = filter;
|
|
806
|
+
exports$4.fsum = fsum;
|
|
807
|
+
exports$4.greatest = greatest;
|
|
808
|
+
exports$4.greatestIndex = greatestIndex;
|
|
809
|
+
exports$4.group = group;
|
|
810
|
+
exports$4.groupSort = groupSort;
|
|
811
|
+
exports$4.groups = groups;
|
|
812
|
+
exports$4.histogram = bin;
|
|
813
|
+
exports$4.index = index;
|
|
814
|
+
exports$4.indexes = indexes;
|
|
815
|
+
exports$4.intersection = intersection;
|
|
816
|
+
exports$4.least = least;
|
|
817
|
+
exports$4.leastIndex = leastIndex;
|
|
818
|
+
exports$4.map = map;
|
|
819
|
+
exports$4.max = max;
|
|
820
|
+
exports$4.maxIndex = maxIndex;
|
|
821
|
+
exports$4.mean = mean;
|
|
822
|
+
exports$4.median = median;
|
|
823
|
+
exports$4.merge = merge;
|
|
824
|
+
exports$4.min = min;
|
|
825
|
+
exports$4.minIndex = minIndex;
|
|
826
|
+
exports$4.nice = nice;
|
|
827
|
+
exports$4.pairs = pairs;
|
|
828
|
+
exports$4.permute = permute;
|
|
829
|
+
exports$4.quantile = quantile;
|
|
830
|
+
exports$4.quantileSorted = quantileSorted;
|
|
831
|
+
exports$4.quickselect = quickselect;
|
|
832
|
+
exports$4.range = range;
|
|
833
|
+
exports$4.reduce = reduce;
|
|
834
|
+
exports$4.reverse = reverse;
|
|
835
|
+
exports$4.rollup = rollup;
|
|
836
|
+
exports$4.rollups = rollups;
|
|
837
|
+
exports$4.scan = scan;
|
|
838
|
+
exports$4.shuffle = shuffle;
|
|
839
|
+
exports$4.shuffler = shuffler;
|
|
840
|
+
exports$4.some = some;
|
|
841
|
+
exports$4.sort = sort;
|
|
842
|
+
exports$4.subset = subset;
|
|
843
|
+
exports$4.sum = sum;
|
|
844
|
+
exports$4.superset = superset;
|
|
845
|
+
exports$4.thresholdFreedmanDiaconis = freedmanDiaconis;
|
|
846
|
+
exports$4.thresholdScott = scott;
|
|
847
|
+
exports$4.thresholdSturges = sturges;
|
|
848
|
+
exports$4.tickIncrement = tickIncrement;
|
|
849
|
+
exports$4.tickStep = tickStep;
|
|
850
|
+
exports$4.ticks = ticks;
|
|
851
|
+
exports$4.transpose = transpose;
|
|
852
|
+
exports$4.union = union;
|
|
853
|
+
exports$4.variance = variance;
|
|
854
|
+
exports$4.zip = zip;
|
|
855
|
+
Object.defineProperty(exports$4, "__esModule", { value: true });
|
|
856
|
+
}));
|
|
857
|
+
}));
|
|
858
|
+
//#endregion
|
|
859
|
+
//#region ../../node_modules/.pnpm/d3-path@1.0.9/node_modules/d3-path/dist/d3-path.js
|
|
860
|
+
var require_d3_path = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
861
|
+
(function(global, factory) {
|
|
862
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global = global || self, factory(global.d3 = global.d3 || {}));
|
|
863
|
+
})(exports, function(exports$3) {
|
|
864
|
+
"use strict";
|
|
865
|
+
var pi = Math.PI, tau = 2 * pi, epsilon = 1e-6, tauEpsilon = tau - epsilon;
|
|
866
|
+
function Path() {
|
|
867
|
+
this._x0 = this._y0 = this._x1 = this._y1 = null;
|
|
868
|
+
this._ = "";
|
|
869
|
+
}
|
|
870
|
+
function path() {
|
|
871
|
+
return new Path();
|
|
872
|
+
}
|
|
873
|
+
Path.prototype = path.prototype = {
|
|
874
|
+
constructor: Path,
|
|
875
|
+
moveTo: function(x, y) {
|
|
876
|
+
this._ += "M" + (this._x0 = this._x1 = +x) + "," + (this._y0 = this._y1 = +y);
|
|
877
|
+
},
|
|
878
|
+
closePath: function() {
|
|
879
|
+
if (this._x1 !== null) {
|
|
880
|
+
this._x1 = this._x0, this._y1 = this._y0;
|
|
881
|
+
this._ += "Z";
|
|
882
|
+
}
|
|
883
|
+
},
|
|
884
|
+
lineTo: function(x, y) {
|
|
885
|
+
this._ += "L" + (this._x1 = +x) + "," + (this._y1 = +y);
|
|
886
|
+
},
|
|
887
|
+
quadraticCurveTo: function(x1, y1, x, y) {
|
|
888
|
+
this._ += "Q" + +x1 + "," + +y1 + "," + (this._x1 = +x) + "," + (this._y1 = +y);
|
|
889
|
+
},
|
|
890
|
+
bezierCurveTo: function(x1, y1, x2, y2, x, y) {
|
|
891
|
+
this._ += "C" + +x1 + "," + +y1 + "," + +x2 + "," + +y2 + "," + (this._x1 = +x) + "," + (this._y1 = +y);
|
|
892
|
+
},
|
|
893
|
+
arcTo: function(x1, y1, x2, y2, r) {
|
|
894
|
+
x1 = +x1, y1 = +y1, x2 = +x2, y2 = +y2, r = +r;
|
|
895
|
+
var x0 = this._x1, y0 = this._y1, x21 = x2 - x1, y21 = y2 - y1, x01 = x0 - x1, y01 = y0 - y1, l01_2 = x01 * x01 + y01 * y01;
|
|
896
|
+
if (r < 0) throw new Error("negative radius: " + r);
|
|
897
|
+
if (this._x1 === null) this._ += "M" + (this._x1 = x1) + "," + (this._y1 = y1);
|
|
898
|
+
else if (!(l01_2 > epsilon));
|
|
899
|
+
else if (!(Math.abs(y01 * x21 - y21 * x01) > epsilon) || !r) this._ += "L" + (this._x1 = x1) + "," + (this._y1 = y1);
|
|
900
|
+
else {
|
|
901
|
+
var x20 = x2 - x0, y20 = y2 - y0, l21_2 = x21 * x21 + y21 * y21, l20_2 = x20 * x20 + y20 * y20, l21 = Math.sqrt(l21_2), l01 = Math.sqrt(l01_2), l = r * Math.tan((pi - Math.acos((l21_2 + l01_2 - l20_2) / (2 * l21 * l01))) / 2), t01 = l / l01, t21 = l / l21;
|
|
902
|
+
if (Math.abs(t01 - 1) > epsilon) this._ += "L" + (x1 + t01 * x01) + "," + (y1 + t01 * y01);
|
|
903
|
+
this._ += "A" + r + "," + r + ",0,0," + +(y01 * x20 > x01 * y20) + "," + (this._x1 = x1 + t21 * x21) + "," + (this._y1 = y1 + t21 * y21);
|
|
904
|
+
}
|
|
905
|
+
},
|
|
906
|
+
arc: function(x, y, r, a0, a1, ccw) {
|
|
907
|
+
x = +x, y = +y, r = +r, ccw = !!ccw;
|
|
908
|
+
var dx = r * Math.cos(a0), dy = r * Math.sin(a0), x0 = x + dx, y0 = y + dy, cw = 1 ^ ccw, da = ccw ? a0 - a1 : a1 - a0;
|
|
909
|
+
if (r < 0) throw new Error("negative radius: " + r);
|
|
910
|
+
if (this._x1 === null) this._ += "M" + x0 + "," + y0;
|
|
911
|
+
else if (Math.abs(this._x1 - x0) > epsilon || Math.abs(this._y1 - y0) > epsilon) this._ += "L" + x0 + "," + y0;
|
|
912
|
+
if (!r) return;
|
|
913
|
+
if (da < 0) da = da % tau + tau;
|
|
914
|
+
if (da > tauEpsilon) this._ += "A" + r + "," + r + ",0,1," + cw + "," + (x - dx) + "," + (y - dy) + "A" + r + "," + r + ",0,1," + cw + "," + (this._x1 = x0) + "," + (this._y1 = y0);
|
|
915
|
+
else if (da > epsilon) this._ += "A" + r + "," + r + ",0," + +(da >= pi) + "," + cw + "," + (this._x1 = x + r * Math.cos(a1)) + "," + (this._y1 = y + r * Math.sin(a1));
|
|
916
|
+
},
|
|
917
|
+
rect: function(x, y, w, h) {
|
|
918
|
+
this._ += "M" + (this._x0 = this._x1 = +x) + "," + (this._y0 = this._y1 = +y) + "h" + +w + "v" + +h + "h" + -w + "Z";
|
|
919
|
+
},
|
|
920
|
+
toString: function() {
|
|
921
|
+
return this._;
|
|
922
|
+
}
|
|
923
|
+
};
|
|
924
|
+
exports$3.path = path;
|
|
925
|
+
Object.defineProperty(exports$3, "__esModule", { value: true });
|
|
926
|
+
});
|
|
927
|
+
}));
|
|
928
|
+
//#endregion
|
|
929
|
+
//#region ../../node_modules/.pnpm/d3-shape@1.3.7/node_modules/d3-shape/dist/d3-shape.js
|
|
930
|
+
var require_d3_shape = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
931
|
+
(function(global, factory) {
|
|
932
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require_d3_path()) : typeof define === "function" && define.amd ? define(["exports", "d3-path"], factory) : (global = global || self, factory(global.d3 = global.d3 || {}, global.d3));
|
|
933
|
+
})(exports, function(exports$2, d3Path) {
|
|
934
|
+
"use strict";
|
|
935
|
+
function constant(x) {
|
|
936
|
+
return function constant() {
|
|
937
|
+
return x;
|
|
938
|
+
};
|
|
939
|
+
}
|
|
940
|
+
var abs = Math.abs;
|
|
941
|
+
var atan2 = Math.atan2;
|
|
942
|
+
var cos = Math.cos;
|
|
943
|
+
var max = Math.max;
|
|
944
|
+
var min = Math.min;
|
|
945
|
+
var sin = Math.sin;
|
|
946
|
+
var sqrt = Math.sqrt;
|
|
947
|
+
var epsilon = 1e-12;
|
|
948
|
+
var pi = Math.PI;
|
|
949
|
+
var halfPi = pi / 2;
|
|
950
|
+
var tau = 2 * pi;
|
|
951
|
+
function acos(x) {
|
|
952
|
+
return x > 1 ? 0 : x < -1 ? pi : Math.acos(x);
|
|
953
|
+
}
|
|
954
|
+
function asin(x) {
|
|
955
|
+
return x >= 1 ? halfPi : x <= -1 ? -halfPi : Math.asin(x);
|
|
956
|
+
}
|
|
957
|
+
function arcInnerRadius(d) {
|
|
958
|
+
return d.innerRadius;
|
|
959
|
+
}
|
|
960
|
+
function arcOuterRadius(d) {
|
|
961
|
+
return d.outerRadius;
|
|
962
|
+
}
|
|
963
|
+
function arcStartAngle(d) {
|
|
964
|
+
return d.startAngle;
|
|
965
|
+
}
|
|
966
|
+
function arcEndAngle(d) {
|
|
967
|
+
return d.endAngle;
|
|
968
|
+
}
|
|
969
|
+
function arcPadAngle(d) {
|
|
970
|
+
return d && d.padAngle;
|
|
971
|
+
}
|
|
972
|
+
function intersect(x0, y0, x1, y1, x2, y2, x3, y3) {
|
|
973
|
+
var x10 = x1 - x0, y10 = y1 - y0, x32 = x3 - x2, y32 = y3 - y2, t = y32 * x10 - x32 * y10;
|
|
974
|
+
if (t * t < epsilon) return;
|
|
975
|
+
t = (x32 * (y0 - y2) - y32 * (x0 - x2)) / t;
|
|
976
|
+
return [x0 + t * x10, y0 + t * y10];
|
|
977
|
+
}
|
|
978
|
+
function cornerTangents(x0, y0, x1, y1, r1, rc, cw) {
|
|
979
|
+
var x01 = x0 - x1, y01 = y0 - y1, lo = (cw ? rc : -rc) / sqrt(x01 * x01 + y01 * y01), ox = lo * y01, oy = -lo * x01, x11 = x0 + ox, y11 = y0 + oy, x10 = x1 + ox, y10 = y1 + oy, x00 = (x11 + x10) / 2, y00 = (y11 + y10) / 2, dx = x10 - x11, dy = y10 - y11, d2 = dx * dx + dy * dy, r = r1 - rc, D = x11 * y10 - x10 * y11, d = (dy < 0 ? -1 : 1) * sqrt(max(0, r * r * d2 - D * D)), cx0 = (D * dy - dx * d) / d2, cy0 = (-D * dx - dy * d) / d2, cx1 = (D * dy + dx * d) / d2, cy1 = (-D * dx + dy * d) / d2, dx0 = cx0 - x00, dy0 = cy0 - y00, dx1 = cx1 - x00, dy1 = cy1 - y00;
|
|
980
|
+
if (dx0 * dx0 + dy0 * dy0 > dx1 * dx1 + dy1 * dy1) cx0 = cx1, cy0 = cy1;
|
|
981
|
+
return {
|
|
982
|
+
cx: cx0,
|
|
983
|
+
cy: cy0,
|
|
984
|
+
x01: -ox,
|
|
985
|
+
y01: -oy,
|
|
986
|
+
x11: cx0 * (r1 / r - 1),
|
|
987
|
+
y11: cy0 * (r1 / r - 1)
|
|
988
|
+
};
|
|
989
|
+
}
|
|
990
|
+
function arc() {
|
|
991
|
+
var innerRadius = arcInnerRadius, outerRadius = arcOuterRadius, cornerRadius = constant(0), padRadius = null, startAngle = arcStartAngle, endAngle = arcEndAngle, padAngle = arcPadAngle, context = null;
|
|
992
|
+
function arc() {
|
|
993
|
+
var buffer, r, r0 = +innerRadius.apply(this, arguments), r1 = +outerRadius.apply(this, arguments), a0 = startAngle.apply(this, arguments) - halfPi, a1 = endAngle.apply(this, arguments) - halfPi, da = abs(a1 - a0), cw = a1 > a0;
|
|
994
|
+
if (!context) context = buffer = d3Path.path();
|
|
995
|
+
if (r1 < r0) r = r1, r1 = r0, r0 = r;
|
|
996
|
+
if (!(r1 > epsilon)) context.moveTo(0, 0);
|
|
997
|
+
else if (da > tau - epsilon) {
|
|
998
|
+
context.moveTo(r1 * cos(a0), r1 * sin(a0));
|
|
999
|
+
context.arc(0, 0, r1, a0, a1, !cw);
|
|
1000
|
+
if (r0 > epsilon) {
|
|
1001
|
+
context.moveTo(r0 * cos(a1), r0 * sin(a1));
|
|
1002
|
+
context.arc(0, 0, r0, a1, a0, cw);
|
|
1003
|
+
}
|
|
1004
|
+
} else {
|
|
1005
|
+
var a01 = a0, a11 = a1, a00 = a0, a10 = a1, da0 = da, da1 = da, ap = padAngle.apply(this, arguments) / 2, rp = ap > epsilon && (padRadius ? +padRadius.apply(this, arguments) : sqrt(r0 * r0 + r1 * r1)), rc = min(abs(r1 - r0) / 2, +cornerRadius.apply(this, arguments)), rc0 = rc, rc1 = rc, t0, t1;
|
|
1006
|
+
if (rp > epsilon) {
|
|
1007
|
+
var p0 = asin(rp / r0 * sin(ap)), p1 = asin(rp / r1 * sin(ap));
|
|
1008
|
+
if ((da0 -= p0 * 2) > epsilon) p0 *= cw ? 1 : -1, a00 += p0, a10 -= p0;
|
|
1009
|
+
else da0 = 0, a00 = a10 = (a0 + a1) / 2;
|
|
1010
|
+
if ((da1 -= p1 * 2) > epsilon) p1 *= cw ? 1 : -1, a01 += p1, a11 -= p1;
|
|
1011
|
+
else da1 = 0, a01 = a11 = (a0 + a1) / 2;
|
|
1012
|
+
}
|
|
1013
|
+
var x01 = r1 * cos(a01), y01 = r1 * sin(a01), x10 = r0 * cos(a10), y10 = r0 * sin(a10);
|
|
1014
|
+
if (rc > epsilon) {
|
|
1015
|
+
var x11 = r1 * cos(a11), y11 = r1 * sin(a11), x00 = r0 * cos(a00), y00 = r0 * sin(a00), oc;
|
|
1016
|
+
if (da < pi && (oc = intersect(x01, y01, x00, y00, x11, y11, x10, y10))) {
|
|
1017
|
+
var ax = x01 - oc[0], ay = y01 - oc[1], bx = x11 - oc[0], by = y11 - oc[1], kc = 1 / sin(acos((ax * bx + ay * by) / (sqrt(ax * ax + ay * ay) * sqrt(bx * bx + by * by))) / 2), lc = sqrt(oc[0] * oc[0] + oc[1] * oc[1]);
|
|
1018
|
+
rc0 = min(rc, (r0 - lc) / (kc - 1));
|
|
1019
|
+
rc1 = min(rc, (r1 - lc) / (kc + 1));
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
if (!(da1 > epsilon)) context.moveTo(x01, y01);
|
|
1023
|
+
else if (rc1 > epsilon) {
|
|
1024
|
+
t0 = cornerTangents(x00, y00, x01, y01, r1, rc1, cw);
|
|
1025
|
+
t1 = cornerTangents(x11, y11, x10, y10, r1, rc1, cw);
|
|
1026
|
+
context.moveTo(t0.cx + t0.x01, t0.cy + t0.y01);
|
|
1027
|
+
if (rc1 < rc) context.arc(t0.cx, t0.cy, rc1, atan2(t0.y01, t0.x01), atan2(t1.y01, t1.x01), !cw);
|
|
1028
|
+
else {
|
|
1029
|
+
context.arc(t0.cx, t0.cy, rc1, atan2(t0.y01, t0.x01), atan2(t0.y11, t0.x11), !cw);
|
|
1030
|
+
context.arc(0, 0, r1, atan2(t0.cy + t0.y11, t0.cx + t0.x11), atan2(t1.cy + t1.y11, t1.cx + t1.x11), !cw);
|
|
1031
|
+
context.arc(t1.cx, t1.cy, rc1, atan2(t1.y11, t1.x11), atan2(t1.y01, t1.x01), !cw);
|
|
1032
|
+
}
|
|
1033
|
+
} else context.moveTo(x01, y01), context.arc(0, 0, r1, a01, a11, !cw);
|
|
1034
|
+
if (!(r0 > epsilon) || !(da0 > epsilon)) context.lineTo(x10, y10);
|
|
1035
|
+
else if (rc0 > epsilon) {
|
|
1036
|
+
t0 = cornerTangents(x10, y10, x11, y11, r0, -rc0, cw);
|
|
1037
|
+
t1 = cornerTangents(x01, y01, x00, y00, r0, -rc0, cw);
|
|
1038
|
+
context.lineTo(t0.cx + t0.x01, t0.cy + t0.y01);
|
|
1039
|
+
if (rc0 < rc) context.arc(t0.cx, t0.cy, rc0, atan2(t0.y01, t0.x01), atan2(t1.y01, t1.x01), !cw);
|
|
1040
|
+
else {
|
|
1041
|
+
context.arc(t0.cx, t0.cy, rc0, atan2(t0.y01, t0.x01), atan2(t0.y11, t0.x11), !cw);
|
|
1042
|
+
context.arc(0, 0, r0, atan2(t0.cy + t0.y11, t0.cx + t0.x11), atan2(t1.cy + t1.y11, t1.cx + t1.x11), cw);
|
|
1043
|
+
context.arc(t1.cx, t1.cy, rc0, atan2(t1.y11, t1.x11), atan2(t1.y01, t1.x01), !cw);
|
|
1044
|
+
}
|
|
1045
|
+
} else context.arc(0, 0, r0, a10, a00, cw);
|
|
1046
|
+
}
|
|
1047
|
+
context.closePath();
|
|
1048
|
+
if (buffer) return context = null, buffer + "" || null;
|
|
1049
|
+
}
|
|
1050
|
+
arc.centroid = function() {
|
|
1051
|
+
var r = (+innerRadius.apply(this, arguments) + +outerRadius.apply(this, arguments)) / 2, a = (+startAngle.apply(this, arguments) + +endAngle.apply(this, arguments)) / 2 - pi / 2;
|
|
1052
|
+
return [cos(a) * r, sin(a) * r];
|
|
1053
|
+
};
|
|
1054
|
+
arc.innerRadius = function(_) {
|
|
1055
|
+
return arguments.length ? (innerRadius = typeof _ === "function" ? _ : constant(+_), arc) : innerRadius;
|
|
1056
|
+
};
|
|
1057
|
+
arc.outerRadius = function(_) {
|
|
1058
|
+
return arguments.length ? (outerRadius = typeof _ === "function" ? _ : constant(+_), arc) : outerRadius;
|
|
1059
|
+
};
|
|
1060
|
+
arc.cornerRadius = function(_) {
|
|
1061
|
+
return arguments.length ? (cornerRadius = typeof _ === "function" ? _ : constant(+_), arc) : cornerRadius;
|
|
1062
|
+
};
|
|
1063
|
+
arc.padRadius = function(_) {
|
|
1064
|
+
return arguments.length ? (padRadius = _ == null ? null : typeof _ === "function" ? _ : constant(+_), arc) : padRadius;
|
|
1065
|
+
};
|
|
1066
|
+
arc.startAngle = function(_) {
|
|
1067
|
+
return arguments.length ? (startAngle = typeof _ === "function" ? _ : constant(+_), arc) : startAngle;
|
|
1068
|
+
};
|
|
1069
|
+
arc.endAngle = function(_) {
|
|
1070
|
+
return arguments.length ? (endAngle = typeof _ === "function" ? _ : constant(+_), arc) : endAngle;
|
|
1071
|
+
};
|
|
1072
|
+
arc.padAngle = function(_) {
|
|
1073
|
+
return arguments.length ? (padAngle = typeof _ === "function" ? _ : constant(+_), arc) : padAngle;
|
|
1074
|
+
};
|
|
1075
|
+
arc.context = function(_) {
|
|
1076
|
+
return arguments.length ? (context = _ == null ? null : _, arc) : context;
|
|
1077
|
+
};
|
|
1078
|
+
return arc;
|
|
1079
|
+
}
|
|
1080
|
+
function Linear(context) {
|
|
1081
|
+
this._context = context;
|
|
1082
|
+
}
|
|
1083
|
+
Linear.prototype = {
|
|
1084
|
+
areaStart: function() {
|
|
1085
|
+
this._line = 0;
|
|
1086
|
+
},
|
|
1087
|
+
areaEnd: function() {
|
|
1088
|
+
this._line = NaN;
|
|
1089
|
+
},
|
|
1090
|
+
lineStart: function() {
|
|
1091
|
+
this._point = 0;
|
|
1092
|
+
},
|
|
1093
|
+
lineEnd: function() {
|
|
1094
|
+
if (this._line || this._line !== 0 && this._point === 1) this._context.closePath();
|
|
1095
|
+
this._line = 1 - this._line;
|
|
1096
|
+
},
|
|
1097
|
+
point: function(x, y) {
|
|
1098
|
+
x = +x, y = +y;
|
|
1099
|
+
switch (this._point) {
|
|
1100
|
+
case 0:
|
|
1101
|
+
this._point = 1;
|
|
1102
|
+
this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y);
|
|
1103
|
+
break;
|
|
1104
|
+
case 1: this._point = 2;
|
|
1105
|
+
default: this._context.lineTo(x, y);
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
};
|
|
1109
|
+
function curveLinear(context) {
|
|
1110
|
+
return new Linear(context);
|
|
1111
|
+
}
|
|
1112
|
+
function x(p) {
|
|
1113
|
+
return p[0];
|
|
1114
|
+
}
|
|
1115
|
+
function y(p) {
|
|
1116
|
+
return p[1];
|
|
1117
|
+
}
|
|
1118
|
+
function line() {
|
|
1119
|
+
var x$1 = x, y$1 = y, defined = constant(true), context = null, curve = curveLinear, output = null;
|
|
1120
|
+
function line(data) {
|
|
1121
|
+
var i, n = data.length, d, defined0 = false, buffer;
|
|
1122
|
+
if (context == null) output = curve(buffer = d3Path.path());
|
|
1123
|
+
for (i = 0; i <= n; ++i) {
|
|
1124
|
+
if (!(i < n && defined(d = data[i], i, data)) === defined0) {
|
|
1125
|
+
if (defined0 = !defined0) output.lineStart();
|
|
1126
|
+
else output.lineEnd();
|
|
1127
|
+
}
|
|
1128
|
+
if (defined0) output.point(+x$1(d, i, data), +y$1(d, i, data));
|
|
1129
|
+
}
|
|
1130
|
+
if (buffer) return output = null, buffer + "" || null;
|
|
1131
|
+
}
|
|
1132
|
+
line.x = function(_) {
|
|
1133
|
+
return arguments.length ? (x$1 = typeof _ === "function" ? _ : constant(+_), line) : x$1;
|
|
1134
|
+
};
|
|
1135
|
+
line.y = function(_) {
|
|
1136
|
+
return arguments.length ? (y$1 = typeof _ === "function" ? _ : constant(+_), line) : y$1;
|
|
1137
|
+
};
|
|
1138
|
+
line.defined = function(_) {
|
|
1139
|
+
return arguments.length ? (defined = typeof _ === "function" ? _ : constant(!!_), line) : defined;
|
|
1140
|
+
};
|
|
1141
|
+
line.curve = function(_) {
|
|
1142
|
+
return arguments.length ? (curve = _, context != null && (output = curve(context)), line) : curve;
|
|
1143
|
+
};
|
|
1144
|
+
line.context = function(_) {
|
|
1145
|
+
return arguments.length ? (_ == null ? context = output = null : output = curve(context = _), line) : context;
|
|
1146
|
+
};
|
|
1147
|
+
return line;
|
|
1148
|
+
}
|
|
1149
|
+
function area() {
|
|
1150
|
+
var x0 = x, x1 = null, y0 = constant(0), y1 = y, defined = constant(true), context = null, curve = curveLinear, output = null;
|
|
1151
|
+
function area(data) {
|
|
1152
|
+
var i, j, k, n = data.length, d, defined0 = false, buffer, x0z = new Array(n), y0z = new Array(n);
|
|
1153
|
+
if (context == null) output = curve(buffer = d3Path.path());
|
|
1154
|
+
for (i = 0; i <= n; ++i) {
|
|
1155
|
+
if (!(i < n && defined(d = data[i], i, data)) === defined0) {
|
|
1156
|
+
if (defined0 = !defined0) {
|
|
1157
|
+
j = i;
|
|
1158
|
+
output.areaStart();
|
|
1159
|
+
output.lineStart();
|
|
1160
|
+
} else {
|
|
1161
|
+
output.lineEnd();
|
|
1162
|
+
output.lineStart();
|
|
1163
|
+
for (k = i - 1; k >= j; --k) output.point(x0z[k], y0z[k]);
|
|
1164
|
+
output.lineEnd();
|
|
1165
|
+
output.areaEnd();
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
if (defined0) {
|
|
1169
|
+
x0z[i] = +x0(d, i, data), y0z[i] = +y0(d, i, data);
|
|
1170
|
+
output.point(x1 ? +x1(d, i, data) : x0z[i], y1 ? +y1(d, i, data) : y0z[i]);
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
if (buffer) return output = null, buffer + "" || null;
|
|
1174
|
+
}
|
|
1175
|
+
function arealine() {
|
|
1176
|
+
return line().defined(defined).curve(curve).context(context);
|
|
1177
|
+
}
|
|
1178
|
+
area.x = function(_) {
|
|
1179
|
+
return arguments.length ? (x0 = typeof _ === "function" ? _ : constant(+_), x1 = null, area) : x0;
|
|
1180
|
+
};
|
|
1181
|
+
area.x0 = function(_) {
|
|
1182
|
+
return arguments.length ? (x0 = typeof _ === "function" ? _ : constant(+_), area) : x0;
|
|
1183
|
+
};
|
|
1184
|
+
area.x1 = function(_) {
|
|
1185
|
+
return arguments.length ? (x1 = _ == null ? null : typeof _ === "function" ? _ : constant(+_), area) : x1;
|
|
1186
|
+
};
|
|
1187
|
+
area.y = function(_) {
|
|
1188
|
+
return arguments.length ? (y0 = typeof _ === "function" ? _ : constant(+_), y1 = null, area) : y0;
|
|
1189
|
+
};
|
|
1190
|
+
area.y0 = function(_) {
|
|
1191
|
+
return arguments.length ? (y0 = typeof _ === "function" ? _ : constant(+_), area) : y0;
|
|
1192
|
+
};
|
|
1193
|
+
area.y1 = function(_) {
|
|
1194
|
+
return arguments.length ? (y1 = _ == null ? null : typeof _ === "function" ? _ : constant(+_), area) : y1;
|
|
1195
|
+
};
|
|
1196
|
+
area.lineX0 = area.lineY0 = function() {
|
|
1197
|
+
return arealine().x(x0).y(y0);
|
|
1198
|
+
};
|
|
1199
|
+
area.lineY1 = function() {
|
|
1200
|
+
return arealine().x(x0).y(y1);
|
|
1201
|
+
};
|
|
1202
|
+
area.lineX1 = function() {
|
|
1203
|
+
return arealine().x(x1).y(y0);
|
|
1204
|
+
};
|
|
1205
|
+
area.defined = function(_) {
|
|
1206
|
+
return arguments.length ? (defined = typeof _ === "function" ? _ : constant(!!_), area) : defined;
|
|
1207
|
+
};
|
|
1208
|
+
area.curve = function(_) {
|
|
1209
|
+
return arguments.length ? (curve = _, context != null && (output = curve(context)), area) : curve;
|
|
1210
|
+
};
|
|
1211
|
+
area.context = function(_) {
|
|
1212
|
+
return arguments.length ? (_ == null ? context = output = null : output = curve(context = _), area) : context;
|
|
1213
|
+
};
|
|
1214
|
+
return area;
|
|
1215
|
+
}
|
|
1216
|
+
function descending(a, b) {
|
|
1217
|
+
return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN;
|
|
1218
|
+
}
|
|
1219
|
+
function identity(d) {
|
|
1220
|
+
return d;
|
|
1221
|
+
}
|
|
1222
|
+
function pie() {
|
|
1223
|
+
var value = identity, sortValues = descending, sort = null, startAngle = constant(0), endAngle = constant(tau), padAngle = constant(0);
|
|
1224
|
+
function pie(data) {
|
|
1225
|
+
var i, n = data.length, j, k, sum = 0, index = new Array(n), arcs = new Array(n), a0 = +startAngle.apply(this, arguments), da = Math.min(tau, Math.max(-tau, endAngle.apply(this, arguments) - a0)), a1, p = Math.min(Math.abs(da) / n, padAngle.apply(this, arguments)), pa = p * (da < 0 ? -1 : 1), v;
|
|
1226
|
+
for (i = 0; i < n; ++i) if ((v = arcs[index[i] = i] = +value(data[i], i, data)) > 0) sum += v;
|
|
1227
|
+
if (sortValues != null) index.sort(function(i, j) {
|
|
1228
|
+
return sortValues(arcs[i], arcs[j]);
|
|
1229
|
+
});
|
|
1230
|
+
else if (sort != null) index.sort(function(i, j) {
|
|
1231
|
+
return sort(data[i], data[j]);
|
|
1232
|
+
});
|
|
1233
|
+
for (i = 0, k = sum ? (da - n * pa) / sum : 0; i < n; ++i, a0 = a1) j = index[i], v = arcs[j], a1 = a0 + (v > 0 ? v * k : 0) + pa, arcs[j] = {
|
|
1234
|
+
data: data[j],
|
|
1235
|
+
index: i,
|
|
1236
|
+
value: v,
|
|
1237
|
+
startAngle: a0,
|
|
1238
|
+
endAngle: a1,
|
|
1239
|
+
padAngle: p
|
|
1240
|
+
};
|
|
1241
|
+
return arcs;
|
|
1242
|
+
}
|
|
1243
|
+
pie.value = function(_) {
|
|
1244
|
+
return arguments.length ? (value = typeof _ === "function" ? _ : constant(+_), pie) : value;
|
|
1245
|
+
};
|
|
1246
|
+
pie.sortValues = function(_) {
|
|
1247
|
+
return arguments.length ? (sortValues = _, sort = null, pie) : sortValues;
|
|
1248
|
+
};
|
|
1249
|
+
pie.sort = function(_) {
|
|
1250
|
+
return arguments.length ? (sort = _, sortValues = null, pie) : sort;
|
|
1251
|
+
};
|
|
1252
|
+
pie.startAngle = function(_) {
|
|
1253
|
+
return arguments.length ? (startAngle = typeof _ === "function" ? _ : constant(+_), pie) : startAngle;
|
|
1254
|
+
};
|
|
1255
|
+
pie.endAngle = function(_) {
|
|
1256
|
+
return arguments.length ? (endAngle = typeof _ === "function" ? _ : constant(+_), pie) : endAngle;
|
|
1257
|
+
};
|
|
1258
|
+
pie.padAngle = function(_) {
|
|
1259
|
+
return arguments.length ? (padAngle = typeof _ === "function" ? _ : constant(+_), pie) : padAngle;
|
|
1260
|
+
};
|
|
1261
|
+
return pie;
|
|
1262
|
+
}
|
|
1263
|
+
var curveRadialLinear = curveRadial(curveLinear);
|
|
1264
|
+
function Radial(curve) {
|
|
1265
|
+
this._curve = curve;
|
|
1266
|
+
}
|
|
1267
|
+
Radial.prototype = {
|
|
1268
|
+
areaStart: function() {
|
|
1269
|
+
this._curve.areaStart();
|
|
1270
|
+
},
|
|
1271
|
+
areaEnd: function() {
|
|
1272
|
+
this._curve.areaEnd();
|
|
1273
|
+
},
|
|
1274
|
+
lineStart: function() {
|
|
1275
|
+
this._curve.lineStart();
|
|
1276
|
+
},
|
|
1277
|
+
lineEnd: function() {
|
|
1278
|
+
this._curve.lineEnd();
|
|
1279
|
+
},
|
|
1280
|
+
point: function(a, r) {
|
|
1281
|
+
this._curve.point(r * Math.sin(a), r * -Math.cos(a));
|
|
1282
|
+
}
|
|
1283
|
+
};
|
|
1284
|
+
function curveRadial(curve) {
|
|
1285
|
+
function radial(context) {
|
|
1286
|
+
return new Radial(curve(context));
|
|
1287
|
+
}
|
|
1288
|
+
radial._curve = curve;
|
|
1289
|
+
return radial;
|
|
1290
|
+
}
|
|
1291
|
+
function lineRadial(l) {
|
|
1292
|
+
var c = l.curve;
|
|
1293
|
+
l.angle = l.x, delete l.x;
|
|
1294
|
+
l.radius = l.y, delete l.y;
|
|
1295
|
+
l.curve = function(_) {
|
|
1296
|
+
return arguments.length ? c(curveRadial(_)) : c()._curve;
|
|
1297
|
+
};
|
|
1298
|
+
return l;
|
|
1299
|
+
}
|
|
1300
|
+
function lineRadial$1() {
|
|
1301
|
+
return lineRadial(line().curve(curveRadialLinear));
|
|
1302
|
+
}
|
|
1303
|
+
function areaRadial() {
|
|
1304
|
+
var a = area().curve(curveRadialLinear), c = a.curve, x0 = a.lineX0, x1 = a.lineX1, y0 = a.lineY0, y1 = a.lineY1;
|
|
1305
|
+
a.angle = a.x, delete a.x;
|
|
1306
|
+
a.startAngle = a.x0, delete a.x0;
|
|
1307
|
+
a.endAngle = a.x1, delete a.x1;
|
|
1308
|
+
a.radius = a.y, delete a.y;
|
|
1309
|
+
a.innerRadius = a.y0, delete a.y0;
|
|
1310
|
+
a.outerRadius = a.y1, delete a.y1;
|
|
1311
|
+
a.lineStartAngle = function() {
|
|
1312
|
+
return lineRadial(x0());
|
|
1313
|
+
}, delete a.lineX0;
|
|
1314
|
+
a.lineEndAngle = function() {
|
|
1315
|
+
return lineRadial(x1());
|
|
1316
|
+
}, delete a.lineX1;
|
|
1317
|
+
a.lineInnerRadius = function() {
|
|
1318
|
+
return lineRadial(y0());
|
|
1319
|
+
}, delete a.lineY0;
|
|
1320
|
+
a.lineOuterRadius = function() {
|
|
1321
|
+
return lineRadial(y1());
|
|
1322
|
+
}, delete a.lineY1;
|
|
1323
|
+
a.curve = function(_) {
|
|
1324
|
+
return arguments.length ? c(curveRadial(_)) : c()._curve;
|
|
1325
|
+
};
|
|
1326
|
+
return a;
|
|
1327
|
+
}
|
|
1328
|
+
function pointRadial(x, y) {
|
|
1329
|
+
return [(y = +y) * Math.cos(x -= Math.PI / 2), y * Math.sin(x)];
|
|
1330
|
+
}
|
|
1331
|
+
var slice = Array.prototype.slice;
|
|
1332
|
+
function linkSource(d) {
|
|
1333
|
+
return d.source;
|
|
1334
|
+
}
|
|
1335
|
+
function linkTarget(d) {
|
|
1336
|
+
return d.target;
|
|
1337
|
+
}
|
|
1338
|
+
function link(curve) {
|
|
1339
|
+
var source = linkSource, target = linkTarget, x$1 = x, y$1 = y, context = null;
|
|
1340
|
+
function link() {
|
|
1341
|
+
var buffer, argv = slice.call(arguments), s = source.apply(this, argv), t = target.apply(this, argv);
|
|
1342
|
+
if (!context) context = buffer = d3Path.path();
|
|
1343
|
+
curve(context, +x$1.apply(this, (argv[0] = s, argv)), +y$1.apply(this, argv), +x$1.apply(this, (argv[0] = t, argv)), +y$1.apply(this, argv));
|
|
1344
|
+
if (buffer) return context = null, buffer + "" || null;
|
|
1345
|
+
}
|
|
1346
|
+
link.source = function(_) {
|
|
1347
|
+
return arguments.length ? (source = _, link) : source;
|
|
1348
|
+
};
|
|
1349
|
+
link.target = function(_) {
|
|
1350
|
+
return arguments.length ? (target = _, link) : target;
|
|
1351
|
+
};
|
|
1352
|
+
link.x = function(_) {
|
|
1353
|
+
return arguments.length ? (x$1 = typeof _ === "function" ? _ : constant(+_), link) : x$1;
|
|
1354
|
+
};
|
|
1355
|
+
link.y = function(_) {
|
|
1356
|
+
return arguments.length ? (y$1 = typeof _ === "function" ? _ : constant(+_), link) : y$1;
|
|
1357
|
+
};
|
|
1358
|
+
link.context = function(_) {
|
|
1359
|
+
return arguments.length ? (context = _ == null ? null : _, link) : context;
|
|
1360
|
+
};
|
|
1361
|
+
return link;
|
|
1362
|
+
}
|
|
1363
|
+
function curveHorizontal(context, x0, y0, x1, y1) {
|
|
1364
|
+
context.moveTo(x0, y0);
|
|
1365
|
+
context.bezierCurveTo(x0 = (x0 + x1) / 2, y0, x0, y1, x1, y1);
|
|
1366
|
+
}
|
|
1367
|
+
function curveVertical(context, x0, y0, x1, y1) {
|
|
1368
|
+
context.moveTo(x0, y0);
|
|
1369
|
+
context.bezierCurveTo(x0, y0 = (y0 + y1) / 2, x1, y0, x1, y1);
|
|
1370
|
+
}
|
|
1371
|
+
function curveRadial$1(context, x0, y0, x1, y1) {
|
|
1372
|
+
var p0 = pointRadial(x0, y0), p1 = pointRadial(x0, y0 = (y0 + y1) / 2), p2 = pointRadial(x1, y0), p3 = pointRadial(x1, y1);
|
|
1373
|
+
context.moveTo(p0[0], p0[1]);
|
|
1374
|
+
context.bezierCurveTo(p1[0], p1[1], p2[0], p2[1], p3[0], p3[1]);
|
|
1375
|
+
}
|
|
1376
|
+
function linkHorizontal() {
|
|
1377
|
+
return link(curveHorizontal);
|
|
1378
|
+
}
|
|
1379
|
+
function linkVertical() {
|
|
1380
|
+
return link(curveVertical);
|
|
1381
|
+
}
|
|
1382
|
+
function linkRadial() {
|
|
1383
|
+
var l = link(curveRadial$1);
|
|
1384
|
+
l.angle = l.x, delete l.x;
|
|
1385
|
+
l.radius = l.y, delete l.y;
|
|
1386
|
+
return l;
|
|
1387
|
+
}
|
|
1388
|
+
var circle = { draw: function(context, size) {
|
|
1389
|
+
var r = Math.sqrt(size / pi);
|
|
1390
|
+
context.moveTo(r, 0);
|
|
1391
|
+
context.arc(0, 0, r, 0, tau);
|
|
1392
|
+
} };
|
|
1393
|
+
var cross = { draw: function(context, size) {
|
|
1394
|
+
var r = Math.sqrt(size / 5) / 2;
|
|
1395
|
+
context.moveTo(-3 * r, -r);
|
|
1396
|
+
context.lineTo(-r, -r);
|
|
1397
|
+
context.lineTo(-r, -3 * r);
|
|
1398
|
+
context.lineTo(r, -3 * r);
|
|
1399
|
+
context.lineTo(r, -r);
|
|
1400
|
+
context.lineTo(3 * r, -r);
|
|
1401
|
+
context.lineTo(3 * r, r);
|
|
1402
|
+
context.lineTo(r, r);
|
|
1403
|
+
context.lineTo(r, 3 * r);
|
|
1404
|
+
context.lineTo(-r, 3 * r);
|
|
1405
|
+
context.lineTo(-r, r);
|
|
1406
|
+
context.lineTo(-3 * r, r);
|
|
1407
|
+
context.closePath();
|
|
1408
|
+
} };
|
|
1409
|
+
var tan30 = Math.sqrt(1 / 3), tan30_2 = tan30 * 2;
|
|
1410
|
+
var diamond = { draw: function(context, size) {
|
|
1411
|
+
var y = Math.sqrt(size / tan30_2), x = y * tan30;
|
|
1412
|
+
context.moveTo(0, -y);
|
|
1413
|
+
context.lineTo(x, 0);
|
|
1414
|
+
context.lineTo(0, y);
|
|
1415
|
+
context.lineTo(-x, 0);
|
|
1416
|
+
context.closePath();
|
|
1417
|
+
} };
|
|
1418
|
+
var ka = .8908130915292852, kr = Math.sin(pi / 10) / Math.sin(7 * pi / 10), kx = Math.sin(tau / 10) * kr, ky = -Math.cos(tau / 10) * kr;
|
|
1419
|
+
var star = { draw: function(context, size) {
|
|
1420
|
+
var r = Math.sqrt(size * ka), x = kx * r, y = ky * r;
|
|
1421
|
+
context.moveTo(0, -r);
|
|
1422
|
+
context.lineTo(x, y);
|
|
1423
|
+
for (var i = 1; i < 5; ++i) {
|
|
1424
|
+
var a = tau * i / 5, c = Math.cos(a), s = Math.sin(a);
|
|
1425
|
+
context.lineTo(s * r, -c * r);
|
|
1426
|
+
context.lineTo(c * x - s * y, s * x + c * y);
|
|
1427
|
+
}
|
|
1428
|
+
context.closePath();
|
|
1429
|
+
} };
|
|
1430
|
+
var square = { draw: function(context, size) {
|
|
1431
|
+
var w = Math.sqrt(size), x = -w / 2;
|
|
1432
|
+
context.rect(x, x, w, w);
|
|
1433
|
+
} };
|
|
1434
|
+
var sqrt3 = Math.sqrt(3);
|
|
1435
|
+
var triangle = { draw: function(context, size) {
|
|
1436
|
+
var y = -Math.sqrt(size / (sqrt3 * 3));
|
|
1437
|
+
context.moveTo(0, y * 2);
|
|
1438
|
+
context.lineTo(-sqrt3 * y, -y);
|
|
1439
|
+
context.lineTo(sqrt3 * y, -y);
|
|
1440
|
+
context.closePath();
|
|
1441
|
+
} };
|
|
1442
|
+
var c = -.5, s = Math.sqrt(3) / 2, k = 1 / Math.sqrt(12), a = (k / 2 + 1) * 3;
|
|
1443
|
+
var wye = { draw: function(context, size) {
|
|
1444
|
+
var r = Math.sqrt(size / a), x0 = r / 2, y0 = r * k, x1 = x0, y1 = r * k + r, x2 = -x1, y2 = y1;
|
|
1445
|
+
context.moveTo(x0, y0);
|
|
1446
|
+
context.lineTo(x1, y1);
|
|
1447
|
+
context.lineTo(x2, y2);
|
|
1448
|
+
context.lineTo(c * x0 - s * y0, s * x0 + c * y0);
|
|
1449
|
+
context.lineTo(c * x1 - s * y1, s * x1 + c * y1);
|
|
1450
|
+
context.lineTo(c * x2 - s * y2, s * x2 + c * y2);
|
|
1451
|
+
context.lineTo(c * x0 + s * y0, c * y0 - s * x0);
|
|
1452
|
+
context.lineTo(c * x1 + s * y1, c * y1 - s * x1);
|
|
1453
|
+
context.lineTo(c * x2 + s * y2, c * y2 - s * x2);
|
|
1454
|
+
context.closePath();
|
|
1455
|
+
} };
|
|
1456
|
+
var symbols = [
|
|
1457
|
+
circle,
|
|
1458
|
+
cross,
|
|
1459
|
+
diamond,
|
|
1460
|
+
square,
|
|
1461
|
+
star,
|
|
1462
|
+
triangle,
|
|
1463
|
+
wye
|
|
1464
|
+
];
|
|
1465
|
+
function symbol() {
|
|
1466
|
+
var type = constant(circle), size = constant(64), context = null;
|
|
1467
|
+
function symbol() {
|
|
1468
|
+
var buffer;
|
|
1469
|
+
if (!context) context = buffer = d3Path.path();
|
|
1470
|
+
type.apply(this, arguments).draw(context, +size.apply(this, arguments));
|
|
1471
|
+
if (buffer) return context = null, buffer + "" || null;
|
|
1472
|
+
}
|
|
1473
|
+
symbol.type = function(_) {
|
|
1474
|
+
return arguments.length ? (type = typeof _ === "function" ? _ : constant(_), symbol) : type;
|
|
1475
|
+
};
|
|
1476
|
+
symbol.size = function(_) {
|
|
1477
|
+
return arguments.length ? (size = typeof _ === "function" ? _ : constant(+_), symbol) : size;
|
|
1478
|
+
};
|
|
1479
|
+
symbol.context = function(_) {
|
|
1480
|
+
return arguments.length ? (context = _ == null ? null : _, symbol) : context;
|
|
1481
|
+
};
|
|
1482
|
+
return symbol;
|
|
1483
|
+
}
|
|
1484
|
+
function noop() {}
|
|
1485
|
+
function point(that, x, y) {
|
|
1486
|
+
that._context.bezierCurveTo((2 * that._x0 + that._x1) / 3, (2 * that._y0 + that._y1) / 3, (that._x0 + 2 * that._x1) / 3, (that._y0 + 2 * that._y1) / 3, (that._x0 + 4 * that._x1 + x) / 6, (that._y0 + 4 * that._y1 + y) / 6);
|
|
1487
|
+
}
|
|
1488
|
+
function Basis(context) {
|
|
1489
|
+
this._context = context;
|
|
1490
|
+
}
|
|
1491
|
+
Basis.prototype = {
|
|
1492
|
+
areaStart: function() {
|
|
1493
|
+
this._line = 0;
|
|
1494
|
+
},
|
|
1495
|
+
areaEnd: function() {
|
|
1496
|
+
this._line = NaN;
|
|
1497
|
+
},
|
|
1498
|
+
lineStart: function() {
|
|
1499
|
+
this._x0 = this._x1 = this._y0 = this._y1 = NaN;
|
|
1500
|
+
this._point = 0;
|
|
1501
|
+
},
|
|
1502
|
+
lineEnd: function() {
|
|
1503
|
+
switch (this._point) {
|
|
1504
|
+
case 3: point(this, this._x1, this._y1);
|
|
1505
|
+
case 2: this._context.lineTo(this._x1, this._y1);
|
|
1506
|
+
}
|
|
1507
|
+
if (this._line || this._line !== 0 && this._point === 1) this._context.closePath();
|
|
1508
|
+
this._line = 1 - this._line;
|
|
1509
|
+
},
|
|
1510
|
+
point: function(x, y) {
|
|
1511
|
+
x = +x, y = +y;
|
|
1512
|
+
switch (this._point) {
|
|
1513
|
+
case 0:
|
|
1514
|
+
this._point = 1;
|
|
1515
|
+
this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y);
|
|
1516
|
+
break;
|
|
1517
|
+
case 1:
|
|
1518
|
+
this._point = 2;
|
|
1519
|
+
break;
|
|
1520
|
+
case 2:
|
|
1521
|
+
this._point = 3;
|
|
1522
|
+
this._context.lineTo((5 * this._x0 + this._x1) / 6, (5 * this._y0 + this._y1) / 6);
|
|
1523
|
+
default: point(this, x, y);
|
|
1524
|
+
}
|
|
1525
|
+
this._x0 = this._x1, this._x1 = x;
|
|
1526
|
+
this._y0 = this._y1, this._y1 = y;
|
|
1527
|
+
}
|
|
1528
|
+
};
|
|
1529
|
+
function basis(context) {
|
|
1530
|
+
return new Basis(context);
|
|
1531
|
+
}
|
|
1532
|
+
function BasisClosed(context) {
|
|
1533
|
+
this._context = context;
|
|
1534
|
+
}
|
|
1535
|
+
BasisClosed.prototype = {
|
|
1536
|
+
areaStart: noop,
|
|
1537
|
+
areaEnd: noop,
|
|
1538
|
+
lineStart: function() {
|
|
1539
|
+
this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = NaN;
|
|
1540
|
+
this._point = 0;
|
|
1541
|
+
},
|
|
1542
|
+
lineEnd: function() {
|
|
1543
|
+
switch (this._point) {
|
|
1544
|
+
case 1:
|
|
1545
|
+
this._context.moveTo(this._x2, this._y2);
|
|
1546
|
+
this._context.closePath();
|
|
1547
|
+
break;
|
|
1548
|
+
case 2:
|
|
1549
|
+
this._context.moveTo((this._x2 + 2 * this._x3) / 3, (this._y2 + 2 * this._y3) / 3);
|
|
1550
|
+
this._context.lineTo((this._x3 + 2 * this._x2) / 3, (this._y3 + 2 * this._y2) / 3);
|
|
1551
|
+
this._context.closePath();
|
|
1552
|
+
break;
|
|
1553
|
+
case 3:
|
|
1554
|
+
this.point(this._x2, this._y2);
|
|
1555
|
+
this.point(this._x3, this._y3);
|
|
1556
|
+
this.point(this._x4, this._y4);
|
|
1557
|
+
}
|
|
1558
|
+
},
|
|
1559
|
+
point: function(x, y) {
|
|
1560
|
+
x = +x, y = +y;
|
|
1561
|
+
switch (this._point) {
|
|
1562
|
+
case 0:
|
|
1563
|
+
this._point = 1;
|
|
1564
|
+
this._x2 = x, this._y2 = y;
|
|
1565
|
+
break;
|
|
1566
|
+
case 1:
|
|
1567
|
+
this._point = 2;
|
|
1568
|
+
this._x3 = x, this._y3 = y;
|
|
1569
|
+
break;
|
|
1570
|
+
case 2:
|
|
1571
|
+
this._point = 3;
|
|
1572
|
+
this._x4 = x, this._y4 = y;
|
|
1573
|
+
this._context.moveTo((this._x0 + 4 * this._x1 + x) / 6, (this._y0 + 4 * this._y1 + y) / 6);
|
|
1574
|
+
break;
|
|
1575
|
+
default: point(this, x, y);
|
|
1576
|
+
}
|
|
1577
|
+
this._x0 = this._x1, this._x1 = x;
|
|
1578
|
+
this._y0 = this._y1, this._y1 = y;
|
|
1579
|
+
}
|
|
1580
|
+
};
|
|
1581
|
+
function basisClosed(context) {
|
|
1582
|
+
return new BasisClosed(context);
|
|
1583
|
+
}
|
|
1584
|
+
function BasisOpen(context) {
|
|
1585
|
+
this._context = context;
|
|
1586
|
+
}
|
|
1587
|
+
BasisOpen.prototype = {
|
|
1588
|
+
areaStart: function() {
|
|
1589
|
+
this._line = 0;
|
|
1590
|
+
},
|
|
1591
|
+
areaEnd: function() {
|
|
1592
|
+
this._line = NaN;
|
|
1593
|
+
},
|
|
1594
|
+
lineStart: function() {
|
|
1595
|
+
this._x0 = this._x1 = this._y0 = this._y1 = NaN;
|
|
1596
|
+
this._point = 0;
|
|
1597
|
+
},
|
|
1598
|
+
lineEnd: function() {
|
|
1599
|
+
if (this._line || this._line !== 0 && this._point === 3) this._context.closePath();
|
|
1600
|
+
this._line = 1 - this._line;
|
|
1601
|
+
},
|
|
1602
|
+
point: function(x, y) {
|
|
1603
|
+
x = +x, y = +y;
|
|
1604
|
+
switch (this._point) {
|
|
1605
|
+
case 0:
|
|
1606
|
+
this._point = 1;
|
|
1607
|
+
break;
|
|
1608
|
+
case 1:
|
|
1609
|
+
this._point = 2;
|
|
1610
|
+
break;
|
|
1611
|
+
case 2:
|
|
1612
|
+
this._point = 3;
|
|
1613
|
+
var x0 = (this._x0 + 4 * this._x1 + x) / 6, y0 = (this._y0 + 4 * this._y1 + y) / 6;
|
|
1614
|
+
this._line ? this._context.lineTo(x0, y0) : this._context.moveTo(x0, y0);
|
|
1615
|
+
break;
|
|
1616
|
+
case 3: this._point = 4;
|
|
1617
|
+
default: point(this, x, y);
|
|
1618
|
+
}
|
|
1619
|
+
this._x0 = this._x1, this._x1 = x;
|
|
1620
|
+
this._y0 = this._y1, this._y1 = y;
|
|
1621
|
+
}
|
|
1622
|
+
};
|
|
1623
|
+
function basisOpen(context) {
|
|
1624
|
+
return new BasisOpen(context);
|
|
1625
|
+
}
|
|
1626
|
+
function Bundle(context, beta) {
|
|
1627
|
+
this._basis = new Basis(context);
|
|
1628
|
+
this._beta = beta;
|
|
1629
|
+
}
|
|
1630
|
+
Bundle.prototype = {
|
|
1631
|
+
lineStart: function() {
|
|
1632
|
+
this._x = [];
|
|
1633
|
+
this._y = [];
|
|
1634
|
+
this._basis.lineStart();
|
|
1635
|
+
},
|
|
1636
|
+
lineEnd: function() {
|
|
1637
|
+
var x = this._x, y = this._y, j = x.length - 1;
|
|
1638
|
+
if (j > 0) {
|
|
1639
|
+
var x0 = x[0], y0 = y[0], dx = x[j] - x0, dy = y[j] - y0, i = -1, t;
|
|
1640
|
+
while (++i <= j) {
|
|
1641
|
+
t = i / j;
|
|
1642
|
+
this._basis.point(this._beta * x[i] + (1 - this._beta) * (x0 + t * dx), this._beta * y[i] + (1 - this._beta) * (y0 + t * dy));
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
this._x = this._y = null;
|
|
1646
|
+
this._basis.lineEnd();
|
|
1647
|
+
},
|
|
1648
|
+
point: function(x, y) {
|
|
1649
|
+
this._x.push(+x);
|
|
1650
|
+
this._y.push(+y);
|
|
1651
|
+
}
|
|
1652
|
+
};
|
|
1653
|
+
var bundle = (function custom(beta) {
|
|
1654
|
+
function bundle(context) {
|
|
1655
|
+
return beta === 1 ? new Basis(context) : new Bundle(context, beta);
|
|
1656
|
+
}
|
|
1657
|
+
bundle.beta = function(beta) {
|
|
1658
|
+
return custom(+beta);
|
|
1659
|
+
};
|
|
1660
|
+
return bundle;
|
|
1661
|
+
})(.85);
|
|
1662
|
+
function point$1(that, x, y) {
|
|
1663
|
+
that._context.bezierCurveTo(that._x1 + that._k * (that._x2 - that._x0), that._y1 + that._k * (that._y2 - that._y0), that._x2 + that._k * (that._x1 - x), that._y2 + that._k * (that._y1 - y), that._x2, that._y2);
|
|
1664
|
+
}
|
|
1665
|
+
function Cardinal(context, tension) {
|
|
1666
|
+
this._context = context;
|
|
1667
|
+
this._k = (1 - tension) / 6;
|
|
1668
|
+
}
|
|
1669
|
+
Cardinal.prototype = {
|
|
1670
|
+
areaStart: function() {
|
|
1671
|
+
this._line = 0;
|
|
1672
|
+
},
|
|
1673
|
+
areaEnd: function() {
|
|
1674
|
+
this._line = NaN;
|
|
1675
|
+
},
|
|
1676
|
+
lineStart: function() {
|
|
1677
|
+
this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN;
|
|
1678
|
+
this._point = 0;
|
|
1679
|
+
},
|
|
1680
|
+
lineEnd: function() {
|
|
1681
|
+
switch (this._point) {
|
|
1682
|
+
case 2:
|
|
1683
|
+
this._context.lineTo(this._x2, this._y2);
|
|
1684
|
+
break;
|
|
1685
|
+
case 3: point$1(this, this._x1, this._y1);
|
|
1686
|
+
}
|
|
1687
|
+
if (this._line || this._line !== 0 && this._point === 1) this._context.closePath();
|
|
1688
|
+
this._line = 1 - this._line;
|
|
1689
|
+
},
|
|
1690
|
+
point: function(x, y) {
|
|
1691
|
+
x = +x, y = +y;
|
|
1692
|
+
switch (this._point) {
|
|
1693
|
+
case 0:
|
|
1694
|
+
this._point = 1;
|
|
1695
|
+
this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y);
|
|
1696
|
+
break;
|
|
1697
|
+
case 1:
|
|
1698
|
+
this._point = 2;
|
|
1699
|
+
this._x1 = x, this._y1 = y;
|
|
1700
|
+
break;
|
|
1701
|
+
case 2: this._point = 3;
|
|
1702
|
+
default: point$1(this, x, y);
|
|
1703
|
+
}
|
|
1704
|
+
this._x0 = this._x1, this._x1 = this._x2, this._x2 = x;
|
|
1705
|
+
this._y0 = this._y1, this._y1 = this._y2, this._y2 = y;
|
|
1706
|
+
}
|
|
1707
|
+
};
|
|
1708
|
+
var cardinal = (function custom(tension) {
|
|
1709
|
+
function cardinal(context) {
|
|
1710
|
+
return new Cardinal(context, tension);
|
|
1711
|
+
}
|
|
1712
|
+
cardinal.tension = function(tension) {
|
|
1713
|
+
return custom(+tension);
|
|
1714
|
+
};
|
|
1715
|
+
return cardinal;
|
|
1716
|
+
})(0);
|
|
1717
|
+
function CardinalClosed(context, tension) {
|
|
1718
|
+
this._context = context;
|
|
1719
|
+
this._k = (1 - tension) / 6;
|
|
1720
|
+
}
|
|
1721
|
+
CardinalClosed.prototype = {
|
|
1722
|
+
areaStart: noop,
|
|
1723
|
+
areaEnd: noop,
|
|
1724
|
+
lineStart: function() {
|
|
1725
|
+
this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._x5 = this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = this._y5 = NaN;
|
|
1726
|
+
this._point = 0;
|
|
1727
|
+
},
|
|
1728
|
+
lineEnd: function() {
|
|
1729
|
+
switch (this._point) {
|
|
1730
|
+
case 1:
|
|
1731
|
+
this._context.moveTo(this._x3, this._y3);
|
|
1732
|
+
this._context.closePath();
|
|
1733
|
+
break;
|
|
1734
|
+
case 2:
|
|
1735
|
+
this._context.lineTo(this._x3, this._y3);
|
|
1736
|
+
this._context.closePath();
|
|
1737
|
+
break;
|
|
1738
|
+
case 3:
|
|
1739
|
+
this.point(this._x3, this._y3);
|
|
1740
|
+
this.point(this._x4, this._y4);
|
|
1741
|
+
this.point(this._x5, this._y5);
|
|
1742
|
+
}
|
|
1743
|
+
},
|
|
1744
|
+
point: function(x, y) {
|
|
1745
|
+
x = +x, y = +y;
|
|
1746
|
+
switch (this._point) {
|
|
1747
|
+
case 0:
|
|
1748
|
+
this._point = 1;
|
|
1749
|
+
this._x3 = x, this._y3 = y;
|
|
1750
|
+
break;
|
|
1751
|
+
case 1:
|
|
1752
|
+
this._point = 2;
|
|
1753
|
+
this._context.moveTo(this._x4 = x, this._y4 = y);
|
|
1754
|
+
break;
|
|
1755
|
+
case 2:
|
|
1756
|
+
this._point = 3;
|
|
1757
|
+
this._x5 = x, this._y5 = y;
|
|
1758
|
+
break;
|
|
1759
|
+
default: point$1(this, x, y);
|
|
1760
|
+
}
|
|
1761
|
+
this._x0 = this._x1, this._x1 = this._x2, this._x2 = x;
|
|
1762
|
+
this._y0 = this._y1, this._y1 = this._y2, this._y2 = y;
|
|
1763
|
+
}
|
|
1764
|
+
};
|
|
1765
|
+
var cardinalClosed = (function custom(tension) {
|
|
1766
|
+
function cardinal(context) {
|
|
1767
|
+
return new CardinalClosed(context, tension);
|
|
1768
|
+
}
|
|
1769
|
+
cardinal.tension = function(tension) {
|
|
1770
|
+
return custom(+tension);
|
|
1771
|
+
};
|
|
1772
|
+
return cardinal;
|
|
1773
|
+
})(0);
|
|
1774
|
+
function CardinalOpen(context, tension) {
|
|
1775
|
+
this._context = context;
|
|
1776
|
+
this._k = (1 - tension) / 6;
|
|
1777
|
+
}
|
|
1778
|
+
CardinalOpen.prototype = {
|
|
1779
|
+
areaStart: function() {
|
|
1780
|
+
this._line = 0;
|
|
1781
|
+
},
|
|
1782
|
+
areaEnd: function() {
|
|
1783
|
+
this._line = NaN;
|
|
1784
|
+
},
|
|
1785
|
+
lineStart: function() {
|
|
1786
|
+
this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN;
|
|
1787
|
+
this._point = 0;
|
|
1788
|
+
},
|
|
1789
|
+
lineEnd: function() {
|
|
1790
|
+
if (this._line || this._line !== 0 && this._point === 3) this._context.closePath();
|
|
1791
|
+
this._line = 1 - this._line;
|
|
1792
|
+
},
|
|
1793
|
+
point: function(x, y) {
|
|
1794
|
+
x = +x, y = +y;
|
|
1795
|
+
switch (this._point) {
|
|
1796
|
+
case 0:
|
|
1797
|
+
this._point = 1;
|
|
1798
|
+
break;
|
|
1799
|
+
case 1:
|
|
1800
|
+
this._point = 2;
|
|
1801
|
+
break;
|
|
1802
|
+
case 2:
|
|
1803
|
+
this._point = 3;
|
|
1804
|
+
this._line ? this._context.lineTo(this._x2, this._y2) : this._context.moveTo(this._x2, this._y2);
|
|
1805
|
+
break;
|
|
1806
|
+
case 3: this._point = 4;
|
|
1807
|
+
default: point$1(this, x, y);
|
|
1808
|
+
}
|
|
1809
|
+
this._x0 = this._x1, this._x1 = this._x2, this._x2 = x;
|
|
1810
|
+
this._y0 = this._y1, this._y1 = this._y2, this._y2 = y;
|
|
1811
|
+
}
|
|
1812
|
+
};
|
|
1813
|
+
var cardinalOpen = (function custom(tension) {
|
|
1814
|
+
function cardinal(context) {
|
|
1815
|
+
return new CardinalOpen(context, tension);
|
|
1816
|
+
}
|
|
1817
|
+
cardinal.tension = function(tension) {
|
|
1818
|
+
return custom(+tension);
|
|
1819
|
+
};
|
|
1820
|
+
return cardinal;
|
|
1821
|
+
})(0);
|
|
1822
|
+
function point$2(that, x, y) {
|
|
1823
|
+
var x1 = that._x1, y1 = that._y1, x2 = that._x2, y2 = that._y2;
|
|
1824
|
+
if (that._l01_a > epsilon) {
|
|
1825
|
+
var a = 2 * that._l01_2a + 3 * that._l01_a * that._l12_a + that._l12_2a, n = 3 * that._l01_a * (that._l01_a + that._l12_a);
|
|
1826
|
+
x1 = (x1 * a - that._x0 * that._l12_2a + that._x2 * that._l01_2a) / n;
|
|
1827
|
+
y1 = (y1 * a - that._y0 * that._l12_2a + that._y2 * that._l01_2a) / n;
|
|
1828
|
+
}
|
|
1829
|
+
if (that._l23_a > epsilon) {
|
|
1830
|
+
var b = 2 * that._l23_2a + 3 * that._l23_a * that._l12_a + that._l12_2a, m = 3 * that._l23_a * (that._l23_a + that._l12_a);
|
|
1831
|
+
x2 = (x2 * b + that._x1 * that._l23_2a - x * that._l12_2a) / m;
|
|
1832
|
+
y2 = (y2 * b + that._y1 * that._l23_2a - y * that._l12_2a) / m;
|
|
1833
|
+
}
|
|
1834
|
+
that._context.bezierCurveTo(x1, y1, x2, y2, that._x2, that._y2);
|
|
1835
|
+
}
|
|
1836
|
+
function CatmullRom(context, alpha) {
|
|
1837
|
+
this._context = context;
|
|
1838
|
+
this._alpha = alpha;
|
|
1839
|
+
}
|
|
1840
|
+
CatmullRom.prototype = {
|
|
1841
|
+
areaStart: function() {
|
|
1842
|
+
this._line = 0;
|
|
1843
|
+
},
|
|
1844
|
+
areaEnd: function() {
|
|
1845
|
+
this._line = NaN;
|
|
1846
|
+
},
|
|
1847
|
+
lineStart: function() {
|
|
1848
|
+
this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN;
|
|
1849
|
+
this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0;
|
|
1850
|
+
},
|
|
1851
|
+
lineEnd: function() {
|
|
1852
|
+
switch (this._point) {
|
|
1853
|
+
case 2:
|
|
1854
|
+
this._context.lineTo(this._x2, this._y2);
|
|
1855
|
+
break;
|
|
1856
|
+
case 3: this.point(this._x2, this._y2);
|
|
1857
|
+
}
|
|
1858
|
+
if (this._line || this._line !== 0 && this._point === 1) this._context.closePath();
|
|
1859
|
+
this._line = 1 - this._line;
|
|
1860
|
+
},
|
|
1861
|
+
point: function(x, y) {
|
|
1862
|
+
x = +x, y = +y;
|
|
1863
|
+
if (this._point) {
|
|
1864
|
+
var x23 = this._x2 - x, y23 = this._y2 - y;
|
|
1865
|
+
this._l23_a = Math.sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23, this._alpha));
|
|
1866
|
+
}
|
|
1867
|
+
switch (this._point) {
|
|
1868
|
+
case 0:
|
|
1869
|
+
this._point = 1;
|
|
1870
|
+
this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y);
|
|
1871
|
+
break;
|
|
1872
|
+
case 1:
|
|
1873
|
+
this._point = 2;
|
|
1874
|
+
break;
|
|
1875
|
+
case 2: this._point = 3;
|
|
1876
|
+
default: point$2(this, x, y);
|
|
1877
|
+
}
|
|
1878
|
+
this._l01_a = this._l12_a, this._l12_a = this._l23_a;
|
|
1879
|
+
this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a;
|
|
1880
|
+
this._x0 = this._x1, this._x1 = this._x2, this._x2 = x;
|
|
1881
|
+
this._y0 = this._y1, this._y1 = this._y2, this._y2 = y;
|
|
1882
|
+
}
|
|
1883
|
+
};
|
|
1884
|
+
var catmullRom = (function custom(alpha) {
|
|
1885
|
+
function catmullRom(context) {
|
|
1886
|
+
return alpha ? new CatmullRom(context, alpha) : new Cardinal(context, 0);
|
|
1887
|
+
}
|
|
1888
|
+
catmullRom.alpha = function(alpha) {
|
|
1889
|
+
return custom(+alpha);
|
|
1890
|
+
};
|
|
1891
|
+
return catmullRom;
|
|
1892
|
+
})(.5);
|
|
1893
|
+
function CatmullRomClosed(context, alpha) {
|
|
1894
|
+
this._context = context;
|
|
1895
|
+
this._alpha = alpha;
|
|
1896
|
+
}
|
|
1897
|
+
CatmullRomClosed.prototype = {
|
|
1898
|
+
areaStart: noop,
|
|
1899
|
+
areaEnd: noop,
|
|
1900
|
+
lineStart: function() {
|
|
1901
|
+
this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._x5 = this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = this._y5 = NaN;
|
|
1902
|
+
this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0;
|
|
1903
|
+
},
|
|
1904
|
+
lineEnd: function() {
|
|
1905
|
+
switch (this._point) {
|
|
1906
|
+
case 1:
|
|
1907
|
+
this._context.moveTo(this._x3, this._y3);
|
|
1908
|
+
this._context.closePath();
|
|
1909
|
+
break;
|
|
1910
|
+
case 2:
|
|
1911
|
+
this._context.lineTo(this._x3, this._y3);
|
|
1912
|
+
this._context.closePath();
|
|
1913
|
+
break;
|
|
1914
|
+
case 3:
|
|
1915
|
+
this.point(this._x3, this._y3);
|
|
1916
|
+
this.point(this._x4, this._y4);
|
|
1917
|
+
this.point(this._x5, this._y5);
|
|
1918
|
+
}
|
|
1919
|
+
},
|
|
1920
|
+
point: function(x, y) {
|
|
1921
|
+
x = +x, y = +y;
|
|
1922
|
+
if (this._point) {
|
|
1923
|
+
var x23 = this._x2 - x, y23 = this._y2 - y;
|
|
1924
|
+
this._l23_a = Math.sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23, this._alpha));
|
|
1925
|
+
}
|
|
1926
|
+
switch (this._point) {
|
|
1927
|
+
case 0:
|
|
1928
|
+
this._point = 1;
|
|
1929
|
+
this._x3 = x, this._y3 = y;
|
|
1930
|
+
break;
|
|
1931
|
+
case 1:
|
|
1932
|
+
this._point = 2;
|
|
1933
|
+
this._context.moveTo(this._x4 = x, this._y4 = y);
|
|
1934
|
+
break;
|
|
1935
|
+
case 2:
|
|
1936
|
+
this._point = 3;
|
|
1937
|
+
this._x5 = x, this._y5 = y;
|
|
1938
|
+
break;
|
|
1939
|
+
default: point$2(this, x, y);
|
|
1940
|
+
}
|
|
1941
|
+
this._l01_a = this._l12_a, this._l12_a = this._l23_a;
|
|
1942
|
+
this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a;
|
|
1943
|
+
this._x0 = this._x1, this._x1 = this._x2, this._x2 = x;
|
|
1944
|
+
this._y0 = this._y1, this._y1 = this._y2, this._y2 = y;
|
|
1945
|
+
}
|
|
1946
|
+
};
|
|
1947
|
+
var catmullRomClosed = (function custom(alpha) {
|
|
1948
|
+
function catmullRom(context) {
|
|
1949
|
+
return alpha ? new CatmullRomClosed(context, alpha) : new CardinalClosed(context, 0);
|
|
1950
|
+
}
|
|
1951
|
+
catmullRom.alpha = function(alpha) {
|
|
1952
|
+
return custom(+alpha);
|
|
1953
|
+
};
|
|
1954
|
+
return catmullRom;
|
|
1955
|
+
})(.5);
|
|
1956
|
+
function CatmullRomOpen(context, alpha) {
|
|
1957
|
+
this._context = context;
|
|
1958
|
+
this._alpha = alpha;
|
|
1959
|
+
}
|
|
1960
|
+
CatmullRomOpen.prototype = {
|
|
1961
|
+
areaStart: function() {
|
|
1962
|
+
this._line = 0;
|
|
1963
|
+
},
|
|
1964
|
+
areaEnd: function() {
|
|
1965
|
+
this._line = NaN;
|
|
1966
|
+
},
|
|
1967
|
+
lineStart: function() {
|
|
1968
|
+
this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN;
|
|
1969
|
+
this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0;
|
|
1970
|
+
},
|
|
1971
|
+
lineEnd: function() {
|
|
1972
|
+
if (this._line || this._line !== 0 && this._point === 3) this._context.closePath();
|
|
1973
|
+
this._line = 1 - this._line;
|
|
1974
|
+
},
|
|
1975
|
+
point: function(x, y) {
|
|
1976
|
+
x = +x, y = +y;
|
|
1977
|
+
if (this._point) {
|
|
1978
|
+
var x23 = this._x2 - x, y23 = this._y2 - y;
|
|
1979
|
+
this._l23_a = Math.sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23, this._alpha));
|
|
1980
|
+
}
|
|
1981
|
+
switch (this._point) {
|
|
1982
|
+
case 0:
|
|
1983
|
+
this._point = 1;
|
|
1984
|
+
break;
|
|
1985
|
+
case 1:
|
|
1986
|
+
this._point = 2;
|
|
1987
|
+
break;
|
|
1988
|
+
case 2:
|
|
1989
|
+
this._point = 3;
|
|
1990
|
+
this._line ? this._context.lineTo(this._x2, this._y2) : this._context.moveTo(this._x2, this._y2);
|
|
1991
|
+
break;
|
|
1992
|
+
case 3: this._point = 4;
|
|
1993
|
+
default: point$2(this, x, y);
|
|
1994
|
+
}
|
|
1995
|
+
this._l01_a = this._l12_a, this._l12_a = this._l23_a;
|
|
1996
|
+
this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a;
|
|
1997
|
+
this._x0 = this._x1, this._x1 = this._x2, this._x2 = x;
|
|
1998
|
+
this._y0 = this._y1, this._y1 = this._y2, this._y2 = y;
|
|
1999
|
+
}
|
|
2000
|
+
};
|
|
2001
|
+
var catmullRomOpen = (function custom(alpha) {
|
|
2002
|
+
function catmullRom(context) {
|
|
2003
|
+
return alpha ? new CatmullRomOpen(context, alpha) : new CardinalOpen(context, 0);
|
|
2004
|
+
}
|
|
2005
|
+
catmullRom.alpha = function(alpha) {
|
|
2006
|
+
return custom(+alpha);
|
|
2007
|
+
};
|
|
2008
|
+
return catmullRom;
|
|
2009
|
+
})(.5);
|
|
2010
|
+
function LinearClosed(context) {
|
|
2011
|
+
this._context = context;
|
|
2012
|
+
}
|
|
2013
|
+
LinearClosed.prototype = {
|
|
2014
|
+
areaStart: noop,
|
|
2015
|
+
areaEnd: noop,
|
|
2016
|
+
lineStart: function() {
|
|
2017
|
+
this._point = 0;
|
|
2018
|
+
},
|
|
2019
|
+
lineEnd: function() {
|
|
2020
|
+
if (this._point) this._context.closePath();
|
|
2021
|
+
},
|
|
2022
|
+
point: function(x, y) {
|
|
2023
|
+
x = +x, y = +y;
|
|
2024
|
+
if (this._point) this._context.lineTo(x, y);
|
|
2025
|
+
else this._point = 1, this._context.moveTo(x, y);
|
|
2026
|
+
}
|
|
2027
|
+
};
|
|
2028
|
+
function linearClosed(context) {
|
|
2029
|
+
return new LinearClosed(context);
|
|
2030
|
+
}
|
|
2031
|
+
function sign(x) {
|
|
2032
|
+
return x < 0 ? -1 : 1;
|
|
2033
|
+
}
|
|
2034
|
+
function slope3(that, x2, y2) {
|
|
2035
|
+
var h0 = that._x1 - that._x0, h1 = x2 - that._x1, s0 = (that._y1 - that._y0) / (h0 || h1 < 0 && -0), s1 = (y2 - that._y1) / (h1 || h0 < 0 && -0), p = (s0 * h1 + s1 * h0) / (h0 + h1);
|
|
2036
|
+
return (sign(s0) + sign(s1)) * Math.min(Math.abs(s0), Math.abs(s1), .5 * Math.abs(p)) || 0;
|
|
2037
|
+
}
|
|
2038
|
+
function slope2(that, t) {
|
|
2039
|
+
var h = that._x1 - that._x0;
|
|
2040
|
+
return h ? (3 * (that._y1 - that._y0) / h - t) / 2 : t;
|
|
2041
|
+
}
|
|
2042
|
+
function point$3(that, t0, t1) {
|
|
2043
|
+
var x0 = that._x0, y0 = that._y0, x1 = that._x1, y1 = that._y1, dx = (x1 - x0) / 3;
|
|
2044
|
+
that._context.bezierCurveTo(x0 + dx, y0 + dx * t0, x1 - dx, y1 - dx * t1, x1, y1);
|
|
2045
|
+
}
|
|
2046
|
+
function MonotoneX(context) {
|
|
2047
|
+
this._context = context;
|
|
2048
|
+
}
|
|
2049
|
+
MonotoneX.prototype = {
|
|
2050
|
+
areaStart: function() {
|
|
2051
|
+
this._line = 0;
|
|
2052
|
+
},
|
|
2053
|
+
areaEnd: function() {
|
|
2054
|
+
this._line = NaN;
|
|
2055
|
+
},
|
|
2056
|
+
lineStart: function() {
|
|
2057
|
+
this._x0 = this._x1 = this._y0 = this._y1 = this._t0 = NaN;
|
|
2058
|
+
this._point = 0;
|
|
2059
|
+
},
|
|
2060
|
+
lineEnd: function() {
|
|
2061
|
+
switch (this._point) {
|
|
2062
|
+
case 2:
|
|
2063
|
+
this._context.lineTo(this._x1, this._y1);
|
|
2064
|
+
break;
|
|
2065
|
+
case 3: point$3(this, this._t0, slope2(this, this._t0));
|
|
2066
|
+
}
|
|
2067
|
+
if (this._line || this._line !== 0 && this._point === 1) this._context.closePath();
|
|
2068
|
+
this._line = 1 - this._line;
|
|
2069
|
+
},
|
|
2070
|
+
point: function(x, y) {
|
|
2071
|
+
var t1 = NaN;
|
|
2072
|
+
x = +x, y = +y;
|
|
2073
|
+
if (x === this._x1 && y === this._y1) return;
|
|
2074
|
+
switch (this._point) {
|
|
2075
|
+
case 0:
|
|
2076
|
+
this._point = 1;
|
|
2077
|
+
this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y);
|
|
2078
|
+
break;
|
|
2079
|
+
case 1:
|
|
2080
|
+
this._point = 2;
|
|
2081
|
+
break;
|
|
2082
|
+
case 2:
|
|
2083
|
+
this._point = 3;
|
|
2084
|
+
point$3(this, slope2(this, t1 = slope3(this, x, y)), t1);
|
|
2085
|
+
break;
|
|
2086
|
+
default: point$3(this, this._t0, t1 = slope3(this, x, y));
|
|
2087
|
+
}
|
|
2088
|
+
this._x0 = this._x1, this._x1 = x;
|
|
2089
|
+
this._y0 = this._y1, this._y1 = y;
|
|
2090
|
+
this._t0 = t1;
|
|
2091
|
+
}
|
|
2092
|
+
};
|
|
2093
|
+
function MonotoneY(context) {
|
|
2094
|
+
this._context = new ReflectContext(context);
|
|
2095
|
+
}
|
|
2096
|
+
(MonotoneY.prototype = Object.create(MonotoneX.prototype)).point = function(x, y) {
|
|
2097
|
+
MonotoneX.prototype.point.call(this, y, x);
|
|
2098
|
+
};
|
|
2099
|
+
function ReflectContext(context) {
|
|
2100
|
+
this._context = context;
|
|
2101
|
+
}
|
|
2102
|
+
ReflectContext.prototype = {
|
|
2103
|
+
moveTo: function(x, y) {
|
|
2104
|
+
this._context.moveTo(y, x);
|
|
2105
|
+
},
|
|
2106
|
+
closePath: function() {
|
|
2107
|
+
this._context.closePath();
|
|
2108
|
+
},
|
|
2109
|
+
lineTo: function(x, y) {
|
|
2110
|
+
this._context.lineTo(y, x);
|
|
2111
|
+
},
|
|
2112
|
+
bezierCurveTo: function(x1, y1, x2, y2, x, y) {
|
|
2113
|
+
this._context.bezierCurveTo(y1, x1, y2, x2, y, x);
|
|
2114
|
+
}
|
|
2115
|
+
};
|
|
2116
|
+
function monotoneX(context) {
|
|
2117
|
+
return new MonotoneX(context);
|
|
2118
|
+
}
|
|
2119
|
+
function monotoneY(context) {
|
|
2120
|
+
return new MonotoneY(context);
|
|
2121
|
+
}
|
|
2122
|
+
function Natural(context) {
|
|
2123
|
+
this._context = context;
|
|
2124
|
+
}
|
|
2125
|
+
Natural.prototype = {
|
|
2126
|
+
areaStart: function() {
|
|
2127
|
+
this._line = 0;
|
|
2128
|
+
},
|
|
2129
|
+
areaEnd: function() {
|
|
2130
|
+
this._line = NaN;
|
|
2131
|
+
},
|
|
2132
|
+
lineStart: function() {
|
|
2133
|
+
this._x = [];
|
|
2134
|
+
this._y = [];
|
|
2135
|
+
},
|
|
2136
|
+
lineEnd: function() {
|
|
2137
|
+
var x = this._x, y = this._y, n = x.length;
|
|
2138
|
+
if (n) {
|
|
2139
|
+
this._line ? this._context.lineTo(x[0], y[0]) : this._context.moveTo(x[0], y[0]);
|
|
2140
|
+
if (n === 2) this._context.lineTo(x[1], y[1]);
|
|
2141
|
+
else {
|
|
2142
|
+
var px = controlPoints(x), py = controlPoints(y);
|
|
2143
|
+
for (var i0 = 0, i1 = 1; i1 < n; ++i0, ++i1) this._context.bezierCurveTo(px[0][i0], py[0][i0], px[1][i0], py[1][i0], x[i1], y[i1]);
|
|
2144
|
+
}
|
|
2145
|
+
}
|
|
2146
|
+
if (this._line || this._line !== 0 && n === 1) this._context.closePath();
|
|
2147
|
+
this._line = 1 - this._line;
|
|
2148
|
+
this._x = this._y = null;
|
|
2149
|
+
},
|
|
2150
|
+
point: function(x, y) {
|
|
2151
|
+
this._x.push(+x);
|
|
2152
|
+
this._y.push(+y);
|
|
2153
|
+
}
|
|
2154
|
+
};
|
|
2155
|
+
function controlPoints(x) {
|
|
2156
|
+
var i, n = x.length - 1, m, a = new Array(n), b = new Array(n), r = new Array(n);
|
|
2157
|
+
a[0] = 0, b[0] = 2, r[0] = x[0] + 2 * x[1];
|
|
2158
|
+
for (i = 1; i < n - 1; ++i) a[i] = 1, b[i] = 4, r[i] = 4 * x[i] + 2 * x[i + 1];
|
|
2159
|
+
a[n - 1] = 2, b[n - 1] = 7, r[n - 1] = 8 * x[n - 1] + x[n];
|
|
2160
|
+
for (i = 1; i < n; ++i) m = a[i] / b[i - 1], b[i] -= m, r[i] -= m * r[i - 1];
|
|
2161
|
+
a[n - 1] = r[n - 1] / b[n - 1];
|
|
2162
|
+
for (i = n - 2; i >= 0; --i) a[i] = (r[i] - a[i + 1]) / b[i];
|
|
2163
|
+
b[n - 1] = (x[n] + a[n - 1]) / 2;
|
|
2164
|
+
for (i = 0; i < n - 1; ++i) b[i] = 2 * x[i + 1] - a[i + 1];
|
|
2165
|
+
return [a, b];
|
|
2166
|
+
}
|
|
2167
|
+
function natural(context) {
|
|
2168
|
+
return new Natural(context);
|
|
2169
|
+
}
|
|
2170
|
+
function Step(context, t) {
|
|
2171
|
+
this._context = context;
|
|
2172
|
+
this._t = t;
|
|
2173
|
+
}
|
|
2174
|
+
Step.prototype = {
|
|
2175
|
+
areaStart: function() {
|
|
2176
|
+
this._line = 0;
|
|
2177
|
+
},
|
|
2178
|
+
areaEnd: function() {
|
|
2179
|
+
this._line = NaN;
|
|
2180
|
+
},
|
|
2181
|
+
lineStart: function() {
|
|
2182
|
+
this._x = this._y = NaN;
|
|
2183
|
+
this._point = 0;
|
|
2184
|
+
},
|
|
2185
|
+
lineEnd: function() {
|
|
2186
|
+
if (0 < this._t && this._t < 1 && this._point === 2) this._context.lineTo(this._x, this._y);
|
|
2187
|
+
if (this._line || this._line !== 0 && this._point === 1) this._context.closePath();
|
|
2188
|
+
if (this._line >= 0) this._t = 1 - this._t, this._line = 1 - this._line;
|
|
2189
|
+
},
|
|
2190
|
+
point: function(x, y) {
|
|
2191
|
+
x = +x, y = +y;
|
|
2192
|
+
switch (this._point) {
|
|
2193
|
+
case 0:
|
|
2194
|
+
this._point = 1;
|
|
2195
|
+
this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y);
|
|
2196
|
+
break;
|
|
2197
|
+
case 1: this._point = 2;
|
|
2198
|
+
default: if (this._t <= 0) {
|
|
2199
|
+
this._context.lineTo(this._x, y);
|
|
2200
|
+
this._context.lineTo(x, y);
|
|
2201
|
+
} else {
|
|
2202
|
+
var x1 = this._x * (1 - this._t) + x * this._t;
|
|
2203
|
+
this._context.lineTo(x1, this._y);
|
|
2204
|
+
this._context.lineTo(x1, y);
|
|
2205
|
+
}
|
|
2206
|
+
}
|
|
2207
|
+
this._x = x, this._y = y;
|
|
2208
|
+
}
|
|
2209
|
+
};
|
|
2210
|
+
function step(context) {
|
|
2211
|
+
return new Step(context, .5);
|
|
2212
|
+
}
|
|
2213
|
+
function stepBefore(context) {
|
|
2214
|
+
return new Step(context, 0);
|
|
2215
|
+
}
|
|
2216
|
+
function stepAfter(context) {
|
|
2217
|
+
return new Step(context, 1);
|
|
2218
|
+
}
|
|
2219
|
+
function none(series, order) {
|
|
2220
|
+
if (!((n = series.length) > 1)) return;
|
|
2221
|
+
for (var i = 1, j, s0, s1 = series[order[0]], n, m = s1.length; i < n; ++i) {
|
|
2222
|
+
s0 = s1, s1 = series[order[i]];
|
|
2223
|
+
for (j = 0; j < m; ++j) s1[j][1] += s1[j][0] = isNaN(s0[j][1]) ? s0[j][0] : s0[j][1];
|
|
2224
|
+
}
|
|
2225
|
+
}
|
|
2226
|
+
function none$1(series) {
|
|
2227
|
+
var n = series.length, o = new Array(n);
|
|
2228
|
+
while (--n >= 0) o[n] = n;
|
|
2229
|
+
return o;
|
|
2230
|
+
}
|
|
2231
|
+
function stackValue(d, key) {
|
|
2232
|
+
return d[key];
|
|
2233
|
+
}
|
|
2234
|
+
function stack() {
|
|
2235
|
+
var keys = constant([]), order = none$1, offset = none, value = stackValue;
|
|
2236
|
+
function stack(data) {
|
|
2237
|
+
var kz = keys.apply(this, arguments), i, m = data.length, n = kz.length, sz = new Array(n), oz;
|
|
2238
|
+
for (i = 0; i < n; ++i) {
|
|
2239
|
+
for (var ki = kz[i], si = sz[i] = new Array(m), j = 0, sij; j < m; ++j) {
|
|
2240
|
+
si[j] = sij = [0, +value(data[j], ki, j, data)];
|
|
2241
|
+
sij.data = data[j];
|
|
2242
|
+
}
|
|
2243
|
+
si.key = ki;
|
|
2244
|
+
}
|
|
2245
|
+
for (i = 0, oz = order(sz); i < n; ++i) sz[oz[i]].index = i;
|
|
2246
|
+
offset(sz, oz);
|
|
2247
|
+
return sz;
|
|
2248
|
+
}
|
|
2249
|
+
stack.keys = function(_) {
|
|
2250
|
+
return arguments.length ? (keys = typeof _ === "function" ? _ : constant(slice.call(_)), stack) : keys;
|
|
2251
|
+
};
|
|
2252
|
+
stack.value = function(_) {
|
|
2253
|
+
return arguments.length ? (value = typeof _ === "function" ? _ : constant(+_), stack) : value;
|
|
2254
|
+
};
|
|
2255
|
+
stack.order = function(_) {
|
|
2256
|
+
return arguments.length ? (order = _ == null ? none$1 : typeof _ === "function" ? _ : constant(slice.call(_)), stack) : order;
|
|
2257
|
+
};
|
|
2258
|
+
stack.offset = function(_) {
|
|
2259
|
+
return arguments.length ? (offset = _ == null ? none : _, stack) : offset;
|
|
2260
|
+
};
|
|
2261
|
+
return stack;
|
|
2262
|
+
}
|
|
2263
|
+
function expand(series, order) {
|
|
2264
|
+
if (!((n = series.length) > 0)) return;
|
|
2265
|
+
for (var i, n, j = 0, m = series[0].length, y; j < m; ++j) {
|
|
2266
|
+
for (y = i = 0; i < n; ++i) y += series[i][j][1] || 0;
|
|
2267
|
+
if (y) for (i = 0; i < n; ++i) series[i][j][1] /= y;
|
|
2268
|
+
}
|
|
2269
|
+
none(series, order);
|
|
2270
|
+
}
|
|
2271
|
+
function diverging(series, order) {
|
|
2272
|
+
if (!((n = series.length) > 0)) return;
|
|
2273
|
+
for (var i, j = 0, d, dy, yp, yn, n, m = series[order[0]].length; j < m; ++j) for (yp = yn = 0, i = 0; i < n; ++i) if ((dy = (d = series[order[i]][j])[1] - d[0]) > 0) d[0] = yp, d[1] = yp += dy;
|
|
2274
|
+
else if (dy < 0) d[1] = yn, d[0] = yn += dy;
|
|
2275
|
+
else d[0] = 0, d[1] = dy;
|
|
2276
|
+
}
|
|
2277
|
+
function silhouette(series, order) {
|
|
2278
|
+
if (!((n = series.length) > 0)) return;
|
|
2279
|
+
for (var j = 0, s0 = series[order[0]], n, m = s0.length; j < m; ++j) {
|
|
2280
|
+
for (var i = 0, y = 0; i < n; ++i) y += series[i][j][1] || 0;
|
|
2281
|
+
s0[j][1] += s0[j][0] = -y / 2;
|
|
2282
|
+
}
|
|
2283
|
+
none(series, order);
|
|
2284
|
+
}
|
|
2285
|
+
function wiggle(series, order) {
|
|
2286
|
+
if (!((n = series.length) > 0) || !((m = (s0 = series[order[0]]).length) > 0)) return;
|
|
2287
|
+
for (var y = 0, j = 1, s0, m, n; j < m; ++j) {
|
|
2288
|
+
for (var i = 0, s1 = 0, s2 = 0; i < n; ++i) {
|
|
2289
|
+
var si = series[order[i]], sij0 = si[j][1] || 0, s3 = (sij0 - (si[j - 1][1] || 0)) / 2;
|
|
2290
|
+
for (var k = 0; k < i; ++k) {
|
|
2291
|
+
var sk = series[order[k]], skj0 = sk[j][1] || 0, skj1 = sk[j - 1][1] || 0;
|
|
2292
|
+
s3 += skj0 - skj1;
|
|
2293
|
+
}
|
|
2294
|
+
s1 += sij0, s2 += s3 * sij0;
|
|
2295
|
+
}
|
|
2296
|
+
s0[j - 1][1] += s0[j - 1][0] = y;
|
|
2297
|
+
if (s1) y -= s2 / s1;
|
|
2298
|
+
}
|
|
2299
|
+
s0[j - 1][1] += s0[j - 1][0] = y;
|
|
2300
|
+
none(series, order);
|
|
2301
|
+
}
|
|
2302
|
+
function appearance(series) {
|
|
2303
|
+
var peaks = series.map(peak);
|
|
2304
|
+
return none$1(series).sort(function(a, b) {
|
|
2305
|
+
return peaks[a] - peaks[b];
|
|
2306
|
+
});
|
|
2307
|
+
}
|
|
2308
|
+
function peak(series) {
|
|
2309
|
+
var i = -1, j = 0, n = series.length, vi, vj = -Infinity;
|
|
2310
|
+
while (++i < n) if ((vi = +series[i][1]) > vj) vj = vi, j = i;
|
|
2311
|
+
return j;
|
|
2312
|
+
}
|
|
2313
|
+
function ascending(series) {
|
|
2314
|
+
var sums = series.map(sum);
|
|
2315
|
+
return none$1(series).sort(function(a, b) {
|
|
2316
|
+
return sums[a] - sums[b];
|
|
2317
|
+
});
|
|
2318
|
+
}
|
|
2319
|
+
function sum(series) {
|
|
2320
|
+
var s = 0, i = -1, n = series.length, v;
|
|
2321
|
+
while (++i < n) if (v = +series[i][1]) s += v;
|
|
2322
|
+
return s;
|
|
2323
|
+
}
|
|
2324
|
+
function descending$1(series) {
|
|
2325
|
+
return ascending(series).reverse();
|
|
2326
|
+
}
|
|
2327
|
+
function insideOut(series) {
|
|
2328
|
+
var n = series.length, i, j, sums = series.map(sum), order = appearance(series), top = 0, bottom = 0, tops = [], bottoms = [];
|
|
2329
|
+
for (i = 0; i < n; ++i) {
|
|
2330
|
+
j = order[i];
|
|
2331
|
+
if (top < bottom) {
|
|
2332
|
+
top += sums[j];
|
|
2333
|
+
tops.push(j);
|
|
2334
|
+
} else {
|
|
2335
|
+
bottom += sums[j];
|
|
2336
|
+
bottoms.push(j);
|
|
2337
|
+
}
|
|
2338
|
+
}
|
|
2339
|
+
return bottoms.reverse().concat(tops);
|
|
2340
|
+
}
|
|
2341
|
+
function reverse(series) {
|
|
2342
|
+
return none$1(series).reverse();
|
|
2343
|
+
}
|
|
2344
|
+
exports$2.arc = arc;
|
|
2345
|
+
exports$2.area = area;
|
|
2346
|
+
exports$2.areaRadial = areaRadial;
|
|
2347
|
+
exports$2.curveBasis = basis;
|
|
2348
|
+
exports$2.curveBasisClosed = basisClosed;
|
|
2349
|
+
exports$2.curveBasisOpen = basisOpen;
|
|
2350
|
+
exports$2.curveBundle = bundle;
|
|
2351
|
+
exports$2.curveCardinal = cardinal;
|
|
2352
|
+
exports$2.curveCardinalClosed = cardinalClosed;
|
|
2353
|
+
exports$2.curveCardinalOpen = cardinalOpen;
|
|
2354
|
+
exports$2.curveCatmullRom = catmullRom;
|
|
2355
|
+
exports$2.curveCatmullRomClosed = catmullRomClosed;
|
|
2356
|
+
exports$2.curveCatmullRomOpen = catmullRomOpen;
|
|
2357
|
+
exports$2.curveLinear = curveLinear;
|
|
2358
|
+
exports$2.curveLinearClosed = linearClosed;
|
|
2359
|
+
exports$2.curveMonotoneX = monotoneX;
|
|
2360
|
+
exports$2.curveMonotoneY = monotoneY;
|
|
2361
|
+
exports$2.curveNatural = natural;
|
|
2362
|
+
exports$2.curveStep = step;
|
|
2363
|
+
exports$2.curveStepAfter = stepAfter;
|
|
2364
|
+
exports$2.curveStepBefore = stepBefore;
|
|
2365
|
+
exports$2.line = line;
|
|
2366
|
+
exports$2.lineRadial = lineRadial$1;
|
|
2367
|
+
exports$2.linkHorizontal = linkHorizontal;
|
|
2368
|
+
exports$2.linkRadial = linkRadial;
|
|
2369
|
+
exports$2.linkVertical = linkVertical;
|
|
2370
|
+
exports$2.pie = pie;
|
|
2371
|
+
exports$2.pointRadial = pointRadial;
|
|
2372
|
+
exports$2.radialArea = areaRadial;
|
|
2373
|
+
exports$2.radialLine = lineRadial$1;
|
|
2374
|
+
exports$2.stack = stack;
|
|
2375
|
+
exports$2.stackOffsetDiverging = diverging;
|
|
2376
|
+
exports$2.stackOffsetExpand = expand;
|
|
2377
|
+
exports$2.stackOffsetNone = none;
|
|
2378
|
+
exports$2.stackOffsetSilhouette = silhouette;
|
|
2379
|
+
exports$2.stackOffsetWiggle = wiggle;
|
|
2380
|
+
exports$2.stackOrderAppearance = appearance;
|
|
2381
|
+
exports$2.stackOrderAscending = ascending;
|
|
2382
|
+
exports$2.stackOrderDescending = descending$1;
|
|
2383
|
+
exports$2.stackOrderInsideOut = insideOut;
|
|
2384
|
+
exports$2.stackOrderNone = none$1;
|
|
2385
|
+
exports$2.stackOrderReverse = reverse;
|
|
2386
|
+
exports$2.symbol = symbol;
|
|
2387
|
+
exports$2.symbolCircle = circle;
|
|
2388
|
+
exports$2.symbolCross = cross;
|
|
2389
|
+
exports$2.symbolDiamond = diamond;
|
|
2390
|
+
exports$2.symbolSquare = square;
|
|
2391
|
+
exports$2.symbolStar = star;
|
|
2392
|
+
exports$2.symbolTriangle = triangle;
|
|
2393
|
+
exports$2.symbolWye = wye;
|
|
2394
|
+
exports$2.symbols = symbols;
|
|
2395
|
+
Object.defineProperty(exports$2, "__esModule", { value: true });
|
|
2396
|
+
});
|
|
2397
|
+
}));
|
|
2398
|
+
//#endregion
|
|
2399
|
+
//#region ../../node_modules/.pnpm/comark-charts@0.12.0_@comark+html@0.9.0_katex@0.19.1_shiki@4.5.0__comark@0.9.0_katex@0._2a141170ea995698c38300c814d9132b/node_modules/comark-charts/dist/sankey-CAYwt82B.mjs
|
|
2400
|
+
var import_d3_sankey = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2401
|
+
(function(global, factory) {
|
|
2402
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require_d3_array(), require_d3_shape()) : typeof define === "function" && define.amd ? define([
|
|
2403
|
+
"exports",
|
|
2404
|
+
"d3-array",
|
|
2405
|
+
"d3-shape"
|
|
2406
|
+
], factory) : (global = global || self, factory(global.d3 = global.d3 || {}, global.d3, global.d3));
|
|
2407
|
+
})(exports, function(exports$1, d3Array, d3Shape) {
|
|
2408
|
+
"use strict";
|
|
2409
|
+
function targetDepth(d) {
|
|
2410
|
+
return d.target.depth;
|
|
2411
|
+
}
|
|
2412
|
+
function left(node) {
|
|
2413
|
+
return node.depth;
|
|
2414
|
+
}
|
|
2415
|
+
function right(node, n) {
|
|
2416
|
+
return n - 1 - node.height;
|
|
2417
|
+
}
|
|
2418
|
+
function justify(node, n) {
|
|
2419
|
+
return node.sourceLinks.length ? node.depth : n - 1;
|
|
2420
|
+
}
|
|
2421
|
+
function center(node) {
|
|
2422
|
+
return node.targetLinks.length ? node.depth : node.sourceLinks.length ? d3Array.min(node.sourceLinks, targetDepth) - 1 : 0;
|
|
2423
|
+
}
|
|
2424
|
+
function constant(x) {
|
|
2425
|
+
return function() {
|
|
2426
|
+
return x;
|
|
2427
|
+
};
|
|
2428
|
+
}
|
|
2429
|
+
function ascendingSourceBreadth(a, b) {
|
|
2430
|
+
return ascendingBreadth(a.source, b.source) || a.index - b.index;
|
|
2431
|
+
}
|
|
2432
|
+
function ascendingTargetBreadth(a, b) {
|
|
2433
|
+
return ascendingBreadth(a.target, b.target) || a.index - b.index;
|
|
2434
|
+
}
|
|
2435
|
+
function ascendingBreadth(a, b) {
|
|
2436
|
+
return a.y0 - b.y0;
|
|
2437
|
+
}
|
|
2438
|
+
function value(d) {
|
|
2439
|
+
return d.value;
|
|
2440
|
+
}
|
|
2441
|
+
function defaultId(d) {
|
|
2442
|
+
return d.index;
|
|
2443
|
+
}
|
|
2444
|
+
function defaultNodes(graph) {
|
|
2445
|
+
return graph.nodes;
|
|
2446
|
+
}
|
|
2447
|
+
function defaultLinks(graph) {
|
|
2448
|
+
return graph.links;
|
|
2449
|
+
}
|
|
2450
|
+
function find(nodeById, id) {
|
|
2451
|
+
const node = nodeById.get(id);
|
|
2452
|
+
if (!node) throw new Error("missing: " + id);
|
|
2453
|
+
return node;
|
|
2454
|
+
}
|
|
2455
|
+
function computeLinkBreadths({ nodes }) {
|
|
2456
|
+
for (const node of nodes) {
|
|
2457
|
+
let y0 = node.y0;
|
|
2458
|
+
let y1 = y0;
|
|
2459
|
+
for (const link of node.sourceLinks) {
|
|
2460
|
+
link.y0 = y0 + link.width / 2;
|
|
2461
|
+
y0 += link.width;
|
|
2462
|
+
}
|
|
2463
|
+
for (const link of node.targetLinks) {
|
|
2464
|
+
link.y1 = y1 + link.width / 2;
|
|
2465
|
+
y1 += link.width;
|
|
2466
|
+
}
|
|
2467
|
+
}
|
|
2468
|
+
}
|
|
2469
|
+
function Sankey() {
|
|
2470
|
+
let x0 = 0, y0 = 0, x1 = 1, y1 = 1;
|
|
2471
|
+
let dx = 24;
|
|
2472
|
+
let dy = 8, py;
|
|
2473
|
+
let id = defaultId;
|
|
2474
|
+
let align = justify;
|
|
2475
|
+
let sort;
|
|
2476
|
+
let linkSort;
|
|
2477
|
+
let nodes = defaultNodes;
|
|
2478
|
+
let links = defaultLinks;
|
|
2479
|
+
let iterations = 6;
|
|
2480
|
+
function sankey() {
|
|
2481
|
+
const graph = {
|
|
2482
|
+
nodes: nodes.apply(null, arguments),
|
|
2483
|
+
links: links.apply(null, arguments)
|
|
2484
|
+
};
|
|
2485
|
+
computeNodeLinks(graph);
|
|
2486
|
+
computeNodeValues(graph);
|
|
2487
|
+
computeNodeDepths(graph);
|
|
2488
|
+
computeNodeHeights(graph);
|
|
2489
|
+
computeNodeBreadths(graph);
|
|
2490
|
+
computeLinkBreadths(graph);
|
|
2491
|
+
return graph;
|
|
2492
|
+
}
|
|
2493
|
+
sankey.update = function(graph) {
|
|
2494
|
+
computeLinkBreadths(graph);
|
|
2495
|
+
return graph;
|
|
2496
|
+
};
|
|
2497
|
+
sankey.nodeId = function(_) {
|
|
2498
|
+
return arguments.length ? (id = typeof _ === "function" ? _ : constant(_), sankey) : id;
|
|
2499
|
+
};
|
|
2500
|
+
sankey.nodeAlign = function(_) {
|
|
2501
|
+
return arguments.length ? (align = typeof _ === "function" ? _ : constant(_), sankey) : align;
|
|
2502
|
+
};
|
|
2503
|
+
sankey.nodeSort = function(_) {
|
|
2504
|
+
return arguments.length ? (sort = _, sankey) : sort;
|
|
2505
|
+
};
|
|
2506
|
+
sankey.nodeWidth = function(_) {
|
|
2507
|
+
return arguments.length ? (dx = +_, sankey) : dx;
|
|
2508
|
+
};
|
|
2509
|
+
sankey.nodePadding = function(_) {
|
|
2510
|
+
return arguments.length ? (dy = py = +_, sankey) : dy;
|
|
2511
|
+
};
|
|
2512
|
+
sankey.nodes = function(_) {
|
|
2513
|
+
return arguments.length ? (nodes = typeof _ === "function" ? _ : constant(_), sankey) : nodes;
|
|
2514
|
+
};
|
|
2515
|
+
sankey.links = function(_) {
|
|
2516
|
+
return arguments.length ? (links = typeof _ === "function" ? _ : constant(_), sankey) : links;
|
|
2517
|
+
};
|
|
2518
|
+
sankey.linkSort = function(_) {
|
|
2519
|
+
return arguments.length ? (linkSort = _, sankey) : linkSort;
|
|
2520
|
+
};
|
|
2521
|
+
sankey.size = function(_) {
|
|
2522
|
+
return arguments.length ? (x0 = y0 = 0, x1 = +_[0], y1 = +_[1], sankey) : [x1 - x0, y1 - y0];
|
|
2523
|
+
};
|
|
2524
|
+
sankey.extent = function(_) {
|
|
2525
|
+
return arguments.length ? (x0 = +_[0][0], x1 = +_[1][0], y0 = +_[0][1], y1 = +_[1][1], sankey) : [[x0, y0], [x1, y1]];
|
|
2526
|
+
};
|
|
2527
|
+
sankey.iterations = function(_) {
|
|
2528
|
+
return arguments.length ? (iterations = +_, sankey) : iterations;
|
|
2529
|
+
};
|
|
2530
|
+
function computeNodeLinks({ nodes, links }) {
|
|
2531
|
+
for (const [i, node] of nodes.entries()) {
|
|
2532
|
+
node.index = i;
|
|
2533
|
+
node.sourceLinks = [];
|
|
2534
|
+
node.targetLinks = [];
|
|
2535
|
+
}
|
|
2536
|
+
const nodeById = new Map(nodes.map((d, i) => [id(d, i, nodes), d]));
|
|
2537
|
+
for (const [i, link] of links.entries()) {
|
|
2538
|
+
link.index = i;
|
|
2539
|
+
let { source, target } = link;
|
|
2540
|
+
if (typeof source !== "object") source = link.source = find(nodeById, source);
|
|
2541
|
+
if (typeof target !== "object") target = link.target = find(nodeById, target);
|
|
2542
|
+
source.sourceLinks.push(link);
|
|
2543
|
+
target.targetLinks.push(link);
|
|
2544
|
+
}
|
|
2545
|
+
if (linkSort != null) for (const { sourceLinks, targetLinks } of nodes) {
|
|
2546
|
+
sourceLinks.sort(linkSort);
|
|
2547
|
+
targetLinks.sort(linkSort);
|
|
2548
|
+
}
|
|
2549
|
+
}
|
|
2550
|
+
function computeNodeValues({ nodes }) {
|
|
2551
|
+
for (const node of nodes) node.value = node.fixedValue === void 0 ? Math.max(d3Array.sum(node.sourceLinks, value), d3Array.sum(node.targetLinks, value)) : node.fixedValue;
|
|
2552
|
+
}
|
|
2553
|
+
function computeNodeDepths({ nodes }) {
|
|
2554
|
+
const n = nodes.length;
|
|
2555
|
+
let current = new Set(nodes);
|
|
2556
|
+
let next = /* @__PURE__ */ new Set();
|
|
2557
|
+
let x = 0;
|
|
2558
|
+
while (current.size) {
|
|
2559
|
+
for (const node of current) {
|
|
2560
|
+
node.depth = x;
|
|
2561
|
+
for (const { target } of node.sourceLinks) next.add(target);
|
|
2562
|
+
}
|
|
2563
|
+
if (++x > n) throw new Error("circular link");
|
|
2564
|
+
current = next;
|
|
2565
|
+
next = /* @__PURE__ */ new Set();
|
|
2566
|
+
}
|
|
2567
|
+
}
|
|
2568
|
+
function computeNodeHeights({ nodes }) {
|
|
2569
|
+
const n = nodes.length;
|
|
2570
|
+
let current = new Set(nodes);
|
|
2571
|
+
let next = /* @__PURE__ */ new Set();
|
|
2572
|
+
let x = 0;
|
|
2573
|
+
while (current.size) {
|
|
2574
|
+
for (const node of current) {
|
|
2575
|
+
node.height = x;
|
|
2576
|
+
for (const { source } of node.targetLinks) next.add(source);
|
|
2577
|
+
}
|
|
2578
|
+
if (++x > n) throw new Error("circular link");
|
|
2579
|
+
current = next;
|
|
2580
|
+
next = /* @__PURE__ */ new Set();
|
|
2581
|
+
}
|
|
2582
|
+
}
|
|
2583
|
+
function computeNodeLayers({ nodes }) {
|
|
2584
|
+
const x = d3Array.max(nodes, (d) => d.depth) + 1;
|
|
2585
|
+
const kx = (x1 - x0 - dx) / (x - 1);
|
|
2586
|
+
const columns = new Array(x);
|
|
2587
|
+
for (const node of nodes) {
|
|
2588
|
+
const i = Math.max(0, Math.min(x - 1, Math.floor(align.call(null, node, x))));
|
|
2589
|
+
node.layer = i;
|
|
2590
|
+
node.x0 = x0 + i * kx;
|
|
2591
|
+
node.x1 = node.x0 + dx;
|
|
2592
|
+
if (columns[i]) columns[i].push(node);
|
|
2593
|
+
else columns[i] = [node];
|
|
2594
|
+
}
|
|
2595
|
+
if (sort) for (const column of columns) column.sort(sort);
|
|
2596
|
+
return columns;
|
|
2597
|
+
}
|
|
2598
|
+
function initializeNodeBreadths(columns) {
|
|
2599
|
+
const ky = d3Array.min(columns, (c) => (y1 - y0 - (c.length - 1) * py) / d3Array.sum(c, value));
|
|
2600
|
+
for (const nodes of columns) {
|
|
2601
|
+
let y = y0;
|
|
2602
|
+
for (const node of nodes) {
|
|
2603
|
+
node.y0 = y;
|
|
2604
|
+
node.y1 = y + node.value * ky;
|
|
2605
|
+
y = node.y1 + py;
|
|
2606
|
+
for (const link of node.sourceLinks) link.width = link.value * ky;
|
|
2607
|
+
}
|
|
2608
|
+
y = (y1 - y + py) / (nodes.length + 1);
|
|
2609
|
+
for (let i = 0; i < nodes.length; ++i) {
|
|
2610
|
+
const node = nodes[i];
|
|
2611
|
+
node.y0 += y * (i + 1);
|
|
2612
|
+
node.y1 += y * (i + 1);
|
|
2613
|
+
}
|
|
2614
|
+
reorderLinks(nodes);
|
|
2615
|
+
}
|
|
2616
|
+
}
|
|
2617
|
+
function computeNodeBreadths(graph) {
|
|
2618
|
+
const columns = computeNodeLayers(graph);
|
|
2619
|
+
py = Math.min(dy, (y1 - y0) / (d3Array.max(columns, (c) => c.length) - 1));
|
|
2620
|
+
initializeNodeBreadths(columns);
|
|
2621
|
+
for (let i = 0; i < iterations; ++i) {
|
|
2622
|
+
const alpha = Math.pow(.99, i);
|
|
2623
|
+
const beta = Math.max(1 - alpha, (i + 1) / iterations);
|
|
2624
|
+
relaxRightToLeft(columns, alpha, beta);
|
|
2625
|
+
relaxLeftToRight(columns, alpha, beta);
|
|
2626
|
+
}
|
|
2627
|
+
}
|
|
2628
|
+
function relaxLeftToRight(columns, alpha, beta) {
|
|
2629
|
+
for (let i = 1, n = columns.length; i < n; ++i) {
|
|
2630
|
+
const column = columns[i];
|
|
2631
|
+
for (const target of column) {
|
|
2632
|
+
let y = 0;
|
|
2633
|
+
let w = 0;
|
|
2634
|
+
for (const { source, value } of target.targetLinks) {
|
|
2635
|
+
let v = value * (target.layer - source.layer);
|
|
2636
|
+
y += targetTop(source, target) * v;
|
|
2637
|
+
w += v;
|
|
2638
|
+
}
|
|
2639
|
+
if (!(w > 0)) continue;
|
|
2640
|
+
let dy = (y / w - target.y0) * alpha;
|
|
2641
|
+
target.y0 += dy;
|
|
2642
|
+
target.y1 += dy;
|
|
2643
|
+
reorderNodeLinks(target);
|
|
2644
|
+
}
|
|
2645
|
+
if (sort === void 0) column.sort(ascendingBreadth);
|
|
2646
|
+
resolveCollisions(column, beta);
|
|
2647
|
+
}
|
|
2648
|
+
}
|
|
2649
|
+
function relaxRightToLeft(columns, alpha, beta) {
|
|
2650
|
+
for (let i = columns.length - 2; i >= 0; --i) {
|
|
2651
|
+
const column = columns[i];
|
|
2652
|
+
for (const source of column) {
|
|
2653
|
+
let y = 0;
|
|
2654
|
+
let w = 0;
|
|
2655
|
+
for (const { target, value } of source.sourceLinks) {
|
|
2656
|
+
let v = value * (target.layer - source.layer);
|
|
2657
|
+
y += sourceTop(source, target) * v;
|
|
2658
|
+
w += v;
|
|
2659
|
+
}
|
|
2660
|
+
if (!(w > 0)) continue;
|
|
2661
|
+
let dy = (y / w - source.y0) * alpha;
|
|
2662
|
+
source.y0 += dy;
|
|
2663
|
+
source.y1 += dy;
|
|
2664
|
+
reorderNodeLinks(source);
|
|
2665
|
+
}
|
|
2666
|
+
if (sort === void 0) column.sort(ascendingBreadth);
|
|
2667
|
+
resolveCollisions(column, beta);
|
|
2668
|
+
}
|
|
2669
|
+
}
|
|
2670
|
+
function resolveCollisions(nodes, alpha) {
|
|
2671
|
+
const i = nodes.length >> 1;
|
|
2672
|
+
const subject = nodes[i];
|
|
2673
|
+
resolveCollisionsBottomToTop(nodes, subject.y0 - py, i - 1, alpha);
|
|
2674
|
+
resolveCollisionsTopToBottom(nodes, subject.y1 + py, i + 1, alpha);
|
|
2675
|
+
resolveCollisionsBottomToTop(nodes, y1, nodes.length - 1, alpha);
|
|
2676
|
+
resolveCollisionsTopToBottom(nodes, y0, 0, alpha);
|
|
2677
|
+
}
|
|
2678
|
+
function resolveCollisionsTopToBottom(nodes, y, i, alpha) {
|
|
2679
|
+
for (; i < nodes.length; ++i) {
|
|
2680
|
+
const node = nodes[i];
|
|
2681
|
+
const dy = (y - node.y0) * alpha;
|
|
2682
|
+
if (dy > 1e-6) node.y0 += dy, node.y1 += dy;
|
|
2683
|
+
y = node.y1 + py;
|
|
2684
|
+
}
|
|
2685
|
+
}
|
|
2686
|
+
function resolveCollisionsBottomToTop(nodes, y, i, alpha) {
|
|
2687
|
+
for (; i >= 0; --i) {
|
|
2688
|
+
const node = nodes[i];
|
|
2689
|
+
const dy = (node.y1 - y) * alpha;
|
|
2690
|
+
if (dy > 1e-6) node.y0 -= dy, node.y1 -= dy;
|
|
2691
|
+
y = node.y0 - py;
|
|
2692
|
+
}
|
|
2693
|
+
}
|
|
2694
|
+
function reorderNodeLinks({ sourceLinks, targetLinks }) {
|
|
2695
|
+
if (linkSort === void 0) {
|
|
2696
|
+
for (const { source: { sourceLinks } } of targetLinks) sourceLinks.sort(ascendingTargetBreadth);
|
|
2697
|
+
for (const { target: { targetLinks } } of sourceLinks) targetLinks.sort(ascendingSourceBreadth);
|
|
2698
|
+
}
|
|
2699
|
+
}
|
|
2700
|
+
function reorderLinks(nodes) {
|
|
2701
|
+
if (linkSort === void 0) for (const { sourceLinks, targetLinks } of nodes) {
|
|
2702
|
+
sourceLinks.sort(ascendingTargetBreadth);
|
|
2703
|
+
targetLinks.sort(ascendingSourceBreadth);
|
|
2704
|
+
}
|
|
2705
|
+
}
|
|
2706
|
+
function targetTop(source, target) {
|
|
2707
|
+
let y = source.y0 - (source.sourceLinks.length - 1) * py / 2;
|
|
2708
|
+
for (const { target: node, width } of source.sourceLinks) {
|
|
2709
|
+
if (node === target) break;
|
|
2710
|
+
y += width + py;
|
|
2711
|
+
}
|
|
2712
|
+
for (const { source: node, width } of target.targetLinks) {
|
|
2713
|
+
if (node === source) break;
|
|
2714
|
+
y -= width;
|
|
2715
|
+
}
|
|
2716
|
+
return y;
|
|
2717
|
+
}
|
|
2718
|
+
function sourceTop(source, target) {
|
|
2719
|
+
let y = target.y0 - (target.targetLinks.length - 1) * py / 2;
|
|
2720
|
+
for (const { source: node, width } of target.targetLinks) {
|
|
2721
|
+
if (node === source) break;
|
|
2722
|
+
y += width + py;
|
|
2723
|
+
}
|
|
2724
|
+
for (const { target: node, width } of source.sourceLinks) {
|
|
2725
|
+
if (node === target) break;
|
|
2726
|
+
y -= width;
|
|
2727
|
+
}
|
|
2728
|
+
return y;
|
|
2729
|
+
}
|
|
2730
|
+
return sankey;
|
|
2731
|
+
}
|
|
2732
|
+
function horizontalSource(d) {
|
|
2733
|
+
return [d.source.x1, d.y0];
|
|
2734
|
+
}
|
|
2735
|
+
function horizontalTarget(d) {
|
|
2736
|
+
return [d.target.x0, d.y1];
|
|
2737
|
+
}
|
|
2738
|
+
function sankeyLinkHorizontal() {
|
|
2739
|
+
return d3Shape.linkHorizontal().source(horizontalSource).target(horizontalTarget);
|
|
2740
|
+
}
|
|
2741
|
+
exports$1.sankey = Sankey;
|
|
2742
|
+
exports$1.sankeyCenter = center;
|
|
2743
|
+
exports$1.sankeyJustify = justify;
|
|
2744
|
+
exports$1.sankeyLeft = left;
|
|
2745
|
+
exports$1.sankeyLinkHorizontal = sankeyLinkHorizontal;
|
|
2746
|
+
exports$1.sankeyRight = right;
|
|
2747
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
2748
|
+
});
|
|
2749
|
+
})))();
|
|
2750
|
+
const WIDTH = 576;
|
|
2751
|
+
const NODE = 12;
|
|
2752
|
+
const LINE = 20;
|
|
2753
|
+
/**
|
|
2754
|
+
* Draws a sankey: d3-sankey places the nodes in columns, in table order, with every sink in the last column, and Vega
|
|
2755
|
+
* draws them in the house type and colors, so it reads like the other charts and its marks are found the same way.
|
|
2756
|
+
*/
|
|
2757
|
+
async function drawSankey(chart) {
|
|
2758
|
+
const gap = (chart.labels ? 2 : 1) * LINE + 8;
|
|
2759
|
+
const layout = (0, import_d3_sankey.sankey)().nodeId((node) => node.row).nodeAlign(import_d3_sankey.sankeyJustify).nodeSort(null).nodeWidth(NODE).nodePadding(gap);
|
|
2760
|
+
const graph = () => ({
|
|
2761
|
+
nodes: chart.nodes.map((name, row) => ({
|
|
2762
|
+
name,
|
|
2763
|
+
row
|
|
2764
|
+
})),
|
|
2765
|
+
links: chart.flows.map((flow) => ({
|
|
2766
|
+
source: flow.from,
|
|
2767
|
+
target: flow.to,
|
|
2768
|
+
value: flow.value
|
|
2769
|
+
}))
|
|
2770
|
+
});
|
|
2771
|
+
const columns = /* @__PURE__ */ new Map();
|
|
2772
|
+
for (const node of layout(graph()).nodes) columns.set(node.depth, (columns.get(node.depth) ?? 0) + 1);
|
|
2773
|
+
const height = Math.max(240, Math.max(...columns.values()) * (gap + 16));
|
|
2774
|
+
const block = (chart.labels ? 2 : 1) * LINE;
|
|
2775
|
+
const { nodes, links } = layout.extent([[0, block / 2], [WIDTH, height - block / 2]])(graph());
|
|
2776
|
+
const color = (row) => SERIES[row % SERIES.length];
|
|
2777
|
+
const last = Math.max(...nodes.map((node) => node.x1));
|
|
2778
|
+
const rowOf = (end) => nodes.find((node) => node === end)?.row ?? -1;
|
|
2779
|
+
const sink = (row) => !links.some((link) => rowOf(link.source) === row);
|
|
2780
|
+
const path = (0, import_d3_sankey.sankeyLinkHorizontal)();
|
|
2781
|
+
const lefts = [...new Set(nodes.map((node) => node.x0))].sort((a, b) => a - b);
|
|
2782
|
+
const room = (left, end) => {
|
|
2783
|
+
const column = lefts.indexOf(left);
|
|
2784
|
+
const [from, to] = end ? [lefts[column - 1], left] : [left, lefts[column + 1]];
|
|
2785
|
+
const gap = to - from - NODE;
|
|
2786
|
+
return (end || column + 2 === lefts.length ? gap / 2 : gap) - 9;
|
|
2787
|
+
};
|
|
2788
|
+
const nodeValues = nodes.map((node) => {
|
|
2789
|
+
const end = node.x1 >= last;
|
|
2790
|
+
return {
|
|
2791
|
+
row: node.row,
|
|
2792
|
+
name: node.name,
|
|
2793
|
+
value: format(node.value),
|
|
2794
|
+
x: node.x0,
|
|
2795
|
+
x2: node.x1,
|
|
2796
|
+
y: node.y0,
|
|
2797
|
+
y2: Math.max(node.y1, node.y0 + 1),
|
|
2798
|
+
fill: color(node.row),
|
|
2799
|
+
tx: end ? node.x0 - 6 : node.x1 + 6,
|
|
2800
|
+
ty: (node.y0 + node.y1) / 2,
|
|
2801
|
+
align: end ? "right" : "left",
|
|
2802
|
+
limit: lefts.length > 1 ? room(node.x0, end) : WIDTH
|
|
2803
|
+
};
|
|
2804
|
+
});
|
|
2805
|
+
const linkValues = links.map((link) => {
|
|
2806
|
+
const [source, target] = [rowOf(link.source), rowOf(link.target)];
|
|
2807
|
+
return {
|
|
2808
|
+
d: path(link) ?? "",
|
|
2809
|
+
width: Math.max(1, link.width),
|
|
2810
|
+
stroke: color(sink(target) ? target : source)
|
|
2811
|
+
};
|
|
2812
|
+
});
|
|
2813
|
+
const text = (field, dy, fill, weight) => ({
|
|
2814
|
+
type: "text",
|
|
2815
|
+
from: { data: "nodes" },
|
|
2816
|
+
aria: false,
|
|
2817
|
+
encode: { enter: {
|
|
2818
|
+
x: { field: "tx" },
|
|
2819
|
+
y: { field: "ty" },
|
|
2820
|
+
dy: { value: dy },
|
|
2821
|
+
text: { field },
|
|
2822
|
+
align: { field: "align" },
|
|
2823
|
+
baseline: { value: "middle" },
|
|
2824
|
+
limit: { field: "limit" },
|
|
2825
|
+
fill: { value: fill },
|
|
2826
|
+
font: { value: "sans-serif" },
|
|
2827
|
+
fontSize: { value: 12 },
|
|
2828
|
+
fontWeight: { value: weight }
|
|
2829
|
+
} }
|
|
2830
|
+
});
|
|
2831
|
+
const spec = {
|
|
2832
|
+
width: WIDTH,
|
|
2833
|
+
height,
|
|
2834
|
+
padding: chart.marks.some((mark) => mark.mark === "circle") ? {
|
|
2835
|
+
...PADDING,
|
|
2836
|
+
bottom: PADDING.bottom + 20
|
|
2837
|
+
} : PADDING,
|
|
2838
|
+
autosize: "none",
|
|
2839
|
+
background: "transparent",
|
|
2840
|
+
data: [{
|
|
2841
|
+
name: "nodes",
|
|
2842
|
+
values: nodeValues
|
|
2843
|
+
}, {
|
|
2844
|
+
name: "links",
|
|
2845
|
+
values: linkValues
|
|
2846
|
+
}],
|
|
2847
|
+
marks: [
|
|
2848
|
+
{
|
|
2849
|
+
type: "path",
|
|
2850
|
+
from: { data: "links" },
|
|
2851
|
+
aria: false,
|
|
2852
|
+
encode: { enter: {
|
|
2853
|
+
path: { field: "d" },
|
|
2854
|
+
stroke: { field: "stroke" },
|
|
2855
|
+
strokeWidth: { field: "width" },
|
|
2856
|
+
strokeOpacity: { value: .3 },
|
|
2857
|
+
fill: { value: "none" }
|
|
2858
|
+
} }
|
|
2859
|
+
},
|
|
2860
|
+
{
|
|
2861
|
+
type: "rect",
|
|
2862
|
+
from: { data: "nodes" },
|
|
2863
|
+
aria: false,
|
|
2864
|
+
encode: { enter: {
|
|
2865
|
+
x: { field: "x" },
|
|
2866
|
+
x2: { field: "x2" },
|
|
2867
|
+
y: { field: "y" },
|
|
2868
|
+
y2: { field: "y2" },
|
|
2869
|
+
fill: { field: "fill" },
|
|
2870
|
+
cornerRadius: { value: 2 }
|
|
2871
|
+
} }
|
|
2872
|
+
},
|
|
2873
|
+
text("name", chart.labels ? -10 : 0, INK.foreground, 500),
|
|
2874
|
+
...chart.labels ? [text("value", LINE / 2, INK.muted, 400)] : []
|
|
2875
|
+
]
|
|
2876
|
+
};
|
|
2877
|
+
const { view, svg } = await render(spec);
|
|
2878
|
+
const [, width = "0", tall = "0"] = /viewBox="0 0 ([\d.]+) ([\d.]+)"/.exec(svg) ?? [];
|
|
2879
|
+
const found = boxes(chart, view, Number(width), Number(tall));
|
|
2880
|
+
view.finalize();
|
|
2881
|
+
return {
|
|
2882
|
+
svg,
|
|
2883
|
+
boxes: found
|
|
2884
|
+
};
|
|
2885
|
+
}
|
|
2886
|
+
//#endregion
|
|
2887
|
+
export { drawSankey };
|