arethesis 0.1.5 → 0.2.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/CHANGELOG.md +66 -0
- package/README.md +5 -4
- package/dist/arethesis.js +2 -147
- package/dist/binding/data-binder.d.ts +8 -0
- package/dist/binding/data-binder.d.ts.map +1 -1
- package/dist/binding/data-binder.js +605 -0
- package/dist/binding/data-binder.js.map +1 -0
- package/dist/binding/types.d.ts +20 -0
- package/dist/binding/types.d.ts.map +1 -1
- package/dist/binding/validation-engine.js +160 -0
- package/dist/binding/validation-engine.js.map +1 -0
- package/dist/cdn/arethesis.min.js +2 -0
- package/dist/cdn/arethesis.min.js.map +1 -0
- package/dist/cdn/chunks/CdTL-MEv.min.js +3 -0
- package/dist/cdn/chunks/CdTL-MEv.min.js.map +1 -0
- package/dist/cdn/components.min.js +81 -0
- package/dist/cdn/components.min.js.map +1 -0
- package/dist/collab/index.d.ts +22 -0
- package/dist/collab/index.d.ts.map +1 -0
- package/dist/collab/index.js +23 -0
- package/dist/collab/index.js.map +1 -0
- package/dist/components/component.d.ts +17 -0
- package/dist/components/component.d.ts.map +1 -1
- package/dist/components/component.js +765 -0
- package/dist/components/component.js.map +1 -0
- package/dist/components/decorators.js +27 -0
- package/dist/components/decorators.js.map +1 -0
- package/dist/components/form-associated.d.ts +55 -0
- package/dist/components/form-associated.d.ts.map +1 -0
- package/dist/components/form-associated.js +180 -0
- package/dist/components/form-associated.js.map +1 -0
- package/dist/components/runtime.d.ts +2 -0
- package/dist/components/runtime.d.ts.map +1 -1
- package/dist/components/runtime.js +18 -0
- package/dist/components/runtime.js.map +1 -0
- package/dist/components/template-loader.js +90 -0
- package/dist/components/template-loader.js.map +1 -0
- package/dist/components.js +2 -606
- package/dist/core/arethesis.d.ts +13 -9
- package/dist/core/arethesis.d.ts.map +1 -1
- package/dist/core/arethesis.js +249 -0
- package/dist/core/arethesis.js.map +1 -0
- package/dist/core/hooks.d.ts +19 -0
- package/dist/core/hooks.d.ts.map +1 -0
- package/dist/core/hooks.js +23 -0
- package/dist/core/hooks.js.map +1 -0
- package/dist/core/index.d.ts +57 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +25 -0
- package/dist/data/list-view-registry.js +300 -0
- package/dist/data/list-view-registry.js.map +1 -0
- package/dist/data/object-store.js +280 -0
- package/dist/data/object-store.js.map +1 -0
- package/dist/data/optimistic-updates.js +168 -0
- package/dist/data/optimistic-updates.js.map +1 -0
- package/dist/data/persistence-manager.js +233 -0
- package/dist/data/persistence-manager.js.map +1 -0
- package/dist/defaults.d.ts +1 -0
- package/dist/defaults.d.ts.map +1 -0
- package/dist/defaults.js +17 -0
- package/dist/defaults.js.map +1 -0
- package/dist/http/auth-manager.js +260 -0
- package/dist/http/auth-manager.js.map +1 -0
- package/dist/http/http-client.d.ts +7 -0
- package/dist/http/http-client.d.ts.map +1 -1
- package/dist/http/http-client.js +501 -0
- package/dist/http/http-client.js.map +1 -0
- package/dist/http/http-error.js +53 -0
- package/dist/http/http-error.js.map +1 -0
- package/dist/http/mapping.js +64 -0
- package/dist/http/mapping.js.map +1 -0
- package/dist/index.d.ts +3 -52
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +55 -0
- package/dist/kit/calendar.d.ts +43 -0
- package/dist/kit/calendar.d.ts.map +1 -0
- package/dist/kit/calendar.js +423 -0
- package/dist/kit/calendar.js.map +1 -0
- package/dist/kit/cell-editor.d.ts +47 -0
- package/dist/kit/cell-editor.d.ts.map +1 -0
- package/dist/kit/cell-editor.js +191 -0
- package/dist/kit/cell-editor.js.map +1 -0
- package/dist/kit/chart.d.ts +57 -0
- package/dist/kit/chart.d.ts.map +1 -0
- package/dist/kit/chart.js +541 -0
- package/dist/kit/chart.js.map +1 -0
- package/dist/kit/combobox.d.ts +57 -0
- package/dist/kit/combobox.d.ts.map +1 -0
- package/dist/kit/combobox.js +379 -0
- package/dist/kit/combobox.js.map +1 -0
- package/dist/kit/command-palette.d.ts +54 -0
- package/dist/kit/command-palette.d.ts.map +1 -0
- package/dist/kit/command-palette.js +315 -0
- package/dist/kit/command-palette.js.map +1 -0
- package/dist/kit/data-table.d.ts +17 -1
- package/dist/kit/data-table.d.ts.map +1 -1
- package/dist/kit/data-table.js +373 -0
- package/dist/kit/data-table.js.map +1 -0
- package/dist/kit/dialog.d.ts +31 -0
- package/dist/kit/dialog.d.ts.map +1 -0
- package/dist/kit/dialog.js +157 -0
- package/dist/kit/dialog.js.map +1 -0
- package/dist/kit/elements/calendar.d.ts +3 -0
- package/dist/kit/elements/calendar.d.ts.map +1 -0
- package/dist/kit/elements/calendar.js +11 -0
- package/dist/kit/elements/calendar.js.map +1 -0
- package/dist/kit/elements/chart.d.ts +3 -0
- package/dist/kit/elements/chart.d.ts.map +1 -0
- package/dist/kit/elements/chart.js +11 -0
- package/dist/kit/elements/chart.js.map +1 -0
- package/dist/kit/elements/combobox.d.ts +3 -0
- package/dist/kit/elements/combobox.d.ts.map +1 -0
- package/dist/kit/elements/combobox.js +11 -0
- package/dist/kit/elements/combobox.js.map +1 -0
- package/dist/kit/elements/command-palette.d.ts +3 -0
- package/dist/kit/elements/command-palette.d.ts.map +1 -0
- package/dist/kit/elements/command-palette.js +11 -0
- package/dist/kit/elements/command-palette.js.map +1 -0
- package/dist/kit/elements/data-table.d.ts +3 -0
- package/dist/kit/elements/data-table.d.ts.map +1 -0
- package/dist/kit/elements/data-table.js +11 -0
- package/dist/kit/elements/data-table.js.map +1 -0
- package/dist/kit/elements/dialog.d.ts +4 -0
- package/dist/kit/elements/dialog.d.ts.map +1 -0
- package/dist/kit/elements/dialog.js +11 -0
- package/dist/kit/elements/dialog.js.map +1 -0
- package/dist/kit/elements/flex-view.d.ts +3 -0
- package/dist/kit/elements/flex-view.d.ts.map +1 -0
- package/dist/kit/elements/flex-view.js +11 -0
- package/dist/kit/elements/flex-view.js.map +1 -0
- package/dist/kit/elements/form.d.ts +3 -0
- package/dist/kit/elements/form.d.ts.map +1 -0
- package/dist/kit/elements/form.js +11 -0
- package/dist/kit/elements/form.js.map +1 -0
- package/dist/kit/elements/kanban.d.ts +3 -0
- package/dist/kit/elements/kanban.d.ts.map +1 -0
- package/dist/kit/elements/kanban.js +11 -0
- package/dist/kit/elements/kanban.js.map +1 -0
- package/dist/kit/elements/list.d.ts +3 -0
- package/dist/kit/elements/list.d.ts.map +1 -0
- package/dist/kit/elements/list.js +11 -0
- package/dist/kit/elements/list.js.map +1 -0
- package/dist/kit/elements/markdown-editor.d.ts +3 -0
- package/dist/kit/elements/markdown-editor.d.ts.map +1 -0
- package/dist/kit/elements/markdown-editor.js +11 -0
- package/dist/kit/elements/markdown-editor.js.map +1 -0
- package/dist/kit/elements/presence.d.ts +3 -0
- package/dist/kit/elements/presence.d.ts.map +1 -0
- package/dist/kit/elements/presence.js +11 -0
- package/dist/kit/elements/presence.js.map +1 -0
- package/dist/kit/elements/sheet.d.ts +3 -0
- package/dist/kit/elements/sheet.d.ts.map +1 -0
- package/dist/kit/elements/sheet.js +11 -0
- package/dist/kit/elements/sheet.js.map +1 -0
- package/dist/kit/elements/tabs.d.ts +3 -0
- package/dist/kit/elements/tabs.d.ts.map +1 -0
- package/dist/kit/elements/tabs.js +11 -0
- package/dist/kit/elements/tabs.js.map +1 -0
- package/dist/kit/elements/toast.d.ts +4 -0
- package/dist/kit/elements/toast.d.ts.map +1 -0
- package/dist/kit/elements/toast.js +11 -0
- package/dist/kit/elements/toast.js.map +1 -0
- package/dist/kit/elements/tree.d.ts +3 -0
- package/dist/kit/elements/tree.d.ts.map +1 -0
- package/dist/kit/elements/tree.js +11 -0
- package/dist/kit/elements/tree.js.map +1 -0
- package/dist/kit/flex-view.d.ts +2 -0
- package/dist/kit/flex-view.d.ts.map +1 -1
- package/dist/kit/flex-view.js +346 -0
- package/dist/kit/flex-view.js.map +1 -0
- package/dist/kit/form.d.ts +2 -0
- package/dist/kit/form.d.ts.map +1 -1
- package/dist/kit/form.js +211 -0
- package/dist/kit/form.js.map +1 -0
- package/dist/kit/index.d.ts +33 -16
- package/dist/kit/index.d.ts.map +1 -1
- package/dist/kit/index.js +40 -0
- package/dist/kit/internal/modal.d.ts +26 -0
- package/dist/kit/internal/modal.d.ts.map +1 -0
- package/dist/kit/internal/modal.js +59 -0
- package/dist/kit/internal/modal.js.map +1 -0
- package/dist/kit/kanban.d.ts +73 -0
- package/dist/kit/kanban.d.ts.map +1 -0
- package/dist/kit/kanban.js +404 -0
- package/dist/kit/kanban.js.map +1 -0
- package/dist/kit/list.d.ts +4 -0
- package/dist/kit/list.d.ts.map +1 -1
- package/dist/kit/list.js +106 -0
- package/dist/kit/list.js.map +1 -0
- package/dist/kit/markdown/highlight.d.ts +29 -0
- package/dist/kit/markdown/highlight.d.ts.map +1 -0
- package/dist/kit/markdown/highlight.js +106 -0
- package/dist/kit/markdown/highlight.js.map +1 -0
- package/dist/kit/markdown/render.d.ts +31 -0
- package/dist/kit/markdown/render.d.ts.map +1 -0
- package/dist/kit/markdown/render.js +260 -0
- package/dist/kit/markdown/render.js.map +1 -0
- package/dist/kit/markdown-editor.d.ts +54 -0
- package/dist/kit/markdown-editor.d.ts.map +1 -0
- package/dist/kit/markdown-editor.js +797 -0
- package/dist/kit/markdown-editor.js.map +1 -0
- package/dist/kit/presence.d.ts +36 -0
- package/dist/kit/presence.d.ts.map +1 -0
- package/dist/kit/presence.js +262 -0
- package/dist/kit/presence.js.map +1 -0
- package/dist/kit/sheet/formula.d.ts +106 -0
- package/dist/kit/sheet/formula.d.ts.map +1 -0
- package/dist/kit/sheet/formula.js +364 -0
- package/dist/kit/sheet/formula.js.map +1 -0
- package/dist/kit/sheet/model.d.ts +28 -0
- package/dist/kit/sheet/model.d.ts.map +1 -0
- package/dist/kit/sheet/model.js +136 -0
- package/dist/kit/sheet/model.js.map +1 -0
- package/dist/kit/sheet/sheet.d.ts +47 -0
- package/dist/kit/sheet/sheet.d.ts.map +1 -0
- package/dist/kit/sheet/sheet.js +676 -0
- package/dist/kit/sheet/sheet.js.map +1 -0
- package/dist/kit/tabs.d.ts +17 -0
- package/dist/kit/tabs.d.ts.map +1 -0
- package/dist/kit/tabs.js +192 -0
- package/dist/kit/tabs.js.map +1 -0
- package/dist/kit/theme-boot.generated.d.ts +2 -0
- package/dist/kit/theme-boot.generated.d.ts.map +1 -1
- package/dist/kit/theme-boot.generated.js +8 -0
- package/dist/kit/theme-boot.generated.js.map +1 -0
- package/dist/kit/theme.d.ts +5 -3
- package/dist/kit/theme.d.ts.map +1 -1
- package/dist/kit/theme.js +89 -0
- package/dist/kit/theme.js.map +1 -0
- package/dist/kit/toast.d.ts +46 -0
- package/dist/kit/toast.d.ts.map +1 -0
- package/dist/kit/toast.js +154 -0
- package/dist/kit/toast.js.map +1 -0
- package/dist/kit/tree.d.ts +41 -0
- package/dist/kit/tree.d.ts.map +1 -0
- package/dist/kit/tree.js +422 -0
- package/dist/kit/tree.js.map +1 -0
- package/dist/mixins/context-menu.d.ts.map +1 -1
- package/dist/mixins/context-menu.js +183 -0
- package/dist/mixins/context-menu.js.map +1 -0
- package/dist/mixins/draggable.d.ts.map +1 -1
- package/dist/mixins/draggable.js +140 -0
- package/dist/mixins/draggable.js.map +1 -0
- package/dist/mixins/dropdown.d.ts.map +1 -1
- package/dist/mixins/dropdown.js +216 -0
- package/dist/mixins/dropdown.js.map +1 -0
- package/dist/mixins/editable.d.ts.map +1 -1
- package/dist/mixins/editable.js +175 -0
- package/dist/mixins/editable.js.map +1 -0
- package/dist/mixins/grid-navigation.d.ts.map +1 -1
- package/dist/mixins/grid-navigation.js +194 -0
- package/dist/mixins/grid-navigation.js.map +1 -0
- package/dist/mixins/index.d.ts +8 -2
- package/dist/mixins/index.d.ts.map +1 -1
- package/dist/mixins/index.js +38 -0
- package/dist/mixins/index.js.map +1 -0
- package/dist/mixins/infinite-scroll.d.ts.map +1 -1
- package/dist/mixins/infinite-scroll.js +83 -0
- package/dist/mixins/infinite-scroll.js.map +1 -0
- package/dist/mixins/listbox.d.ts +19 -0
- package/dist/mixins/listbox.d.ts.map +1 -0
- package/dist/mixins/listbox.js +208 -0
- package/dist/mixins/listbox.js.map +1 -0
- package/dist/mixins/popup.d.ts +36 -0
- package/dist/mixins/popup.d.ts.map +1 -0
- package/dist/mixins/popup.js +113 -0
- package/dist/mixins/popup.js.map +1 -0
- package/dist/mixins/registry.d.ts +6 -0
- package/dist/mixins/registry.d.ts.map +1 -1
- package/dist/mixins/registry.js +167 -0
- package/dist/mixins/registry.js.map +1 -0
- package/dist/mixins/resizable.d.ts.map +1 -1
- package/dist/mixins/resizable.js +128 -0
- package/dist/mixins/resizable.js.map +1 -0
- package/dist/mixins/sortable.d.ts.map +1 -1
- package/dist/mixins/sortable.js +511 -0
- package/dist/mixins/sortable.js.map +1 -0
- package/dist/mixins/tooltip.d.ts.map +1 -1
- package/dist/mixins/tooltip.js +80 -0
- package/dist/mixins/tooltip.js.map +1 -0
- package/dist/mixins/utils.js +105 -0
- package/dist/mixins/utils.js.map +1 -0
- package/dist/plugins/async-validators.js +118 -0
- package/dist/plugins/async-validators.js.map +1 -0
- package/dist/plugins/builtins.d.ts +1 -1
- package/dist/plugins/builtins.d.ts.map +1 -1
- package/dist/plugins/builtins.js +20 -0
- package/dist/plugins/builtins.js.map +1 -0
- package/dist/plugins/date-utils.js +128 -0
- package/dist/plugins/date-utils.js.map +1 -0
- package/dist/plugins/plugin-manager.d.ts.map +1 -1
- package/dist/plugins/plugin-manager.js +99 -0
- package/dist/plugins/plugin-manager.js.map +1 -0
- package/dist/plugins/rich-text.js +365 -0
- package/dist/plugins/rich-text.js.map +1 -0
- package/dist/realtime/azure-pubsub-manager.js +273 -0
- package/dist/realtime/azure-pubsub-manager.js.map +1 -0
- package/dist/realtime/collab/anchors.d.ts +10 -0
- package/dist/realtime/collab/anchors.d.ts.map +1 -0
- package/dist/realtime/collab/anchors.js +19 -0
- package/dist/realtime/collab/anchors.js.map +1 -0
- package/dist/realtime/collab/collab-session.d.ts +46 -1
- package/dist/realtime/collab/collab-session.d.ts.map +1 -1
- package/dist/realtime/collab/collab-session.js +396 -0
- package/dist/realtime/collab/collab-session.js.map +1 -0
- package/dist/realtime/collab/cursor-overlay.d.ts +10 -0
- package/dist/realtime/collab/cursor-overlay.d.ts.map +1 -1
- package/dist/realtime/collab/cursor-overlay.js +187 -0
- package/dist/realtime/collab/cursor-overlay.js.map +1 -0
- package/dist/realtime/collab/textarea-adapter.d.ts +13 -0
- package/dist/realtime/collab/textarea-adapter.d.ts.map +1 -1
- package/dist/realtime/collab/textarea-adapter.js +125 -0
- package/dist/realtime/collab/textarea-adapter.js.map +1 -0
- package/dist/realtime/collab/undo-manager.d.ts +44 -0
- package/dist/realtime/collab/undo-manager.d.ts.map +1 -0
- package/dist/realtime/collab/undo-manager.js +148 -0
- package/dist/realtime/collab/undo-manager.js.map +1 -0
- package/dist/realtime/index.d.ts +11 -0
- package/dist/realtime/index.d.ts.map +1 -0
- package/dist/realtime/index.js +22 -0
- package/dist/realtime/index.js.map +1 -0
- package/dist/realtime/ot/client.d.ts +1 -1
- package/dist/realtime/ot/client.d.ts.map +1 -1
- package/dist/realtime/ot/client.js +74 -0
- package/dist/realtime/ot/client.js.map +1 -0
- package/dist/realtime/ot/server.d.ts +13 -1
- package/dist/realtime/ot/server.d.ts.map +1 -1
- package/dist/realtime/ot/server.js +292 -0
- package/dist/realtime/ot/server.js.map +1 -0
- package/dist/realtime/ot/text-operation.js +282 -0
- package/dist/realtime/ot/text-operation.js.map +1 -0
- package/dist/realtime/reconnect.js +58 -0
- package/dist/realtime/reconnect.js.map +1 -0
- package/dist/realtime/sse-manager.js +172 -0
- package/dist/realtime/sse-manager.js.map +1 -0
- package/dist/realtime/types.d.ts +29 -1
- package/dist/realtime/types.d.ts.map +1 -1
- package/dist/realtime/websocket-manager.js +180 -0
- package/dist/realtime/websocket-manager.js.map +1 -0
- package/dist/theme-polychrome-boot.js +17 -0
- package/dist/theme-polychrome.css +310 -0
- package/dist/theme.css +490 -1
- package/dist/tokens/base.tokens.json +18 -0
- package/dist/tokens/dark-high-contrast.tokens.json +11 -0
- package/dist/tokens/dark.tokens.json +81 -0
- package/dist/tokens/light-high-contrast.tokens.json +11 -0
- package/dist/tokens/light.tokens.json +81 -0
- package/dist/tokens/polychrome.base.tokens.json +45 -0
- package/dist/tokens/polychrome.dark-high-contrast.tokens.json +183 -0
- package/dist/tokens/polychrome.dark.tokens.json +321 -0
- package/dist/tokens/polychrome.light-high-contrast.tokens.json +115 -0
- package/dist/tokens/polychrome.light.tokens.json +418 -0
- package/dist/tokens/polychrome.resolver.json +78 -0
- package/dist/utils/backoff.js +30 -0
- package/dist/utils/backoff.js.map +1 -0
- package/dist/utils/dates.js +67 -0
- package/dist/utils/dates.js.map +1 -0
- package/dist/utils/dom.js +30 -0
- package/dist/utils/dom.js.map +1 -0
- package/dist/utils/emitter.js +40 -0
- package/dist/utils/emitter.js.map +1 -0
- package/dist/utils/fuzzy.d.ts +23 -0
- package/dist/utils/fuzzy.d.ts.map +1 -0
- package/dist/utils/fuzzy.js +95 -0
- package/dist/utils/fuzzy.js.map +1 -0
- package/dist/utils/path.js +99 -0
- package/dist/utils/path.js.map +1 -0
- package/dist/utils/sanitize.js +161 -0
- package/dist/utils/sanitize.js.map +1 -0
- package/dist/utils/url.js +44 -0
- package/dist/utils/url.js.map +1 -0
- package/dist/utils/virtual-window.d.ts +25 -0
- package/dist/utils/virtual-window.d.ts.map +1 -0
- package/dist/utils/virtual-window.js +19 -0
- package/dist/utils/virtual-window.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +6 -0
- package/dist/version.js.map +1 -0
- package/package.json +63 -11
- package/dist/arethesis-jPH9QdQE.js +0 -5345
- package/dist/arethesis-jPH9QdQE.js.map +0 -1
- package/dist/arethesis.js.map +0 -1
- package/dist/components.js.map +0 -1
|
@@ -0,0 +1,541 @@
|
|
|
1
|
+
import { Component } from "../components/component.js";
|
|
2
|
+
import { defineComponent } from "../components/decorators.js";
|
|
3
|
+
// src/kit/chart.ts
|
|
4
|
+
/**
|
|
5
|
+
* `<a-chart>`: dependency-free SVG charts (line, area, bar, stacked bar)
|
|
6
|
+
* that stream, resize, and can be read without a mouse or without sight.
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* chart.configure({
|
|
10
|
+
* type: 'line',
|
|
11
|
+
* label: 'Requests per second',
|
|
12
|
+
* series: [{ key: 'web', label: 'Web' }, { key: 'api', label: 'API' }],
|
|
13
|
+
* x: { type: 'time' },
|
|
14
|
+
* data: [{ x: Date.now(), web: 120, api: 80 }, …],
|
|
15
|
+
* maxPoints: 60,
|
|
16
|
+
* });
|
|
17
|
+
* chart.push({ x: Date.now(), web: 131, api: 77 }); // streaming: the oldest point drops off
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* - **Colors** come from `--ar-chart-1` … `--ar-chart-6`, in series order, and a
|
|
21
|
+
* series keeps its color when others are hidden.
|
|
22
|
+
* - **Hover** shows a crosshair and one tooltip listing every series at that x.
|
|
23
|
+
* - **Keyboard:** the plot is focusable; ← → step through the points (Home/End
|
|
24
|
+
* jump), and each point is announced. Escape hides the readout.
|
|
25
|
+
* - **Legend** (two or more series): buttons that show and hide series.
|
|
26
|
+
* - **Data table:** always available to screen readers, and shown with the
|
|
27
|
+
* "Table" button.
|
|
28
|
+
* - `sparkline: true` draws just the line, for stat tiles.
|
|
29
|
+
*
|
|
30
|
+
* @module kit/chart
|
|
31
|
+
*/
|
|
32
|
+
var NS = "http://www.w3.org/2000/svg";
|
|
33
|
+
/** Colors are written into style attributes, so only plain color values are accepted. */
|
|
34
|
+
var SAFE_COLOR = /^(#[0-9a-f]{3,8}|(rgb|hsl|oklch|oklab)a?\([\d\s.,%/-]+\)|var\(--[\w-]+\)|[a-z]+)$/i;
|
|
35
|
+
var esc = (s) => s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
36
|
+
var round = (n) => Math.round(n * 10) / 10;
|
|
37
|
+
/** "Nice" axis ticks: 1, 2, 2.5 or 5 times a power of ten. */
|
|
38
|
+
function niceTicks(min, max, count = 5) {
|
|
39
|
+
if (!Number.isFinite(min) || !Number.isFinite(max)) return [0];
|
|
40
|
+
if (min === max) {
|
|
41
|
+
const pad = Math.abs(min) || 1;
|
|
42
|
+
min -= pad;
|
|
43
|
+
max += pad;
|
|
44
|
+
}
|
|
45
|
+
const raw = (max - min) / Math.max(1, count);
|
|
46
|
+
const power = 10 ** Math.floor(Math.log10(raw));
|
|
47
|
+
const step = [
|
|
48
|
+
1,
|
|
49
|
+
2,
|
|
50
|
+
2.5,
|
|
51
|
+
5,
|
|
52
|
+
10
|
|
53
|
+
].map((m) => m * power).find((s) => s >= raw) ?? 10 * power;
|
|
54
|
+
const start = Math.floor(min / step) * step;
|
|
55
|
+
const ticks = [];
|
|
56
|
+
for (let v = start; v <= max + step * .5 && ticks.length < 50; v += step) ticks.push(Math.round(v / step) * step);
|
|
57
|
+
if (ticks[ticks.length - 1] < max) ticks.push(ticks[ticks.length - 1] + step);
|
|
58
|
+
return ticks;
|
|
59
|
+
}
|
|
60
|
+
var compact = new Intl.NumberFormat(void 0, {
|
|
61
|
+
notation: "compact",
|
|
62
|
+
maximumFractionDigits: 1
|
|
63
|
+
});
|
|
64
|
+
var full = new Intl.NumberFormat(void 0, { maximumFractionDigits: 2 });
|
|
65
|
+
var Chart = class extends Component {
|
|
66
|
+
#config = null;
|
|
67
|
+
#data = [];
|
|
68
|
+
#hidden = /* @__PURE__ */ new Set();
|
|
69
|
+
#index = -1;
|
|
70
|
+
#width = 0;
|
|
71
|
+
#plot;
|
|
72
|
+
#svg;
|
|
73
|
+
#tooltip;
|
|
74
|
+
#legend;
|
|
75
|
+
#table;
|
|
76
|
+
#live;
|
|
77
|
+
#built = false;
|
|
78
|
+
#frame = 0;
|
|
79
|
+
/** Geometry of the last render, for hit-testing. */
|
|
80
|
+
#geo = null;
|
|
81
|
+
/** Set up (or replace) the chart. */
|
|
82
|
+
configure(config) {
|
|
83
|
+
this.#config = config;
|
|
84
|
+
this.#data = [...config.data ?? []];
|
|
85
|
+
this.#trim();
|
|
86
|
+
this.#hidden.clear();
|
|
87
|
+
this.#index = -1;
|
|
88
|
+
if (this.isConnected) this.#build();
|
|
89
|
+
this.#schedule();
|
|
90
|
+
}
|
|
91
|
+
get config() {
|
|
92
|
+
return this.#config;
|
|
93
|
+
}
|
|
94
|
+
get data() {
|
|
95
|
+
return this.#data;
|
|
96
|
+
}
|
|
97
|
+
/** Replace all the data. */
|
|
98
|
+
setData(rows) {
|
|
99
|
+
this.#data = [...rows];
|
|
100
|
+
this.#trim();
|
|
101
|
+
this.#schedule();
|
|
102
|
+
}
|
|
103
|
+
/** Add a point at the end (dropping the oldest beyond `maxPoints`). */
|
|
104
|
+
push(row) {
|
|
105
|
+
this.#data.push(row);
|
|
106
|
+
const dropped = this.#trim();
|
|
107
|
+
if (this.#index >= 0) this.#index = Math.max(0, this.#index - dropped);
|
|
108
|
+
this.#schedule();
|
|
109
|
+
}
|
|
110
|
+
/** Show or hide a series (its color doesn't change). */
|
|
111
|
+
setSeriesVisible(key, visible) {
|
|
112
|
+
if (visible) this.#hidden.delete(key);
|
|
113
|
+
else this.#hidden.add(key);
|
|
114
|
+
this.#schedule();
|
|
115
|
+
}
|
|
116
|
+
#trim() {
|
|
117
|
+
const max = this.#config?.maxPoints;
|
|
118
|
+
if (!max || this.#data.length <= max) return 0;
|
|
119
|
+
const n = this.#data.length - max;
|
|
120
|
+
this.#data.splice(0, n);
|
|
121
|
+
return n;
|
|
122
|
+
}
|
|
123
|
+
onConnected() {
|
|
124
|
+
if (this.#config) this.#build();
|
|
125
|
+
this.listen(window, "resize", () => this.#schedule());
|
|
126
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
127
|
+
const ro = new ResizeObserver(() => this.#schedule());
|
|
128
|
+
ro.observe(this);
|
|
129
|
+
this.signal.addEventListener("abort", () => ro.disconnect());
|
|
130
|
+
}
|
|
131
|
+
this.#schedule();
|
|
132
|
+
}
|
|
133
|
+
onDisconnected() {
|
|
134
|
+
cancelAnimationFrame(this.#frame);
|
|
135
|
+
this.#frame = 0;
|
|
136
|
+
}
|
|
137
|
+
#build() {
|
|
138
|
+
const config = this.#config;
|
|
139
|
+
this.classList.add("ar-chart");
|
|
140
|
+
this.classList.toggle("ar-chart--spark", !!config.sparkline);
|
|
141
|
+
if (!this.#built) {
|
|
142
|
+
this.#built = true;
|
|
143
|
+
this.#legend = document.createElement("div");
|
|
144
|
+
this.#legend.className = "ar-chart__legend";
|
|
145
|
+
this.#plot = document.createElement("div");
|
|
146
|
+
this.#plot.className = "ar-chart__plot";
|
|
147
|
+
this.#svg = document.createElementNS(NS, "svg");
|
|
148
|
+
this.#svg.setAttribute("aria-hidden", "true");
|
|
149
|
+
this.#svg.setAttribute("focusable", "false");
|
|
150
|
+
this.#tooltip = document.createElement("div");
|
|
151
|
+
this.#tooltip.className = "ar-chart__tooltip";
|
|
152
|
+
this.#tooltip.hidden = true;
|
|
153
|
+
this.#tooltip.setAttribute("aria-hidden", "true");
|
|
154
|
+
this.#live = document.createElement("div");
|
|
155
|
+
this.#live.className = "ar-visually-hidden";
|
|
156
|
+
this.#live.setAttribute("aria-live", "polite");
|
|
157
|
+
this.#table = document.createElement("table");
|
|
158
|
+
this.#table.className = "ar-chart__table ar-visually-hidden";
|
|
159
|
+
this.#plot.append(this.#svg, this.#tooltip);
|
|
160
|
+
this.replaceChildren(this.#legend, this.#plot, this.#live, this.#table);
|
|
161
|
+
this.#wire();
|
|
162
|
+
}
|
|
163
|
+
this.#plot.style.height = `${config.height ?? (config.sparkline ? 40 : 220)}px`;
|
|
164
|
+
if (config.sparkline) {
|
|
165
|
+
this.#plot.removeAttribute("tabindex");
|
|
166
|
+
this.#plot.setAttribute("role", "img");
|
|
167
|
+
this.#plot.setAttribute("aria-label", config.label);
|
|
168
|
+
} else {
|
|
169
|
+
this.#plot.tabIndex = 0;
|
|
170
|
+
this.#plot.setAttribute("role", "group");
|
|
171
|
+
this.#plot.setAttribute("aria-roledescription", "chart");
|
|
172
|
+
this.#plot.setAttribute("aria-label", `${config.label}. Use the left and right arrow keys to read the values.`);
|
|
173
|
+
}
|
|
174
|
+
this.#renderLegend();
|
|
175
|
+
}
|
|
176
|
+
#renderLegend() {
|
|
177
|
+
const config = this.#config;
|
|
178
|
+
this.#legend.replaceChildren();
|
|
179
|
+
if (config.sparkline) return;
|
|
180
|
+
if (config.series.length > 1) config.series.forEach((s, i) => {
|
|
181
|
+
const button = document.createElement("button");
|
|
182
|
+
button.type = "button";
|
|
183
|
+
button.className = "ar-chart__key";
|
|
184
|
+
button.dataset.key = s.key;
|
|
185
|
+
button.setAttribute("aria-pressed", String(!this.#hidden.has(s.key)));
|
|
186
|
+
const swatch = document.createElement("span");
|
|
187
|
+
swatch.className = "ar-chart__swatch";
|
|
188
|
+
swatch.style.background = this.#color(s, i);
|
|
189
|
+
swatch.setAttribute("aria-hidden", "true");
|
|
190
|
+
button.append(swatch, document.createTextNode(s.label));
|
|
191
|
+
this.#legend.appendChild(button);
|
|
192
|
+
});
|
|
193
|
+
const table = document.createElement("button");
|
|
194
|
+
table.type = "button";
|
|
195
|
+
table.className = "ar-chart__key ar-chart__table-toggle";
|
|
196
|
+
table.textContent = "Table";
|
|
197
|
+
table.setAttribute("aria-pressed", String(!this.#table.classList.contains("ar-visually-hidden")));
|
|
198
|
+
table.title = "Show the data as a table";
|
|
199
|
+
this.#legend.appendChild(table);
|
|
200
|
+
}
|
|
201
|
+
#color(series, index) {
|
|
202
|
+
return series.color && SAFE_COLOR.test(series.color) ? series.color : `var(--ar-chart-${index % 6 + 1})`;
|
|
203
|
+
}
|
|
204
|
+
#wire() {
|
|
205
|
+
this.listen(this.#legend, "click", (e) => {
|
|
206
|
+
const button = e.target.closest("button");
|
|
207
|
+
if (!button) return;
|
|
208
|
+
if (button.classList.contains("ar-chart__table-toggle")) {
|
|
209
|
+
const show = this.#table.classList.toggle("ar-visually-hidden") === false;
|
|
210
|
+
button.setAttribute("aria-pressed", String(show));
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
const key = button.dataset.key;
|
|
214
|
+
const visible = this.#hidden.has(key);
|
|
215
|
+
if (!visible && this.#config.series.filter((s) => !this.#hidden.has(s.key)).length === 1) return;
|
|
216
|
+
this.setSeriesVisible(key, visible);
|
|
217
|
+
button.setAttribute("aria-pressed", String(visible));
|
|
218
|
+
});
|
|
219
|
+
this.listen(this.#plot, "pointermove", (e) => {
|
|
220
|
+
const pe = e;
|
|
221
|
+
if (!this.#geo || this.#config?.sparkline) return;
|
|
222
|
+
const rect = this.#plot.getBoundingClientRect();
|
|
223
|
+
const x = pe.clientX - rect.left;
|
|
224
|
+
this.#index = this.#nearest(x);
|
|
225
|
+
this.#drawReadout(false);
|
|
226
|
+
});
|
|
227
|
+
this.listen(this.#plot, "pointerleave", () => {
|
|
228
|
+
if (document.activeElement !== this.#plot) this.#hideReadout();
|
|
229
|
+
});
|
|
230
|
+
this.listen(this.#plot, "focus", () => {
|
|
231
|
+
if (this.#index < 0) this.#index = this.#data.length - 1;
|
|
232
|
+
this.#drawReadout(true);
|
|
233
|
+
});
|
|
234
|
+
this.listen(this.#plot, "blur", () => this.#hideReadout());
|
|
235
|
+
this.listen(this.#plot, "keydown", (e) => {
|
|
236
|
+
const ke = e;
|
|
237
|
+
const last = this.#data.length - 1;
|
|
238
|
+
let next;
|
|
239
|
+
if (ke.key === "ArrowRight") next = Math.min(last, this.#index + 1);
|
|
240
|
+
else if (ke.key === "ArrowLeft") next = Math.max(0, this.#index - 1);
|
|
241
|
+
else if (ke.key === "Home") next = 0;
|
|
242
|
+
else if (ke.key === "End") next = last;
|
|
243
|
+
else if (ke.key === "Escape") {
|
|
244
|
+
this.#hideReadout();
|
|
245
|
+
return;
|
|
246
|
+
} else return;
|
|
247
|
+
ke.preventDefault();
|
|
248
|
+
this.#index = next;
|
|
249
|
+
this.#drawReadout(true);
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
#nearest(x) {
|
|
253
|
+
const xs = this.#geo?.xs ?? [];
|
|
254
|
+
let best = -1;
|
|
255
|
+
let dist = Infinity;
|
|
256
|
+
xs.forEach((px, i) => {
|
|
257
|
+
const d = Math.abs(px - x);
|
|
258
|
+
if (d < dist) {
|
|
259
|
+
dist = d;
|
|
260
|
+
best = i;
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
return best;
|
|
264
|
+
}
|
|
265
|
+
#schedule() {
|
|
266
|
+
if (this.#frame || !this.#config) return;
|
|
267
|
+
const run = () => {
|
|
268
|
+
this.#frame = 0;
|
|
269
|
+
this.#render();
|
|
270
|
+
};
|
|
271
|
+
this.#frame = typeof requestAnimationFrame === "function" ? requestAnimationFrame(run) : setTimeout(run, 0);
|
|
272
|
+
}
|
|
273
|
+
/** Draw now (normally batched to the next frame). */
|
|
274
|
+
redraw() {
|
|
275
|
+
cancelAnimationFrame(this.#frame);
|
|
276
|
+
this.#frame = 0;
|
|
277
|
+
this.#render();
|
|
278
|
+
}
|
|
279
|
+
#formatX(x) {
|
|
280
|
+
const config = this.#config;
|
|
281
|
+
if (config.x?.format) return config.x.format(x);
|
|
282
|
+
if (config.x?.type === "time" || x instanceof Date) return new Date(x).toLocaleTimeString(void 0, {
|
|
283
|
+
hour: "numeric",
|
|
284
|
+
minute: "2-digit",
|
|
285
|
+
second: "2-digit"
|
|
286
|
+
});
|
|
287
|
+
return typeof x === "number" ? full.format(x) : String(x);
|
|
288
|
+
}
|
|
289
|
+
#formatY(v, axis = false) {
|
|
290
|
+
const f = this.#config.y?.format;
|
|
291
|
+
if (f) return f(v);
|
|
292
|
+
return axis && Math.abs(v) >= 1e4 ? compact.format(v) : full.format(v);
|
|
293
|
+
}
|
|
294
|
+
#value(row, key) {
|
|
295
|
+
const v = row[key];
|
|
296
|
+
return typeof v === "number" && Number.isFinite(v) ? v : null;
|
|
297
|
+
}
|
|
298
|
+
#render() {
|
|
299
|
+
const config = this.#config;
|
|
300
|
+
if (!config || !this.#built) return;
|
|
301
|
+
this.#width = this.#plot.clientWidth || this.#width || 300;
|
|
302
|
+
const width = this.#width;
|
|
303
|
+
const height = config.height ?? (config.sparkline ? 40 : 220);
|
|
304
|
+
const series = config.series.map((s, i) => ({
|
|
305
|
+
...s,
|
|
306
|
+
color: this.#color(s, i)
|
|
307
|
+
})).filter((s) => !this.#hidden.has(s.key));
|
|
308
|
+
const data = this.#data;
|
|
309
|
+
const stacked = config.type === "stacked-bar";
|
|
310
|
+
const bars = config.type === "bar" || stacked;
|
|
311
|
+
let lo = Infinity;
|
|
312
|
+
let hi = -Infinity;
|
|
313
|
+
for (const row of data) if (stacked) {
|
|
314
|
+
const sum = series.reduce((t, s) => t + Math.max(0, this.#value(row, s.key) ?? 0), 0);
|
|
315
|
+
hi = Math.max(hi, sum);
|
|
316
|
+
lo = Math.min(lo, 0);
|
|
317
|
+
} else for (const s of series) {
|
|
318
|
+
const v = this.#value(row, s.key);
|
|
319
|
+
if (v === null) continue;
|
|
320
|
+
lo = Math.min(lo, v);
|
|
321
|
+
hi = Math.max(hi, v);
|
|
322
|
+
}
|
|
323
|
+
if (!Number.isFinite(lo)) [lo, hi] = [0, 1];
|
|
324
|
+
if (bars || config.type === "area") lo = Math.min(0, lo);
|
|
325
|
+
if (config.y?.min !== void 0) lo = config.y.min;
|
|
326
|
+
if (config.y?.max !== void 0) hi = config.y.max;
|
|
327
|
+
const ticks = config.sparkline ? [lo, hi === lo ? lo + 1 : hi] : niceTicks(lo, hi, height < 180 ? 3 : 5);
|
|
328
|
+
const y0 = ticks[0];
|
|
329
|
+
const y1 = ticks[ticks.length - 1];
|
|
330
|
+
const labelWidth = config.sparkline ? 0 : Math.max(...ticks.map((t) => this.#formatY(t, true).length)) * 7 + 10;
|
|
331
|
+
const m = config.sparkline ? {
|
|
332
|
+
top: 3,
|
|
333
|
+
right: 3,
|
|
334
|
+
bottom: 3,
|
|
335
|
+
left: 3
|
|
336
|
+
} : {
|
|
337
|
+
top: 10,
|
|
338
|
+
right: 14,
|
|
339
|
+
bottom: 26,
|
|
340
|
+
left: labelWidth
|
|
341
|
+
};
|
|
342
|
+
const pw = Math.max(10, width - m.left - m.right);
|
|
343
|
+
const ph = Math.max(10, height - m.top - m.bottom);
|
|
344
|
+
const y = (v) => m.top + ph - (v - y0) / (y1 - y0 || 1) * ph;
|
|
345
|
+
const n = data.length;
|
|
346
|
+
let xs;
|
|
347
|
+
const band = n ? pw / n : pw;
|
|
348
|
+
if (bars) xs = data.map((_, i) => m.left + band * (i + .5));
|
|
349
|
+
else if ((config.x?.type === "time" || config.x?.type === "number") && n > 1) {
|
|
350
|
+
const t = data.map((r) => r.x instanceof Date ? r.x.getTime() : Number(r.x));
|
|
351
|
+
const t0 = t[0];
|
|
352
|
+
const t1 = t[n - 1];
|
|
353
|
+
xs = t.map((v) => m.left + (v - t0) / (t1 - t0 || 1) * pw);
|
|
354
|
+
} else xs = data.map((_, i) => m.left + (n > 1 ? i / (n - 1) * pw : pw / 2));
|
|
355
|
+
this.#geo = {
|
|
356
|
+
left: m.left,
|
|
357
|
+
top: m.top,
|
|
358
|
+
width: pw,
|
|
359
|
+
height: ph,
|
|
360
|
+
xs,
|
|
361
|
+
y
|
|
362
|
+
};
|
|
363
|
+
const out = [];
|
|
364
|
+
if (!config.sparkline) {
|
|
365
|
+
for (const t of ticks) {
|
|
366
|
+
const py = round(y(t));
|
|
367
|
+
out.push(`<line class="ar-chart__grid${t === 0 ? " is-zero" : ""}" x1="${m.left}" x2="${m.left + pw}" y1="${py}" y2="${py}"/>`);
|
|
368
|
+
out.push(`<text class="ar-chart__tick" x="${m.left - 8}" y="${py}" text-anchor="end" dominant-baseline="middle">${esc(this.#formatY(t, true))}</text>`);
|
|
369
|
+
}
|
|
370
|
+
const longest = Math.max(4, ...data.map((r) => this.#formatX(r.x).length));
|
|
371
|
+
const fit = Math.max(2, Math.floor(pw / (longest * 6.5 + 16)));
|
|
372
|
+
const step = Math.max(1, Math.ceil(n / fit));
|
|
373
|
+
for (let i = n - 1; i >= 0; i -= step) out.push(`<text class="ar-chart__tick" x="${round(xs[i])}" y="${m.top + ph + 18}" text-anchor="${i === n - 1 && !bars ? "end" : i === 0 && !bars ? "start" : "middle"}">${esc(this.#formatX(data[i].x))}</text>`);
|
|
374
|
+
}
|
|
375
|
+
if (bars && n) {
|
|
376
|
+
const base = y(Math.max(y0, Math.min(0, y1)));
|
|
377
|
+
if (stacked) {
|
|
378
|
+
const w = Math.min(24, band * .7);
|
|
379
|
+
data.forEach((row, i) => {
|
|
380
|
+
let top = base;
|
|
381
|
+
const parts = series.map((s) => ({
|
|
382
|
+
s,
|
|
383
|
+
v: Math.max(0, this.#value(row, s.key) ?? 0)
|
|
384
|
+
})).filter((p) => p.v > 0);
|
|
385
|
+
parts.forEach((p, j) => {
|
|
386
|
+
const h = p.v / (y1 - y0 || 1) * ph;
|
|
387
|
+
const gap = j > 0 ? 2 : 0;
|
|
388
|
+
const yTop = top - h;
|
|
389
|
+
out.push(barPath(xs[i] - w / 2, yTop, w, h - gap, top - gap, j === parts.length - 1, p.s.color));
|
|
390
|
+
top = yTop;
|
|
391
|
+
});
|
|
392
|
+
});
|
|
393
|
+
} else {
|
|
394
|
+
const groupW = Math.min(band * .8, 24 * series.length + 2 * (series.length - 1));
|
|
395
|
+
const w = Math.max(2, (groupW - 2 * (series.length - 1)) / series.length);
|
|
396
|
+
data.forEach((row, i) => {
|
|
397
|
+
series.forEach((s, j) => {
|
|
398
|
+
const v = this.#value(row, s.key);
|
|
399
|
+
if (v === null) return;
|
|
400
|
+
const x = xs[i] - groupW / 2 + j * (w + 2);
|
|
401
|
+
const top = y(Math.max(v, 0));
|
|
402
|
+
const bottom = y(Math.min(v, 0));
|
|
403
|
+
out.push(barPath(x, top, w, bottom - top, bottom, true, s.color, v < 0));
|
|
404
|
+
});
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
} else for (const s of series) {
|
|
408
|
+
const points = data.map((row, i) => [xs[i], this.#value(row, s.key)]).filter((p) => p[1] !== null);
|
|
409
|
+
if (!points.length) continue;
|
|
410
|
+
const d = points.map(([px, v], i) => `${i ? "L" : "M"}${round(px)},${round(y(v))}`).join("");
|
|
411
|
+
if (config.type === "area") {
|
|
412
|
+
const base = round(y(Math.max(y0, 0)));
|
|
413
|
+
out.push(`<path class="ar-chart__area" style="fill:${s.color}" d="${d}L${round(points[points.length - 1][0])},${base}L${round(points[0][0])},${base}Z"/>`);
|
|
414
|
+
}
|
|
415
|
+
out.push(`<path class="ar-chart__line" style="stroke:${s.color}" d="${d}"/>`);
|
|
416
|
+
const [ex, ev] = points[points.length - 1];
|
|
417
|
+
out.push(`<circle class="ar-chart__dot" style="fill:${s.color}" cx="${round(ex)}" cy="${round(y(ev))}" r="${config.sparkline ? 2.5 : 4}"/>`);
|
|
418
|
+
}
|
|
419
|
+
out.push("<g class=\"ar-chart__cursor\"></g>");
|
|
420
|
+
this.#svg.setAttribute("viewBox", `0 0 ${width} ${height}`);
|
|
421
|
+
this.#svg.setAttribute("width", String(width));
|
|
422
|
+
this.#svg.setAttribute("height", String(height));
|
|
423
|
+
this.#svg.innerHTML = out.join("");
|
|
424
|
+
if (!this.#tooltip.hidden) this.#drawReadout(false, true);
|
|
425
|
+
this.#renderTable(series);
|
|
426
|
+
}
|
|
427
|
+
#renderTable(series) {
|
|
428
|
+
const config = this.#config;
|
|
429
|
+
const caption = document.createElement("caption");
|
|
430
|
+
caption.textContent = config.label;
|
|
431
|
+
const head = document.createElement("tr");
|
|
432
|
+
for (const label of [config.x?.type === "time" ? "Time" : "X", ...series.map((s) => s.label)]) {
|
|
433
|
+
const th = document.createElement("th");
|
|
434
|
+
th.scope = "col";
|
|
435
|
+
th.textContent = label;
|
|
436
|
+
head.appendChild(th);
|
|
437
|
+
}
|
|
438
|
+
const rows = this.#data.map((row) => {
|
|
439
|
+
const tr = document.createElement("tr");
|
|
440
|
+
const th = document.createElement("th");
|
|
441
|
+
th.scope = "row";
|
|
442
|
+
th.textContent = this.#formatX(row.x);
|
|
443
|
+
tr.appendChild(th);
|
|
444
|
+
for (const s of series) {
|
|
445
|
+
const td = document.createElement("td");
|
|
446
|
+
const v = this.#value(row, s.key);
|
|
447
|
+
td.textContent = v === null ? "–" : this.#formatY(v);
|
|
448
|
+
tr.appendChild(td);
|
|
449
|
+
}
|
|
450
|
+
return tr;
|
|
451
|
+
});
|
|
452
|
+
const thead = document.createElement("thead");
|
|
453
|
+
thead.appendChild(head);
|
|
454
|
+
const tbody = document.createElement("tbody");
|
|
455
|
+
tbody.append(...rows);
|
|
456
|
+
this.#table.replaceChildren(caption, thead, tbody);
|
|
457
|
+
}
|
|
458
|
+
/** Crosshair, dots and tooltip at the current index; `announce` also tells screen readers. */
|
|
459
|
+
#drawReadout(announce, quiet = false) {
|
|
460
|
+
const config = this.#config;
|
|
461
|
+
const geo = this.#geo;
|
|
462
|
+
if (!config || !geo || config.sparkline || this.#index < 0 || this.#index >= this.#data.length) return;
|
|
463
|
+
const row = this.#data[this.#index];
|
|
464
|
+
const x = geo.xs[this.#index];
|
|
465
|
+
const series = config.series.map((s, i) => ({
|
|
466
|
+
...s,
|
|
467
|
+
color: this.#color(s, i)
|
|
468
|
+
})).filter((s) => !this.#hidden.has(s.key));
|
|
469
|
+
const bars = config.type === "bar" || config.type === "stacked-bar";
|
|
470
|
+
const cursor = this.#svg.querySelector(".ar-chart__cursor");
|
|
471
|
+
const parts = [];
|
|
472
|
+
if (bars) {
|
|
473
|
+
const band = geo.width / Math.max(1, this.#data.length);
|
|
474
|
+
parts.push(`<rect class="ar-chart__band" x="${round(x - band / 2)}" y="${geo.top}" width="${round(band)}" height="${geo.height}"/>`);
|
|
475
|
+
} else {
|
|
476
|
+
parts.push(`<line class="ar-chart__crosshair" x1="${round(x)}" x2="${round(x)}" y1="${geo.top}" y2="${geo.top + geo.height}"/>`);
|
|
477
|
+
for (const s of series) {
|
|
478
|
+
const v = this.#value(row, s.key);
|
|
479
|
+
if (v !== null) parts.push(`<circle class="ar-chart__dot is-hover" style="fill:${s.color}" cx="${round(x)}" cy="${round(geo.y(v))}" r="4.5"/>`);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
cursor.innerHTML = parts.join("");
|
|
483
|
+
const tip = this.#tooltip;
|
|
484
|
+
const title = document.createElement("p");
|
|
485
|
+
title.className = "ar-chart__tip-title";
|
|
486
|
+
title.textContent = this.#formatX(row.x);
|
|
487
|
+
const list = document.createElement("dl");
|
|
488
|
+
for (const s of series) {
|
|
489
|
+
const v = this.#value(row, s.key);
|
|
490
|
+
const dt = document.createElement("dt");
|
|
491
|
+
const swatch = document.createElement("span");
|
|
492
|
+
swatch.className = "ar-chart__swatch";
|
|
493
|
+
swatch.style.background = s.color;
|
|
494
|
+
dt.append(swatch, document.createTextNode(s.label));
|
|
495
|
+
const dd = document.createElement("dd");
|
|
496
|
+
dd.textContent = v === null ? "–" : this.#formatY(v);
|
|
497
|
+
list.append(dt, dd);
|
|
498
|
+
}
|
|
499
|
+
tip.replaceChildren(title, list);
|
|
500
|
+
tip.hidden = false;
|
|
501
|
+
const plotWidth = this.#plot.clientWidth || this.#width;
|
|
502
|
+
const tipWidth = tip.offsetWidth || 160;
|
|
503
|
+
const left = x + 14 + tipWidth > plotWidth ? x - 14 - tipWidth : x + 14;
|
|
504
|
+
tip.style.left = `${Math.max(0, left)}px`;
|
|
505
|
+
tip.style.top = `${geo.top}px`;
|
|
506
|
+
if (announce && !quiet) this.#live.textContent = `${this.#formatX(row.x)}: ${series.map((s) => {
|
|
507
|
+
const v = this.#value(row, s.key);
|
|
508
|
+
return `${s.label} ${v === null ? "no value" : this.#formatY(v)}`;
|
|
509
|
+
}).join(", ")}`;
|
|
510
|
+
}
|
|
511
|
+
#hideReadout() {
|
|
512
|
+
this.#tooltip.hidden = true;
|
|
513
|
+
const cursor = this.#svg?.querySelector(".ar-chart__cursor");
|
|
514
|
+
if (cursor) cursor.innerHTML = "";
|
|
515
|
+
}
|
|
516
|
+
};
|
|
517
|
+
/**
|
|
518
|
+
* A bar with a 4px rounded data end and a square base. `top`/`height` are
|
|
519
|
+
* the bar's extent, `base` the baseline side; `flip` rounds the bottom
|
|
520
|
+
* instead (negative values).
|
|
521
|
+
*/
|
|
522
|
+
function barPath(x, top, w, h, base, rounded, color, flip = false) {
|
|
523
|
+
if (h <= 0) return "";
|
|
524
|
+
const r = rounded ? Math.min(4, w / 2, h) : 0;
|
|
525
|
+
const [l, rgt] = [round(x), round(x + w)];
|
|
526
|
+
if (!flip) {
|
|
527
|
+
const t = round(top);
|
|
528
|
+
const b = round(base);
|
|
529
|
+
return `<path class="ar-chart__bar" style="fill:${color}" d="M${l},${b}V${round(t + r)}Q${l},${t} ${round(l + r)},${t}H${round(rgt - r)}Q${rgt},${t} ${rgt},${round(t + r)}V${b}Z"/>`;
|
|
530
|
+
}
|
|
531
|
+
const t = round(top);
|
|
532
|
+
const b = round(top + h);
|
|
533
|
+
return `<path class="ar-chart__bar" style="fill:${color}" d="M${l},${t}V${round(b - r)}Q${l},${b} ${round(l + r)},${b}H${round(rgt - r)}Q${rgt},${b} ${rgt},${round(b - r)}V${t}Z"/>`;
|
|
534
|
+
}
|
|
535
|
+
/** Define `<a-chart>` (idempotent). `import 'arethesis/components/chart'` calls this. */
|
|
536
|
+
function defineChart() {
|
|
537
|
+
defineComponent({ tag: "a-chart" })(Chart);
|
|
538
|
+
}
|
|
539
|
+
export { Chart, defineChart, niceTicks };
|
|
540
|
+
|
|
541
|
+
//# sourceMappingURL=chart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chart.js","names":[],"sources":["../../src/kit/chart.ts"],"sourcesContent":["/**\n * `<a-chart>`: dependency-free SVG charts (line, area, bar, stacked bar)\n * that stream, resize, and can be read without a mouse or without sight.\n *\n * ```ts\n * chart.configure({\n * type: 'line',\n * label: 'Requests per second',\n * series: [{ key: 'web', label: 'Web' }, { key: 'api', label: 'API' }],\n * x: { type: 'time' },\n * data: [{ x: Date.now(), web: 120, api: 80 }, …],\n * maxPoints: 60,\n * });\n * chart.push({ x: Date.now(), web: 131, api: 77 }); // streaming: the oldest point drops off\n * ```\n *\n * - **Colors** come from `--ar-chart-1` … `--ar-chart-6`, in series order, and a\n * series keeps its color when others are hidden.\n * - **Hover** shows a crosshair and one tooltip listing every series at that x.\n * - **Keyboard:** the plot is focusable; ← → step through the points (Home/End\n * jump), and each point is announced. Escape hides the readout.\n * - **Legend** (two or more series): buttons that show and hide series.\n * - **Data table:** always available to screen readers, and shown with the\n * \"Table\" button.\n * - `sparkline: true` draws just the line, for stat tiles.\n *\n * @module kit/chart\n */\n\nimport { Component } from '../components/component';\nimport { defineComponent } from '../components/decorators';\n\nexport type ChartType = 'line' | 'area' | 'bar' | 'stacked-bar';\nexport type ChartX = number | string | Date;\nexport type ChartRow = { x: ChartX } & Record<string, unknown>;\n\nexport interface ChartSeries {\n key: string;\n label: string;\n /** Any CSS color. @default `var(--ar-chart-N)` by position */\n color?: string;\n}\n\nexport interface ChartConfig {\n type: ChartType;\n /** Accessible name, and the data table's caption. */\n label: string;\n series: ChartSeries[];\n data?: ChartRow[];\n x?: { type?: 'time' | 'number' | 'category'; format?: (x: ChartX) => string };\n y?: { min?: number; max?: number; format?: (value: number) => string; label?: string };\n /** Keep at most this many points (streaming). */\n maxPoints?: number;\n /** Plot height in px. @default 220 (40 for sparklines) */\n height?: number;\n /** Just the line: no axes, legend, tooltip or table button. */\n sparkline?: boolean;\n}\n\nconst NS = 'http://www.w3.org/2000/svg';\n/** Colors are written into style attributes, so only plain color values are accepted. */\nconst SAFE_COLOR = /^(#[0-9a-f]{3,8}|(rgb|hsl|oklch|oklab)a?\\([\\d\\s.,%/-]+\\)|var\\(--[\\w-]+\\)|[a-z]+)$/i;\nconst esc = (s: string): string => s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');\nconst round = (n: number): number => Math.round(n * 10) / 10;\n\n/** \"Nice\" axis ticks: 1, 2, 2.5 or 5 times a power of ten. */\nexport function niceTicks(min: number, max: number, count = 5): number[] {\n if (!Number.isFinite(min) || !Number.isFinite(max)) return [0];\n if (min === max) {\n const pad = Math.abs(min) || 1;\n min -= pad;\n max += pad;\n }\n const raw = (max - min) / Math.max(1, count);\n const power = 10 ** Math.floor(Math.log10(raw));\n const step = [1, 2, 2.5, 5, 10].map(m => m * power).find(s => s >= raw) ?? 10 * power;\n const start = Math.floor(min / step) * step;\n const ticks: number[] = [];\n for (let v = start; v <= max + step * 0.5 && ticks.length < 50; v += step) ticks.push(Math.round(v / step) * step);\n if (ticks[ticks.length - 1] < max) ticks.push(ticks[ticks.length - 1] + step);\n return ticks;\n}\n\nconst compact = new Intl.NumberFormat(undefined, { notation: 'compact', maximumFractionDigits: 1 });\nconst full = new Intl.NumberFormat(undefined, { maximumFractionDigits: 2 });\n\nexport class Chart extends Component {\n #config: ChartConfig | null = null;\n #data: ChartRow[] = [];\n #hidden = new Set<string>();\n #index = -1;\n #width = 0;\n #plot!: HTMLElement;\n #svg!: SVGSVGElement;\n #tooltip!: HTMLElement;\n #legend!: HTMLElement;\n #table!: HTMLTableElement;\n #live!: HTMLElement;\n #built = false;\n #frame = 0;\n /** Geometry of the last render, for hit-testing. */\n #geo: { left: number; top: number; width: number; height: number; xs: number[]; y: (v: number) => number } | null = null;\n\n /** Set up (or replace) the chart. */\n configure(config: ChartConfig): void {\n this.#config = config;\n this.#data = [...(config.data ?? [])];\n this.#trim();\n this.#hidden.clear();\n this.#index = -1;\n if (this.isConnected) this.#build();\n this.#schedule();\n }\n\n get config(): ChartConfig | null {\n return this.#config;\n }\n\n get data(): readonly ChartRow[] {\n return this.#data;\n }\n\n /** Replace all the data. */\n setData(rows: ChartRow[]): void {\n this.#data = [...rows];\n this.#trim();\n this.#schedule();\n }\n\n /** Add a point at the end (dropping the oldest beyond `maxPoints`). */\n push(row: ChartRow): void {\n this.#data.push(row);\n const dropped = this.#trim();\n if (this.#index >= 0) this.#index = Math.max(0, this.#index - dropped);\n this.#schedule();\n }\n\n /** Show or hide a series (its color doesn't change). */\n setSeriesVisible(key: string, visible: boolean): void {\n if (visible) this.#hidden.delete(key);\n else this.#hidden.add(key);\n this.#schedule();\n }\n\n #trim(): number {\n const max = this.#config?.maxPoints;\n if (!max || this.#data.length <= max) return 0;\n const n = this.#data.length - max;\n this.#data.splice(0, n);\n return n;\n }\n\n protected override onConnected(): void {\n if (this.#config) this.#build();\n this.listen(window, 'resize', () => this.#schedule());\n if (typeof ResizeObserver !== 'undefined') {\n const ro = new ResizeObserver(() => this.#schedule());\n ro.observe(this);\n this.signal.addEventListener('abort', () => ro.disconnect());\n }\n this.#schedule();\n }\n\n protected override onDisconnected(): void {\n cancelAnimationFrame(this.#frame);\n this.#frame = 0;\n }\n\n #build(): void {\n const config = this.#config!;\n this.classList.add('ar-chart');\n this.classList.toggle('ar-chart--spark', !!config.sparkline);\n if (!this.#built) {\n this.#built = true;\n this.#legend = document.createElement('div');\n this.#legend.className = 'ar-chart__legend';\n this.#plot = document.createElement('div');\n this.#plot.className = 'ar-chart__plot';\n this.#svg = document.createElementNS(NS, 'svg');\n this.#svg.setAttribute('aria-hidden', 'true');\n this.#svg.setAttribute('focusable', 'false');\n this.#tooltip = document.createElement('div');\n this.#tooltip.className = 'ar-chart__tooltip';\n this.#tooltip.hidden = true;\n this.#tooltip.setAttribute('aria-hidden', 'true');\n this.#live = document.createElement('div');\n this.#live.className = 'ar-visually-hidden';\n this.#live.setAttribute('aria-live', 'polite');\n this.#table = document.createElement('table');\n this.#table.className = 'ar-chart__table ar-visually-hidden';\n this.#plot.append(this.#svg, this.#tooltip);\n this.replaceChildren(this.#legend, this.#plot, this.#live, this.#table);\n this.#wire();\n }\n this.#plot.style.height = `${config.height ?? (config.sparkline ? 40 : 220)}px`;\n if (config.sparkline) {\n this.#plot.removeAttribute('tabindex');\n this.#plot.setAttribute('role', 'img');\n this.#plot.setAttribute('aria-label', config.label);\n } else {\n this.#plot.tabIndex = 0;\n this.#plot.setAttribute('role', 'group');\n this.#plot.setAttribute('aria-roledescription', 'chart');\n this.#plot.setAttribute('aria-label', `${config.label}. Use the left and right arrow keys to read the values.`);\n }\n this.#renderLegend();\n }\n\n #renderLegend(): void {\n const config = this.#config!;\n this.#legend.replaceChildren();\n if (config.sparkline) return;\n if (config.series.length > 1) {\n config.series.forEach((s, i) => {\n const button = document.createElement('button');\n button.type = 'button';\n button.className = 'ar-chart__key';\n button.dataset.key = s.key;\n button.setAttribute('aria-pressed', String(!this.#hidden.has(s.key)));\n const swatch = document.createElement('span');\n swatch.className = 'ar-chart__swatch';\n swatch.style.background = this.#color(s, i);\n swatch.setAttribute('aria-hidden', 'true');\n button.append(swatch, document.createTextNode(s.label));\n this.#legend.appendChild(button);\n });\n }\n const table = document.createElement('button');\n table.type = 'button';\n table.className = 'ar-chart__key ar-chart__table-toggle';\n table.textContent = 'Table';\n table.setAttribute('aria-pressed', String(!this.#table.classList.contains('ar-visually-hidden')));\n table.title = 'Show the data as a table';\n this.#legend.appendChild(table);\n }\n\n #color(series: ChartSeries, index: number): string {\n return series.color && SAFE_COLOR.test(series.color) ? series.color : `var(--ar-chart-${(index % 6) + 1})`;\n }\n\n #wire(): void {\n this.listen(this.#legend, 'click', (e: Event) => {\n const button = (e.target as Element).closest<HTMLButtonElement>('button');\n if (!button) return;\n if (button.classList.contains('ar-chart__table-toggle')) {\n const show = this.#table.classList.toggle('ar-visually-hidden') === false;\n button.setAttribute('aria-pressed', String(show));\n return;\n }\n const key = button.dataset.key!;\n const visible = this.#hidden.has(key);\n // Keep at least one series showing.\n if (!visible && this.#config!.series.filter(s => !this.#hidden.has(s.key)).length === 1) return;\n this.setSeriesVisible(key, visible);\n button.setAttribute('aria-pressed', String(visible));\n });\n this.listen(this.#plot, 'pointermove', (e: Event) => {\n const pe = e as PointerEvent;\n if (!this.#geo || this.#config?.sparkline) return;\n const rect = this.#plot.getBoundingClientRect();\n const x = pe.clientX - rect.left;\n this.#index = this.#nearest(x);\n this.#drawReadout(false);\n });\n this.listen(this.#plot, 'pointerleave', () => {\n if (document.activeElement !== this.#plot) this.#hideReadout();\n });\n this.listen(this.#plot, 'focus', () => {\n if (this.#index < 0) this.#index = this.#data.length - 1;\n this.#drawReadout(true);\n });\n this.listen(this.#plot, 'blur', () => this.#hideReadout());\n this.listen(this.#plot, 'keydown', (e: Event) => {\n const ke = e as KeyboardEvent;\n const last = this.#data.length - 1;\n let next: number;\n if (ke.key === 'ArrowRight') next = Math.min(last, this.#index + 1);\n else if (ke.key === 'ArrowLeft') next = Math.max(0, this.#index - 1);\n else if (ke.key === 'Home') next = 0;\n else if (ke.key === 'End') next = last;\n else if (ke.key === 'Escape') {\n this.#hideReadout();\n return;\n } else return;\n ke.preventDefault();\n this.#index = next;\n this.#drawReadout(true);\n });\n }\n\n #nearest(x: number): number {\n const xs = this.#geo?.xs ?? [];\n let best = -1;\n let dist = Infinity;\n xs.forEach((px, i) => {\n const d = Math.abs(px - x);\n if (d < dist) {\n dist = d;\n best = i;\n }\n });\n return best;\n }\n\n #schedule(): void {\n if (this.#frame || !this.#config) return;\n const run = () => {\n this.#frame = 0;\n this.#render();\n };\n this.#frame = typeof requestAnimationFrame === 'function' ? requestAnimationFrame(run) : (setTimeout(run, 0) as unknown as number);\n }\n\n /** Draw now (normally batched to the next frame). */\n redraw(): void {\n cancelAnimationFrame(this.#frame);\n this.#frame = 0;\n this.#render();\n }\n\n #formatX(x: ChartX): string {\n const config = this.#config!;\n if (config.x?.format) return config.x.format(x);\n if (config.x?.type === 'time' || x instanceof Date) {\n return new Date(x as number).toLocaleTimeString(undefined, { hour: 'numeric', minute: '2-digit', second: '2-digit' });\n }\n return typeof x === 'number' ? full.format(x) : String(x);\n }\n\n #formatY(v: number, axis = false): string {\n const f = this.#config!.y?.format;\n if (f) return f(v);\n return axis && Math.abs(v) >= 10000 ? compact.format(v) : full.format(v);\n }\n\n #value(row: ChartRow, key: string): number | null {\n const v = row[key];\n return typeof v === 'number' && Number.isFinite(v) ? v : null;\n }\n\n #render(): void {\n const config = this.#config;\n if (!config || !this.#built) return;\n this.#width = this.#plot.clientWidth || this.#width || 300;\n const width = this.#width;\n const height = config.height ?? (config.sparkline ? 40 : 220);\n const series = config.series.map((s, i) => ({ ...s, color: this.#color(s, i) })).filter(s => !this.#hidden.has(s.key));\n const data = this.#data;\n const stacked = config.type === 'stacked-bar';\n const bars = config.type === 'bar' || stacked;\n\n // Y domain.\n let lo = Infinity;\n let hi = -Infinity;\n for (const row of data) {\n if (stacked) {\n const sum = series.reduce((t, s) => t + Math.max(0, this.#value(row, s.key) ?? 0), 0);\n hi = Math.max(hi, sum);\n lo = Math.min(lo, 0);\n } else {\n for (const s of series) {\n const v = this.#value(row, s.key);\n if (v === null) continue;\n lo = Math.min(lo, v);\n hi = Math.max(hi, v);\n }\n }\n }\n if (!Number.isFinite(lo)) [lo, hi] = [0, 1];\n if (bars || config.type === 'area') lo = Math.min(0, lo);\n if (config.y?.min !== undefined) lo = config.y.min;\n if (config.y?.max !== undefined) hi = config.y.max;\n const ticks = config.sparkline ? [lo, hi === lo ? lo + 1 : hi] : niceTicks(lo, hi, height < 180 ? 3 : 5);\n const y0 = ticks[0];\n const y1 = ticks[ticks.length - 1];\n\n // Margins: room for the widest y label.\n const labelWidth = config.sparkline ? 0 : Math.max(...ticks.map(t => this.#formatY(t, true).length)) * 7 + 10;\n const m = config.sparkline ? { top: 3, right: 3, bottom: 3, left: 3 } : { top: 10, right: 14, bottom: 26, left: labelWidth };\n const pw = Math.max(10, width - m.left - m.right);\n const ph = Math.max(10, height - m.top - m.bottom);\n const y = (v: number) => m.top + ph - ((v - y0) / (y1 - y0 || 1)) * ph;\n\n // X positions: bars sit in bands; lines span the width (by time or number when given).\n const n = data.length;\n let xs: number[];\n const band = n ? pw / n : pw;\n if (bars) xs = data.map((_, i) => m.left + band * (i + 0.5));\n else if ((config.x?.type === 'time' || config.x?.type === 'number') && n > 1) {\n const t = data.map(r => (r.x instanceof Date ? r.x.getTime() : Number(r.x)));\n const t0 = t[0];\n const t1 = t[n - 1];\n xs = t.map(v => m.left + ((v - t0) / (t1 - t0 || 1)) * pw);\n } else xs = data.map((_, i) => m.left + (n > 1 ? (i / (n - 1)) * pw : pw / 2));\n this.#geo = { left: m.left, top: m.top, width: pw, height: ph, xs, y };\n\n const out: string[] = [];\n if (!config.sparkline) {\n // Gridlines and y labels: hairlines, recessive.\n for (const t of ticks) {\n const py = round(y(t));\n out.push(`<line class=\"ar-chart__grid${t === 0 ? ' is-zero' : ''}\" x1=\"${m.left}\" x2=\"${m.left + pw}\" y1=\"${py}\" y2=\"${py}\"/>`);\n out.push(`<text class=\"ar-chart__tick\" x=\"${m.left - 8}\" y=\"${py}\" text-anchor=\"end\" dominant-baseline=\"middle\">${esc(this.#formatY(t, true))}</text>`);\n }\n // X labels: as many as fit side by side, evenly spaced, always including the latest.\n const longest = Math.max(4, ...data.map(r => this.#formatX(r.x).length));\n const fit = Math.max(2, Math.floor(pw / (longest * 6.5 + 16)));\n const step = Math.max(1, Math.ceil(n / fit));\n for (let i = n - 1; i >= 0; i -= step) {\n out.push(`<text class=\"ar-chart__tick\" x=\"${round(xs[i])}\" y=\"${m.top + ph + 18}\" text-anchor=\"${i === n - 1 && !bars ? 'end' : i === 0 && !bars ? 'start' : 'middle'}\">${esc(this.#formatX(data[i].x))}</text>`);\n }\n }\n\n if (bars && n) {\n const base = y(Math.max(y0, Math.min(0, y1)));\n if (stacked) {\n const w = Math.min(24, band * 0.7);\n data.forEach((row, i) => {\n let top = base;\n const parts = series.map(s => ({ s, v: Math.max(0, this.#value(row, s.key) ?? 0) })).filter(p => p.v > 0);\n parts.forEach((p, j) => {\n const h = (p.v / (y1 - y0 || 1)) * ph;\n const gap = j > 0 ? 2 : 0; // a 2px surface gap between segments\n const yTop = top - h;\n out.push(barPath(xs[i] - w / 2, yTop, w, h - gap, top - gap, j === parts.length - 1, p.s.color));\n top = yTop;\n });\n });\n } else {\n const groupW = Math.min(band * 0.8, 24 * series.length + 2 * (series.length - 1));\n const w = Math.max(2, (groupW - 2 * (series.length - 1)) / series.length);\n data.forEach((row, i) => {\n series.forEach((s, j) => {\n const v = this.#value(row, s.key);\n if (v === null) return;\n const x = xs[i] - groupW / 2 + j * (w + 2);\n const top = y(Math.max(v, 0));\n const bottom = y(Math.min(v, 0));\n out.push(barPath(x, top, w, bottom - top, bottom, true, s.color, v < 0));\n });\n });\n }\n } else {\n for (const s of series) {\n const points = data.map((row, i) => [xs[i], this.#value(row, s.key)] as const).filter((p): p is readonly [number, number] => p[1] !== null);\n if (!points.length) continue;\n const d = points.map(([px, v], i) => `${i ? 'L' : 'M'}${round(px)},${round(y(v))}`).join('');\n if (config.type === 'area') {\n const base = round(y(Math.max(y0, 0)));\n out.push(`<path class=\"ar-chart__area\" style=\"fill:${s.color}\" d=\"${d}L${round(points[points.length - 1][0])},${base}L${round(points[0][0])},${base}Z\"/>`);\n }\n out.push(`<path class=\"ar-chart__line\" style=\"stroke:${s.color}\" d=\"${d}\"/>`);\n // An end dot marks the latest value.\n const [ex, ev] = points[points.length - 1];\n out.push(`<circle class=\"ar-chart__dot\" style=\"fill:${s.color}\" cx=\"${round(ex)}\" cy=\"${round(y(ev))}\" r=\"${config.sparkline ? 2.5 : 4}\"/>`);\n }\n }\n out.push('<g class=\"ar-chart__cursor\"></g>');\n this.#svg.setAttribute('viewBox', `0 0 ${width} ${height}`);\n this.#svg.setAttribute('width', String(width));\n this.#svg.setAttribute('height', String(height));\n this.#svg.innerHTML = out.join('');\n if (!this.#tooltip.hidden) this.#drawReadout(false, true);\n this.#renderTable(series);\n }\n\n #renderTable(series: Array<ChartSeries & { color: string }>): void {\n const config = this.#config!;\n const caption = document.createElement('caption');\n caption.textContent = config.label;\n const head = document.createElement('tr');\n for (const label of [config.x?.type === 'time' ? 'Time' : 'X', ...series.map(s => s.label)]) {\n const th = document.createElement('th');\n th.scope = 'col';\n th.textContent = label;\n head.appendChild(th);\n }\n const rows = this.#data.map(row => {\n const tr = document.createElement('tr');\n const th = document.createElement('th');\n th.scope = 'row';\n th.textContent = this.#formatX(row.x);\n tr.appendChild(th);\n for (const s of series) {\n const td = document.createElement('td');\n const v = this.#value(row, s.key);\n td.textContent = v === null ? '–' : this.#formatY(v);\n tr.appendChild(td);\n }\n return tr;\n });\n const thead = document.createElement('thead');\n thead.appendChild(head);\n const tbody = document.createElement('tbody');\n tbody.append(...rows);\n this.#table.replaceChildren(caption, thead, tbody);\n }\n\n /** Crosshair, dots and tooltip at the current index; `announce` also tells screen readers. */\n #drawReadout(announce: boolean, quiet = false): void {\n const config = this.#config;\n const geo = this.#geo;\n if (!config || !geo || config.sparkline || this.#index < 0 || this.#index >= this.#data.length) return;\n const row = this.#data[this.#index];\n const x = geo.xs[this.#index];\n const series = config.series.map((s, i) => ({ ...s, color: this.#color(s, i) })).filter(s => !this.#hidden.has(s.key));\n const bars = config.type === 'bar' || config.type === 'stacked-bar';\n const cursor = this.#svg.querySelector('.ar-chart__cursor')!;\n const parts: string[] = [];\n if (bars) {\n const band = geo.width / Math.max(1, this.#data.length);\n parts.push(`<rect class=\"ar-chart__band\" x=\"${round(x - band / 2)}\" y=\"${geo.top}\" width=\"${round(band)}\" height=\"${geo.height}\"/>`);\n } else {\n parts.push(`<line class=\"ar-chart__crosshair\" x1=\"${round(x)}\" x2=\"${round(x)}\" y1=\"${geo.top}\" y2=\"${geo.top + geo.height}\"/>`);\n for (const s of series) {\n const v = this.#value(row, s.key);\n if (v !== null) parts.push(`<circle class=\"ar-chart__dot is-hover\" style=\"fill:${s.color}\" cx=\"${round(x)}\" cy=\"${round(geo.y(v))}\" r=\"4.5\"/>`);\n }\n }\n cursor.innerHTML = parts.join('');\n\n // One tooltip, every series: the value leads, the label follows.\n const tip = this.#tooltip;\n const title = document.createElement('p');\n title.className = 'ar-chart__tip-title';\n title.textContent = this.#formatX(row.x);\n const list = document.createElement('dl');\n for (const s of series) {\n const v = this.#value(row, s.key);\n const dt = document.createElement('dt');\n const swatch = document.createElement('span');\n swatch.className = 'ar-chart__swatch';\n swatch.style.background = s.color;\n dt.append(swatch, document.createTextNode(s.label));\n const dd = document.createElement('dd');\n dd.textContent = v === null ? '–' : this.#formatY(v);\n list.append(dt, dd);\n }\n tip.replaceChildren(title, list);\n tip.hidden = false;\n const plotWidth = this.#plot.clientWidth || this.#width;\n const tipWidth = tip.offsetWidth || 160;\n const left = x + 14 + tipWidth > plotWidth ? x - 14 - tipWidth : x + 14;\n tip.style.left = `${Math.max(0, left)}px`;\n tip.style.top = `${geo.top}px`;\n if (announce && !quiet) {\n this.#live.textContent = `${this.#formatX(row.x)}: ${series.map(s => {\n const v = this.#value(row, s.key);\n return `${s.label} ${v === null ? 'no value' : this.#formatY(v)}`;\n }).join(', ')}`;\n }\n }\n\n #hideReadout(): void {\n this.#tooltip.hidden = true;\n const cursor = this.#svg?.querySelector('.ar-chart__cursor');\n if (cursor) cursor.innerHTML = '';\n }\n}\n\n/**\n * A bar with a 4px rounded data end and a square base. `top`/`height` are\n * the bar's extent, `base` the baseline side; `flip` rounds the bottom\n * instead (negative values).\n */\nfunction barPath(x: number, top: number, w: number, h: number, base: number, rounded: boolean, color: string, flip = false): string {\n if (h <= 0) return '';\n const r = rounded ? Math.min(4, w / 2, h) : 0;\n const [l, rgt] = [round(x), round(x + w)];\n if (!flip) {\n const t = round(top);\n const b = round(base);\n return `<path class=\"ar-chart__bar\" style=\"fill:${color}\" d=\"M${l},${b}V${round(t + r)}Q${l},${t} ${round(l + r)},${t}H${round(rgt - r)}Q${rgt},${t} ${rgt},${round(t + r)}V${b}Z\"/>`;\n }\n const t = round(top);\n const b = round(top + h);\n return `<path class=\"ar-chart__bar\" style=\"fill:${color}\" d=\"M${l},${t}V${round(b - r)}Q${l},${b} ${round(l + r)},${b}H${round(rgt - r)}Q${rgt},${b} ${rgt},${round(b - r)}V${t}Z\"/>`;\n}\n\n/** Define `<a-chart>` (idempotent). `import 'arethesis/components/chart'` calls this. */\nexport function defineChart(): void {\n defineComponent({ tag: 'a-chart' })(Chart);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;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