yukit-web 0.10.6 → 0.10.7
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/fesm2022/yukit-web-chart.mjs +807 -552
- package/fesm2022/yukit-web-chart.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-accordion.mjs +271 -100
- package/fesm2022/yukit-web-helm-accordion.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-alert-dialog.mjs +675 -243
- package/fesm2022/yukit-web-helm-alert-dialog.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-alert.mjs +199 -91
- package/fesm2022/yukit-web-helm-alert.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-aspect-ratio.mjs +77 -43
- package/fesm2022/yukit-web-helm-aspect-ratio.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-attachment.mjs +552 -205
- package/fesm2022/yukit-web-helm-attachment.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-autocomplete.mjs +913 -288
- package/fesm2022/yukit-web-helm-autocomplete.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-avatar.mjs +298 -137
- package/fesm2022/yukit-web-helm-avatar.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-badge.mjs +78 -44
- package/fesm2022/yukit-web-helm-badge.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-breadcrumb.mjs +466 -183
- package/fesm2022/yukit-web-helm-breadcrumb.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-bubble.mjs +297 -118
- package/fesm2022/yukit-web-helm-bubble.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-button-group.mjs +179 -83
- package/fesm2022/yukit-web-helm-button-group.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-button.mjs +137 -67
- package/fesm2022/yukit-web-helm-button.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-calendar.mjs +957 -230
- package/fesm2022/yukit-web-helm-calendar.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-card.mjs +318 -136
- package/fesm2022/yukit-web-helm-card.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-carousel.mjs +563 -233
- package/fesm2022/yukit-web-helm-carousel.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-checkbox.mjs +367 -101
- package/fesm2022/yukit-web-helm-checkbox.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-collapsible.mjs +155 -61
- package/fesm2022/yukit-web-helm-collapsible.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-combobox.mjs +1572 -481
- package/fesm2022/yukit-web-helm-combobox.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-command.mjs +752 -260
- package/fesm2022/yukit-web-helm-command.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-context-menu.mjs +161 -63
- package/fesm2022/yukit-web-helm-context-menu.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-date-picker.mjs +2322 -932
- package/fesm2022/yukit-web-helm-date-picker.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-dialog.mjs +625 -240
- package/fesm2022/yukit-web-helm-dialog.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-drawer.mjs +539 -222
- package/fesm2022/yukit-web-helm-drawer.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-dropdown-menu.mjs +1295 -493
- package/fesm2022/yukit-web-helm-dropdown-menu.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-empty.mjs +280 -121
- package/fesm2022/yukit-web-helm-empty.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-field.mjs +670 -301
- package/fesm2022/yukit-web-helm-field.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-hover-card.mjs +198 -99
- package/fesm2022/yukit-web-helm-hover-card.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-input-group.mjs +357 -165
- package/fesm2022/yukit-web-helm-input-group.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-input-otp.mjs +306 -114
- package/fesm2022/yukit-web-helm-input-otp.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-input.mjs +62 -30
- package/fesm2022/yukit-web-helm-input.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-item.mjs +545 -227
- package/fesm2022/yukit-web-helm-item.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-kbd.mjs +85 -44
- package/fesm2022/yukit-web-helm-kbd.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-label.mjs +60 -28
- package/fesm2022/yukit-web-helm-label.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-marker.mjs +165 -74
- package/fesm2022/yukit-web-helm-marker.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-menubar.mjs +207 -82
- package/fesm2022/yukit-web-helm-menubar.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-message.mjs +277 -112
- package/fesm2022/yukit-web-helm-message.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-native-select.mjs +363 -129
- package/fesm2022/yukit-web-helm-native-select.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-navigation-menu.mjs +398 -166
- package/fesm2022/yukit-web-helm-navigation-menu.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-pagination.mjs +1444 -460
- package/fesm2022/yukit-web-helm-pagination.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-popover.mjs +358 -133
- package/fesm2022/yukit-web-helm-popover.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-progress.mjs +126 -58
- package/fesm2022/yukit-web-helm-progress.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-radio-group.mjs +420 -144
- package/fesm2022/yukit-web-helm-radio-group.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-resizable.mjs +210 -91
- package/fesm2022/yukit-web-helm-resizable.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-scroll-area.mjs +64 -34
- package/fesm2022/yukit-web-helm-scroll-area.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-select.mjs +1059 -351
- package/fesm2022/yukit-web-helm-select.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-separator.mjs +61 -31
- package/fesm2022/yukit-web-helm-separator.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-sheet.mjs +590 -231
- package/fesm2022/yukit-web-helm-sheet.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-sidebar.mjs +1781 -757
- package/fesm2022/yukit-web-helm-sidebar.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-skeleton.mjs +45 -27
- package/fesm2022/yukit-web-helm-skeleton.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-slider.mjs +139 -59
- package/fesm2022/yukit-web-helm-slider.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-sonner.mjs +350 -62
- package/fesm2022/yukit-web-helm-sonner.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-spinner.mjs +118 -44
- package/fesm2022/yukit-web-helm-spinner.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-switch.mjs +326 -94
- package/fesm2022/yukit-web-helm-switch.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-table.mjs +374 -177
- package/fesm2022/yukit-web-helm-table.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-tabs.mjs +549 -173
- package/fesm2022/yukit-web-helm-tabs.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-textarea.mjs +62 -30
- package/fesm2022/yukit-web-helm-textarea.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-toggle-group.mjs +291 -89
- package/fesm2022/yukit-web-helm-toggle-group.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-toggle.mjs +132 -57
- package/fesm2022/yukit-web-helm-toggle.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-tooltip.mjs +84 -54
- package/fesm2022/yukit-web-helm-tooltip.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-typography.mjs +461 -202
- package/fesm2022/yukit-web-helm-typography.mjs.map +1 -1
- package/fesm2022/yukit-web-helm-utils.mjs +131 -253
- package/fesm2022/yukit-web-helm-utils.mjs.map +1 -1
- package/fesm2022/yukit-web.mjs +24457 -9670
- package/fesm2022/yukit-web.mjs.map +1 -1
- package/package.json +9 -9
- package/types/yukit-web-chart.d.ts +184 -125
- package/types/yukit-web-helm-accordion.d.ts +49 -28
- package/types/yukit-web-helm-alert-dialog.d.ts +127 -73
- package/types/yukit-web-helm-alert.d.ts +30 -32
- package/types/yukit-web-helm-aspect-ratio.d.ts +17 -15
- package/types/yukit-web-helm-attachment.d.ts +97 -69
- package/types/yukit-web-helm-autocomplete.d.ts +205 -79
- package/types/yukit-web-helm-avatar.d.ts +44 -39
- package/types/yukit-web-helm-badge.d.ts +18 -17
- package/types/yukit-web-helm-breadcrumb.d.ts +69 -45
- package/types/yukit-web-helm-bubble.d.ts +54 -40
- package/types/yukit-web-helm-button-group.d.ts +29 -22
- package/types/yukit-web-helm-button.d.ts +41 -31
- package/types/yukit-web-helm-calendar.d.ts +157 -85
- package/types/yukit-web-helm-card.d.ts +38 -42
- package/types/yukit-web-helm-carousel.d.ts +105 -73
- package/types/yukit-web-helm-checkbox.d.ts +117 -58
- package/types/yukit-web-helm-collapsible.d.ts +34 -19
- package/types/yukit-web-helm-combobox.d.ts +355 -150
- package/types/yukit-web-helm-command.d.ts +140 -73
- package/types/yukit-web-helm-context-menu.d.ts +48 -27
- package/types/yukit-web-helm-date-picker.d.ts +852 -556
- package/types/yukit-web-helm-dialog.d.ts +106 -78
- package/types/yukit-web-helm-drawer.d.ts +90 -61
- package/types/yukit-web-helm-dropdown-menu.d.ts +278 -158
- package/types/yukit-web-helm-empty.d.ts +38 -42
- package/types/yukit-web-helm-field.d.ts +122 -91
- package/types/yukit-web-helm-hover-card.d.ts +39 -27
- package/types/yukit-web-helm-input-group.d.ts +63 -41
- package/types/yukit-web-helm-input-otp.d.ts +38 -35
- package/types/yukit-web-helm-input.d.ts +19 -12
- package/types/yukit-web-helm-item.d.ts +90 -82
- package/types/yukit-web-helm-kbd.d.ts +10 -15
- package/types/yukit-web-helm-label.d.ts +14 -11
- package/types/yukit-web-helm-marker.d.ts +26 -27
- package/types/yukit-web-helm-menubar.d.ts +61 -32
- package/types/yukit-web-helm-message.d.ts +34 -38
- package/types/yukit-web-helm-native-select.d.ts +102 -61
- package/types/yukit-web-helm-navigation-menu.d.ts +76 -42
- package/types/yukit-web-helm-pagination.d.ts +344 -166
- package/types/yukit-web-helm-popover.d.ts +62 -42
- package/types/yukit-web-helm-progress.d.ts +27 -20
- package/types/yukit-web-helm-radio-group.d.ts +121 -63
- package/types/yukit-web-helm-resizable.d.ts +46 -24
- package/types/yukit-web-helm-scroll-area.d.ts +6 -10
- package/types/yukit-web-helm-select.d.ts +231 -114
- package/types/yukit-web-helm-separator.d.ts +15 -12
- package/types/yukit-web-helm-sheet.d.ts +94 -65
- package/types/yukit-web-helm-sidebar.d.ts +322 -232
- package/types/yukit-web-helm-skeleton.d.ts +6 -10
- package/types/yukit-web-helm-slider.d.ts +33 -13
- package/types/yukit-web-helm-sonner.d.ts +112 -51
- package/types/yukit-web-helm-spinner.d.ts +24 -17
- package/types/yukit-web-helm-switch.d.ts +89 -51
- package/types/yukit-web-helm-table.d.ts +38 -42
- package/types/yukit-web-helm-tabs.d.ts +116 -60
- package/types/yukit-web-helm-textarea.d.ts +19 -12
- package/types/yukit-web-helm-toggle-group.d.ts +81 -32
- package/types/yukit-web-helm-toggle.d.ts +39 -21
- package/types/yukit-web-helm-tooltip.d.ts +21 -16
- package/types/yukit-web-helm-typography.d.ts +62 -77
- package/types/yukit-web-helm-utils.d.ts +8 -11
- package/types/yukit-web.d.ts +5092 -2351
|
@@ -1,650 +1,905 @@
|
|
|
1
|
-
import { _IdGenerator } from
|
|
2
|
-
import * as i0 from
|
|
3
|
-
import {
|
|
4
|
-
import { HlmSkeleton } from
|
|
5
|
-
import { hlm } from
|
|
6
|
-
import { area, curveMonotoneX, curveMonotoneY,
|
|
7
|
-
import { scaleBand,
|
|
8
|
-
|
|
9
|
-
/** Every chart token, in palette order. */
|
|
1
|
+
import { _IdGenerator } from "@angular/cdk/a11y";
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
import { ChangeDetectionStrategy, Component, DestroyRef, afterNextRender, booleanAttribute, computed, inject, input, linkedSignal, signal, viewChild } from "@angular/core";
|
|
4
|
+
import { HlmSkeleton } from "yukit-web/helm/skeleton";
|
|
5
|
+
import { hlm } from "yukit-web/helm/utils";
|
|
6
|
+
import { arc, area, curveMonotoneX, curveMonotoneY, line, pie, stack, stackOffsetDiverging, stackOffsetNone } from "d3-shape";
|
|
7
|
+
import { scaleBand, scaleLinear, scalePoint } from "d3-scale";
|
|
10
8
|
const YUW_CHART_COLORS = [
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
"chart-1",
|
|
10
|
+
"chart-2",
|
|
11
|
+
"chart-3",
|
|
12
|
+
"chart-4",
|
|
13
|
+
"chart-5",
|
|
14
|
+
"chart-6",
|
|
15
|
+
"chart-7",
|
|
16
|
+
"chart-8"
|
|
19
17
|
];
|
|
20
|
-
/** Color token of the series at `index`, cycling through the palette: builds a config for a dynamic set of series. */
|
|
21
18
|
function yuwChartColorAt(index) {
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
const count = YUW_CHART_COLORS.length;
|
|
20
|
+
return YUW_CHART_COLORS[(index % count + count) % count];
|
|
24
21
|
}
|
|
25
|
-
|
|
26
|
-
/** Average advance of a glyph at the `text-xs` size axis labels use, to reserve room without measuring text. */
|
|
27
|
-
const CHART_CHAR_WIDTH = 7;
|
|
28
22
|
function cssColor(color) {
|
|
29
|
-
|
|
23
|
+
return `var(--${color})`;
|
|
30
24
|
}
|
|
31
25
|
function seriesOf(config) {
|
|
32
|
-
|
|
26
|
+
return Object.entries(config).map(([key, series]) => ({
|
|
27
|
+
key,
|
|
28
|
+
label: series.label,
|
|
29
|
+
color: cssColor(series.color)
|
|
30
|
+
}));
|
|
33
31
|
}
|
|
34
|
-
/** A finite number, or `null` for anything else: a missing value is a gap, never a zero. */
|
|
35
32
|
function valueOf(row, key) {
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
const value = row[key];
|
|
34
|
+
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
38
35
|
}
|
|
39
36
|
function textWidth(labels) {
|
|
40
|
-
|
|
37
|
+
return labels.reduce((widest, label) => Math.max(widest, label.length), 0) * 7;
|
|
41
38
|
}
|
|
42
39
|
function rectPath(x, y, width, height, radius = 0) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
`a${r},${r} 0 0 1 ${-r},${r}h${2 * r - width}a${r},${r} 0 0 1 ${-r},${-r}` +
|
|
46
|
-
`v${2 * r - height}a${r},${r} 0 0 1 ${r},${-r}Z`);
|
|
40
|
+
const r = Math.max(0, Math.min(radius, width / 2, height / 2));
|
|
41
|
+
return `M${x + r},${y}h${width - 2 * r}a${r},${r} 0 0 1 ${r},${r}v${height - 2 * r}a${r},${r} 0 0 1 ${-r},${r}h${2 * r - width}a${r},${r} 0 0 1 ${-r},${-r}v${2 * r - height}a${r},${r} 0 0 1 ${r},${-r}Z`;
|
|
47
42
|
}
|
|
48
43
|
function emptyScene(table) {
|
|
49
|
-
|
|
44
|
+
return {
|
|
45
|
+
cursorPaint: "band",
|
|
46
|
+
empty: true,
|
|
47
|
+
grid: [],
|
|
48
|
+
hits: [],
|
|
49
|
+
marks: [],
|
|
50
|
+
origin: {
|
|
51
|
+
x: 0,
|
|
52
|
+
y: 0
|
|
53
|
+
},
|
|
54
|
+
table,
|
|
55
|
+
ticks: []
|
|
56
|
+
};
|
|
50
57
|
}
|
|
51
|
-
|
|
52
58
|
const LABEL_GAP = 8;
|
|
53
59
|
const AXIS_ROOM = 24;
|
|
54
60
|
const LINE_HEIGHT = 16;
|
|
55
61
|
const MAX_VALUE_TICKS = 5;
|
|
56
62
|
function tickCount(length, room) {
|
|
57
|
-
|
|
63
|
+
return Math.max(2, Math.min(MAX_VALUE_TICKS, Math.floor(length / room)));
|
|
58
64
|
}
|
|
59
65
|
const VERTICAL = {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
66
|
+
curve: curveMonotoneX,
|
|
67
|
+
anchor: (plot, category) => ({
|
|
68
|
+
x: category,
|
|
69
|
+
y: (plot.top + plot.bottom) / 2
|
|
70
|
+
}),
|
|
71
|
+
area: (spans) => area().x((span) => span.category).y0((span) => span.base).y1((span) => span.top).curve(curveMonotoneX)(spans) ?? "",
|
|
72
|
+
band: (plot, start, end) => rectPath(start, plot.top, end - start, plot.bottom - plot.top),
|
|
73
|
+
bar: (category, size, base, top, radius) => rectPath(category, Math.min(base, top), size, Math.abs(base - top), radius),
|
|
74
|
+
categoryLabelChars: () => Number.POSITIVE_INFINITY,
|
|
75
|
+
categoryLabelRoom: (categoryLabelWidth) => categoryLabelWidth + LABEL_GAP,
|
|
76
|
+
categoryRange: (plot) => [plot.left, plot.right],
|
|
77
|
+
categoryTick: (plot, category, label) => ({
|
|
78
|
+
anchor: "middle",
|
|
79
|
+
label,
|
|
80
|
+
x: category,
|
|
81
|
+
y: plot.bottom + AXIS_ROOM - 6
|
|
82
|
+
}),
|
|
83
|
+
cursor: (plot, category) => `M${category},${plot.top}V${plot.bottom}`,
|
|
84
|
+
grid: (plot, value) => `M${plot.left},${value}H${plot.right}`,
|
|
85
|
+
margins: (_width, valueLabelWidth) => ({
|
|
86
|
+
top: LABEL_GAP,
|
|
87
|
+
right: LABEL_GAP,
|
|
88
|
+
bottom: AXIS_ROOM,
|
|
89
|
+
left: valueLabelWidth + LABEL_GAP
|
|
90
|
+
}),
|
|
91
|
+
point: (category, value) => [category, value],
|
|
92
|
+
valueRange: (plot) => [plot.bottom, plot.top],
|
|
93
|
+
valueTick: (plot, value, label) => ({
|
|
94
|
+
anchor: "end",
|
|
95
|
+
label,
|
|
96
|
+
x: plot.left - LABEL_GAP,
|
|
97
|
+
y: value
|
|
98
|
+
}),
|
|
99
|
+
valueTickCount: (plot) => tickCount(plot.bottom - plot.top, 32)
|
|
85
100
|
};
|
|
86
101
|
const HORIZONTAL = {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
102
|
+
curve: curveMonotoneY,
|
|
103
|
+
anchor: (plot, category) => ({
|
|
104
|
+
x: plot.right,
|
|
105
|
+
y: category
|
|
106
|
+
}),
|
|
107
|
+
area: (spans) => area().y((span) => span.category).x0((span) => span.base).x1((span) => span.top).curve(curveMonotoneY)(spans) ?? "",
|
|
108
|
+
band: (plot, start, end) => rectPath(plot.left, start, plot.right - plot.left, end - start),
|
|
109
|
+
bar: (category, size, base, top, radius) => rectPath(Math.min(base, top), category, Math.abs(base - top), size, radius),
|
|
110
|
+
categoryLabelChars: (margins) => Math.max(1, Math.floor((margins.left - LABEL_GAP) / 7)),
|
|
111
|
+
categoryLabelRoom: () => LINE_HEIGHT,
|
|
112
|
+
categoryRange: (plot) => [plot.top, plot.bottom],
|
|
113
|
+
categoryTick: (plot, category, label) => ({
|
|
114
|
+
anchor: "end",
|
|
115
|
+
label,
|
|
116
|
+
x: plot.left - LABEL_GAP,
|
|
117
|
+
y: category
|
|
118
|
+
}),
|
|
119
|
+
cursor: (plot, category) => `M${plot.left},${category}H${plot.right}`,
|
|
120
|
+
grid: (plot, value) => `M${value},${plot.top}V${plot.bottom}`,
|
|
121
|
+
margins: (width, valueLabelWidth, categoryLabelWidth) => ({
|
|
122
|
+
top: LABEL_GAP,
|
|
123
|
+
right: Math.max(LABEL_GAP, valueLabelWidth / 2),
|
|
124
|
+
bottom: AXIS_ROOM,
|
|
125
|
+
left: Math.min(categoryLabelWidth, width * .4) + LABEL_GAP
|
|
126
|
+
}),
|
|
127
|
+
point: (category, value) => [value, category],
|
|
128
|
+
valueRange: (plot) => [plot.left, plot.right],
|
|
129
|
+
valueTick: (plot, value, label) => ({
|
|
130
|
+
anchor: "middle",
|
|
131
|
+
label,
|
|
132
|
+
x: value,
|
|
133
|
+
y: plot.bottom + AXIS_ROOM - 6
|
|
134
|
+
}),
|
|
135
|
+
valueTickCount: (plot, valueLabelWidth) => tickCount(plot.right - plot.left, valueLabelWidth + 16)
|
|
112
136
|
};
|
|
113
|
-
|
|
114
137
|
function extentWithZero(values) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
138
|
+
const ends = values.flat().flatMap((value) => value ? [value.base, value.top] : []);
|
|
139
|
+
const min = Math.min(0, ...ends);
|
|
140
|
+
const max = Math.max(0, ...ends);
|
|
141
|
+
return [min, max === min ? min + 1 : max];
|
|
119
142
|
}
|
|
120
|
-
/** Every series starts from zero. */
|
|
121
143
|
const sideBySide = (rows, keys) => {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
144
|
+
const columns = keys.map((key) => rows.map((row) => {
|
|
145
|
+
const value = valueOf(row, key);
|
|
146
|
+
return value === null ? null : {
|
|
147
|
+
base: 0,
|
|
148
|
+
top: value,
|
|
149
|
+
value
|
|
150
|
+
};
|
|
151
|
+
}));
|
|
152
|
+
return {
|
|
153
|
+
domain: extentWithZero(columns),
|
|
154
|
+
byKey: new Map(keys.map((key, index) => [key, columns[index]]))
|
|
155
|
+
};
|
|
127
156
|
};
|
|
128
|
-
/** Each series starts where the previous one ended, following `offset`. */
|
|
129
157
|
function stackedBy(offset) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
158
|
+
return (rows, keys) => {
|
|
159
|
+
const columns = stack().keys(keys).value((row, key) => valueOf(row, key) ?? 0).offset(offset)(rows).map((layer) => layer.map(([base, top], index) => ({
|
|
160
|
+
base,
|
|
161
|
+
top,
|
|
162
|
+
value: valueOf(rows[index], layer.key)
|
|
163
|
+
})));
|
|
164
|
+
return {
|
|
165
|
+
domain: extentWithZero(columns),
|
|
166
|
+
byKey: new Map(keys.map((key, index) => [key, columns[index]]))
|
|
167
|
+
};
|
|
168
|
+
};
|
|
138
169
|
}
|
|
139
|
-
/** A continuous stack, so an area keeps its height where a series holds nothing. */
|
|
140
170
|
const stacked = stackedBy(stackOffsetNone);
|
|
141
|
-
/** Positive values stack upwards and negative ones downwards from zero, as bars need. */
|
|
142
171
|
const stackedDiverging = stackedBy(stackOffsetDiverging);
|
|
143
|
-
|
|
144
172
|
const VALUE_TICKS = 5;
|
|
145
173
|
const BAR_RADIUS = 4;
|
|
146
|
-
/** What highlights the active category: its whole band behind bars, a rule across lines and areas. */
|
|
147
174
|
const CURSORS = {
|
|
148
|
-
|
|
149
|
-
|
|
175
|
+
band: (orientation, plot, start, end) => orientation.band(plot, start, end),
|
|
176
|
+
line: (orientation, plot, _start, _end, center) => orientation.cursor(plot, center)
|
|
150
177
|
};
|
|
151
|
-
/** Categories as bands, so bars have a width. */
|
|
152
178
|
const bands = (count, range) => {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
179
|
+
const scale = scaleBand().domain(indices(count)).range(range).paddingInner(.2).paddingOuter(.1);
|
|
180
|
+
const starts = indices(count).map((index) => scale(index) ?? 0);
|
|
181
|
+
return {
|
|
182
|
+
starts,
|
|
183
|
+
size: scale.bandwidth(),
|
|
184
|
+
centers: starts.map((start) => start + scale.bandwidth() / 2)
|
|
185
|
+
};
|
|
156
186
|
};
|
|
157
|
-
/** Categories as points spanning the whole axis, so lines reach both edges. */
|
|
158
187
|
const points = (count, range) => {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
188
|
+
const scale = scalePoint().domain(indices(count)).range(range);
|
|
189
|
+
const centers = indices(count).map((index) => scale(index) ?? 0);
|
|
190
|
+
return {
|
|
191
|
+
starts: centers,
|
|
192
|
+
size: 0,
|
|
193
|
+
centers
|
|
194
|
+
};
|
|
162
195
|
};
|
|
163
|
-
/** Bars of every series side by side inside the category band. */
|
|
164
196
|
const groupedBars = {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
paint: 'fill',
|
|
178
|
-
})));
|
|
179
|
-
},
|
|
197
|
+
cursor: "band",
|
|
198
|
+
points: false,
|
|
199
|
+
marks: ({ categories, orientation, scale, series, values }) => {
|
|
200
|
+
const inner = scaleBand().domain(series.map((item) => item.key)).range([0, categories.size]).padding(.1);
|
|
201
|
+
return series.flatMap((item) => barsOf(values, item).map(({ index, value }) => ({
|
|
202
|
+
color: item.color,
|
|
203
|
+
d: orientation.bar(categories.starts[index] + (inner(item.key) ?? 0), inner.bandwidth(), scale(value.base), scale(value.top), BAR_RADIUS),
|
|
204
|
+
hit: index,
|
|
205
|
+
key: item.key,
|
|
206
|
+
paint: "fill"
|
|
207
|
+
})));
|
|
208
|
+
}
|
|
180
209
|
};
|
|
181
|
-
/** One bar per category, each series a segment of it. */
|
|
182
210
|
const stackedBars = {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
211
|
+
cursor: "band",
|
|
212
|
+
points: false,
|
|
213
|
+
marks: ({ categories, orientation, scale, series, values }) => series.flatMap((item) => barsOf(values, item).map(({ index, value }) => ({
|
|
214
|
+
color: item.color,
|
|
215
|
+
d: orientation.bar(categories.starts[index], categories.size, scale(value.base), scale(value.top), 0),
|
|
216
|
+
hit: index,
|
|
217
|
+
key: item.key,
|
|
218
|
+
paint: "fill"
|
|
219
|
+
})))
|
|
192
220
|
};
|
|
193
221
|
const lines = {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
222
|
+
cursor: "line",
|
|
223
|
+
points: true,
|
|
224
|
+
marks: (frame) => frame.series.map((item) => strokeOf(frame, item))
|
|
197
225
|
};
|
|
198
|
-
/** A translucent band under each series, outlined by its line. */
|
|
199
226
|
const areas = {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
},
|
|
210
|
-
strokeOf(frame, item),
|
|
211
|
-
]),
|
|
227
|
+
cursor: "line",
|
|
228
|
+
points: true,
|
|
229
|
+
marks: (frame) => frame.series.flatMap((item) => [{
|
|
230
|
+
color: item.color,
|
|
231
|
+
d: frame.orientation.area(spansOf(frame, item)),
|
|
232
|
+
hit: null,
|
|
233
|
+
key: item.key,
|
|
234
|
+
paint: "area"
|
|
235
|
+
}, strokeOf(frame, item)])
|
|
212
236
|
};
|
|
213
|
-
/** A bar, line or area chart: the categories along one axis, the values along the other. */
|
|
214
237
|
function cartesianLayout(options) {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
return sceneOf(options, input, series, table);
|
|
222
|
-
};
|
|
238
|
+
return (input) => {
|
|
239
|
+
const series = seriesOf(input.config);
|
|
240
|
+
const table = tableOf$1(input, series);
|
|
241
|
+
if (input.data.length === 0 || series.length === 0) return emptyScene(table);
|
|
242
|
+
return sceneOf(options, input, series, table);
|
|
243
|
+
};
|
|
223
244
|
}
|
|
224
245
|
function sceneOf(options, input, series, table) {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
246
|
+
const { orientation } = options;
|
|
247
|
+
const values = options.values(input.data, series.map((item) => item.key));
|
|
248
|
+
const value = scaleLinear().domain(values.domain).nice();
|
|
249
|
+
const labelWidth = textWidth(value.ticks(VALUE_TICKS).map((tick) => input.valueFormat(tick)));
|
|
250
|
+
const titles = input.data.map((row) => titleOf(input, row));
|
|
251
|
+
const margins = orientation.margins(input.width, labelWidth, textWidth(titles));
|
|
252
|
+
const plot = {
|
|
253
|
+
top: margins.top,
|
|
254
|
+
left: margins.left,
|
|
255
|
+
right: Math.max(margins.left + 1, input.width - margins.right),
|
|
256
|
+
bottom: Math.max(margins.top + 1, input.height - margins.bottom)
|
|
257
|
+
};
|
|
258
|
+
const tickCount = orientation.valueTickCount(plot, labelWidth);
|
|
259
|
+
const candidates = value.ticks(tickCount);
|
|
260
|
+
const tickValues = candidates.filter((_tick, index) => index % Math.ceil(candidates.length / tickCount) === 0);
|
|
261
|
+
const valueLabels = tickValues.map((tick) => input.valueFormat(tick));
|
|
262
|
+
const scale = value.range(orientation.valueRange(plot));
|
|
263
|
+
const range = orientation.categoryRange(plot);
|
|
264
|
+
const categories = options.categories(input.data.length, range);
|
|
265
|
+
const frame = {
|
|
266
|
+
categories,
|
|
267
|
+
orientation,
|
|
268
|
+
scale,
|
|
269
|
+
series,
|
|
270
|
+
values
|
|
271
|
+
};
|
|
272
|
+
const boundaries = boundariesOf(categories.centers, range);
|
|
273
|
+
return {
|
|
274
|
+
cursorPaint: options.marks.cursor,
|
|
275
|
+
empty: false,
|
|
276
|
+
grid: tickValues.map((tick) => orientation.grid(plot, scale(tick))),
|
|
277
|
+
hits: categories.centers.map((center, index) => ({
|
|
278
|
+
anchor: orientation.anchor(plot, center),
|
|
279
|
+
cursor: CURSORS[options.marks.cursor](orientation, plot, boundaries[index], boundaries[index + 1], center),
|
|
280
|
+
d: orientation.band(plot, boundaries[index], boundaries[index + 1]),
|
|
281
|
+
points: options.marks.points ? pointsOf(frame, index) : [],
|
|
282
|
+
tooltip: tooltipOf(input, series, values, index, titles[index])
|
|
283
|
+
})),
|
|
284
|
+
marks: options.marks.marks(frame),
|
|
285
|
+
origin: {
|
|
286
|
+
x: 0,
|
|
287
|
+
y: 0
|
|
288
|
+
},
|
|
289
|
+
table,
|
|
290
|
+
ticks: [...tickValues.map((tick, index) => orientation.valueTick(plot, scale(tick), valueLabels[index])), ...categoryTicksOf(orientation, plot, margins, categories.centers, range, titles)]
|
|
291
|
+
};
|
|
265
292
|
}
|
|
266
293
|
function categoryTicksOf(orientation, plot, margins, centers, range, titles) {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
.map((center, index) => orientation.categoryTick(plot, center, truncate(titles[index], chars)))
|
|
272
|
-
.filter((_tick, index) => index % every === 0);
|
|
294
|
+
const step = Math.abs(range[1] - range[0]) / Math.max(1, centers.length);
|
|
295
|
+
const every = Math.max(1, Math.ceil(orientation.categoryLabelRoom(textWidth(titles)) / Math.max(step, 1)));
|
|
296
|
+
const chars = orientation.categoryLabelChars(margins);
|
|
297
|
+
return centers.map((center, index) => orientation.categoryTick(plot, center, truncate(titles[index], chars))).filter((_tick, index) => index % every === 0);
|
|
273
298
|
}
|
|
274
299
|
function pointsOf({ categories, orientation, scale, series, values }, index) {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
300
|
+
return series.flatMap((item) => {
|
|
301
|
+
const value = values.byKey.get(item.key)?.[index];
|
|
302
|
+
if (!value || value.value === null) return [];
|
|
303
|
+
const [cx, cy] = orientation.point(categories.centers[index], scale(value.top));
|
|
304
|
+
return [{
|
|
305
|
+
color: item.color,
|
|
306
|
+
cx,
|
|
307
|
+
cy,
|
|
308
|
+
key: item.key
|
|
309
|
+
}];
|
|
310
|
+
});
|
|
283
311
|
}
|
|
284
312
|
function strokeOf({ categories, orientation, scale, values }, item) {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
313
|
+
const coordinates = (values.byKey.get(item.key) ?? []).map((value, index) => value ? orientation.point(categories.centers[index], scale(value.top)) : null);
|
|
314
|
+
const path = line().defined((point) => point !== null).x((point) => point?.[0] ?? 0).y((point) => point?.[1] ?? 0).curve(orientation.curve);
|
|
315
|
+
return {
|
|
316
|
+
color: item.color,
|
|
317
|
+
d: path(coordinates) ?? "",
|
|
318
|
+
hit: null,
|
|
319
|
+
key: item.key,
|
|
320
|
+
paint: "stroke"
|
|
321
|
+
};
|
|
292
322
|
}
|
|
293
323
|
function spansOf({ categories, scale, values }, item) {
|
|
294
|
-
|
|
324
|
+
return (values.byKey.get(item.key) ?? []).flatMap((value, index) => value ? [{
|
|
325
|
+
base: scale(value.base),
|
|
326
|
+
category: categories.centers[index],
|
|
327
|
+
top: scale(value.top)
|
|
328
|
+
}] : []);
|
|
295
329
|
}
|
|
296
330
|
function barsOf(values, item) {
|
|
297
|
-
|
|
331
|
+
return (values.byKey.get(item.key) ?? []).flatMap((value, index) => value && value.value !== null && value.base !== value.top ? [{
|
|
332
|
+
index,
|
|
333
|
+
value
|
|
334
|
+
}] : []);
|
|
298
335
|
}
|
|
299
336
|
function tooltipOf(input, series, values, index, title) {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
337
|
+
return {
|
|
338
|
+
title: input.categoryKey === void 0 ? null : title,
|
|
339
|
+
items: series.flatMap((item) => {
|
|
340
|
+
const value = values.byKey.get(item.key)?.[index]?.value ?? null;
|
|
341
|
+
return value === null ? [] : [{
|
|
342
|
+
color: item.color,
|
|
343
|
+
key: item.key,
|
|
344
|
+
label: item.label,
|
|
345
|
+
value: input.valueFormat(value)
|
|
346
|
+
}];
|
|
347
|
+
})
|
|
348
|
+
};
|
|
309
349
|
}
|
|
310
350
|
function tableOf$1(input, series) {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
351
|
+
return {
|
|
352
|
+
corner: input.categoryLabel ?? "",
|
|
353
|
+
head: series.map((item) => item.label),
|
|
354
|
+
rows: input.data.map((row) => ({
|
|
355
|
+
header: titleOf(input, row),
|
|
356
|
+
cells: series.map((item) => {
|
|
357
|
+
const value = valueOf(row, item.key);
|
|
358
|
+
return value === null ? "" : input.valueFormat(value);
|
|
359
|
+
})
|
|
360
|
+
}))
|
|
361
|
+
};
|
|
322
362
|
}
|
|
323
363
|
function titleOf(input, row) {
|
|
324
|
-
|
|
364
|
+
return input.categoryKey === void 0 ? "" : input.categoryFormat(row[input.categoryKey]);
|
|
325
365
|
}
|
|
326
|
-
/** Edges between consecutive categories, so every pixel of the axis activates the nearest one. */
|
|
327
366
|
function boundariesOf(centers, range) {
|
|
328
|
-
|
|
329
|
-
|
|
367
|
+
const middles = centers.slice(1).map((center, index) => (centers[index] + center) / 2);
|
|
368
|
+
return [
|
|
369
|
+
range[0],
|
|
370
|
+
...middles,
|
|
371
|
+
range[1]
|
|
372
|
+
];
|
|
330
373
|
}
|
|
331
374
|
function truncate(label, chars) {
|
|
332
|
-
|
|
375
|
+
return label.length > chars ? `${label.slice(0, Math.max(1, chars - 1))}…` : label;
|
|
333
376
|
}
|
|
334
377
|
function indices(count) {
|
|
335
|
-
|
|
378
|
+
return Array.from({ length: count }, (_, index) => index);
|
|
336
379
|
}
|
|
337
|
-
|
|
338
380
|
const EDGE = 4;
|
|
339
|
-
/** One slice per series, sized by its value summed across every row. */
|
|
340
381
|
function pieLayout(options) {
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
table,
|
|
393
|
-
ticks: [],
|
|
394
|
-
};
|
|
395
|
-
};
|
|
382
|
+
return (input) => {
|
|
383
|
+
const slices = slicesOf(input);
|
|
384
|
+
const table = tableOf(input, slices);
|
|
385
|
+
const shown = slices.filter((slice) => slice.total > 0);
|
|
386
|
+
if (shown.length === 0) return emptyScene(table);
|
|
387
|
+
const radius = Math.max(1, Math.min(input.width, input.height) / 2 - EDGE);
|
|
388
|
+
const centerX = input.width / 2;
|
|
389
|
+
const centerY = input.height / 2;
|
|
390
|
+
const arcs = pie().sort(null).value((slice) => slice.total)(shown);
|
|
391
|
+
const shape = arc().innerRadius(radius * options.hole).outerRadius(radius).padAngle(options.hole > 0 ? .01 : 0).cornerRadius(options.hole > 0 ? 3 : 0);
|
|
392
|
+
const paths = arcs.map((datum) => shape(datum) ?? "");
|
|
393
|
+
return {
|
|
394
|
+
cursorPaint: "band",
|
|
395
|
+
empty: false,
|
|
396
|
+
grid: [],
|
|
397
|
+
origin: {
|
|
398
|
+
x: centerX,
|
|
399
|
+
y: centerY
|
|
400
|
+
},
|
|
401
|
+
hits: arcs.map((datum, index) => {
|
|
402
|
+
const [x, y] = shape.centroid(datum);
|
|
403
|
+
return {
|
|
404
|
+
anchor: {
|
|
405
|
+
x: centerX + x,
|
|
406
|
+
y: centerY + y
|
|
407
|
+
},
|
|
408
|
+
cursor: null,
|
|
409
|
+
d: paths[index],
|
|
410
|
+
points: [],
|
|
411
|
+
tooltip: {
|
|
412
|
+
title: null,
|
|
413
|
+
items: [{
|
|
414
|
+
color: datum.data.color,
|
|
415
|
+
key: datum.data.key,
|
|
416
|
+
label: datum.data.label,
|
|
417
|
+
value: input.valueFormat(datum.data.total)
|
|
418
|
+
}]
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
}),
|
|
422
|
+
marks: arcs.map((datum, index) => ({
|
|
423
|
+
color: datum.data.color,
|
|
424
|
+
d: paths[index],
|
|
425
|
+
hit: index,
|
|
426
|
+
key: datum.data.key,
|
|
427
|
+
paint: "fill"
|
|
428
|
+
})),
|
|
429
|
+
table,
|
|
430
|
+
ticks: []
|
|
431
|
+
};
|
|
432
|
+
};
|
|
396
433
|
}
|
|
397
434
|
function slicesOf(input) {
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
435
|
+
return seriesOf(input.config).map((series) => ({
|
|
436
|
+
...series,
|
|
437
|
+
total: input.data.reduce((sum, row) => sum + Math.max(0, valueOf(row, series.key) ?? 0), 0)
|
|
438
|
+
}));
|
|
402
439
|
}
|
|
403
440
|
function tableOf(input, slices) {
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
441
|
+
return {
|
|
442
|
+
corner: null,
|
|
443
|
+
head: slices.map((slice) => slice.label),
|
|
444
|
+
rows: input.data.length === 0 ? [] : [{
|
|
445
|
+
header: null,
|
|
446
|
+
cells: slices.map((slice) => input.valueFormat(slice.total))
|
|
447
|
+
}]
|
|
448
|
+
};
|
|
409
449
|
}
|
|
410
|
-
|
|
411
|
-
/** The layout drawing each chart kind. A new kind is one entry here, built from the same parts. */
|
|
412
450
|
const YUW_CHART_LAYOUTS = {
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
451
|
+
area: cartesianLayout({
|
|
452
|
+
categories: points,
|
|
453
|
+
marks: areas,
|
|
454
|
+
orientation: VERTICAL,
|
|
455
|
+
values: sideBySide
|
|
456
|
+
}),
|
|
457
|
+
"area-stacked": cartesianLayout({
|
|
458
|
+
categories: points,
|
|
459
|
+
marks: areas,
|
|
460
|
+
orientation: VERTICAL,
|
|
461
|
+
values: stacked
|
|
462
|
+
}),
|
|
463
|
+
bar: cartesianLayout({
|
|
464
|
+
categories: bands,
|
|
465
|
+
marks: groupedBars,
|
|
466
|
+
orientation: VERTICAL,
|
|
467
|
+
values: sideBySide
|
|
468
|
+
}),
|
|
469
|
+
"bar-horizontal": cartesianLayout({
|
|
470
|
+
categories: bands,
|
|
471
|
+
marks: groupedBars,
|
|
472
|
+
orientation: HORIZONTAL,
|
|
473
|
+
values: sideBySide
|
|
474
|
+
}),
|
|
475
|
+
"bar-horizontal-stacked": cartesianLayout({
|
|
476
|
+
categories: bands,
|
|
477
|
+
marks: stackedBars,
|
|
478
|
+
orientation: HORIZONTAL,
|
|
479
|
+
values: stackedDiverging
|
|
480
|
+
}),
|
|
481
|
+
"bar-stacked": cartesianLayout({
|
|
482
|
+
categories: bands,
|
|
483
|
+
marks: stackedBars,
|
|
484
|
+
orientation: VERTICAL,
|
|
485
|
+
values: stackedDiverging
|
|
486
|
+
}),
|
|
487
|
+
donut: pieLayout({ hole: .6 }),
|
|
488
|
+
line: cartesianLayout({
|
|
489
|
+
categories: points,
|
|
490
|
+
marks: lines,
|
|
491
|
+
orientation: VERTICAL,
|
|
492
|
+
values: sideBySide
|
|
493
|
+
}),
|
|
494
|
+
pie: pieLayout({ hole: 0 })
|
|
495
|
+
};
|
|
496
|
+
const UNMEASURED = {
|
|
497
|
+
height: 0,
|
|
498
|
+
width: 0
|
|
437
499
|
};
|
|
438
|
-
|
|
439
|
-
const UNMEASURED = { height: 0, width: 0 };
|
|
440
|
-
/**
|
|
441
|
-
* Tracks the content box of `element` as a signal. Stays at zero on the server and wherever `ResizeObserver` is
|
|
442
|
-
* missing, so nothing is drawn until there is a real box to draw into. Must be called in an injection context.
|
|
443
|
-
*/
|
|
444
500
|
function injectChartSize(element) {
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
501
|
+
const size = signal(UNMEASURED, {
|
|
502
|
+
...ngDevMode ? { debugName: "size" } : /* istanbul ignore next */ {},
|
|
503
|
+
equal: (a, b) => a.width === b.width && a.height === b.height
|
|
504
|
+
});
|
|
505
|
+
const destroyRef = inject(DestroyRef);
|
|
506
|
+
afterNextRender(() => {
|
|
507
|
+
const target = element()?.nativeElement;
|
|
508
|
+
if (!target || typeof ResizeObserver === "undefined") return;
|
|
509
|
+
const observer = new ResizeObserver(([entry]) => size.set({
|
|
510
|
+
width: Math.floor(entry.contentRect.width),
|
|
511
|
+
height: Math.floor(entry.contentRect.height)
|
|
512
|
+
}));
|
|
513
|
+
observer.observe(target);
|
|
514
|
+
destroyRef.onDestroy(() => observer.disconnect());
|
|
515
|
+
});
|
|
516
|
+
return size.asReadonly();
|
|
457
517
|
}
|
|
458
|
-
|
|
459
|
-
/** Classes of each kind of mark; the color arrives separately, as a `var(--chart-n)` style. */
|
|
460
518
|
const MARK_CLASS = {
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
519
|
+
area: "opacity-30",
|
|
520
|
+
fill: "stroke-background stroke-1 motion-safe:transition-opacity motion-safe:duration-150",
|
|
521
|
+
stroke: "fill-none stroke-2"
|
|
464
522
|
};
|
|
465
|
-
/** Which style property carries the color of each kind of mark. */
|
|
466
523
|
const MARK_COLOR_PROPERTY = {
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
524
|
+
area: "fill",
|
|
525
|
+
fill: "fill",
|
|
526
|
+
stroke: "stroke"
|
|
470
527
|
};
|
|
471
|
-
const MARK_DIMMED_CLASS = 'opacity-40';
|
|
472
528
|
const CURSOR_CLASS = {
|
|
473
|
-
|
|
474
|
-
|
|
529
|
+
band: "fill-muted",
|
|
530
|
+
line: "fill-none stroke-border stroke-1"
|
|
475
531
|
};
|
|
476
|
-
/** Which side of its anchor the tooltip opens to, so it stays inside the plot. */
|
|
477
532
|
const TOOLTIP_SIDE_CLASS = {
|
|
478
|
-
|
|
479
|
-
|
|
533
|
+
left: "-translate-x-[calc(100%+0.75rem)]",
|
|
534
|
+
right: "translate-x-3"
|
|
480
535
|
};
|
|
481
|
-
/** What each key does to the active position, given it and how many there are; `null` hides the tooltip. */
|
|
482
536
|
const KEY_MOVES = {
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
537
|
+
ArrowDown: (active, count) => Math.min(active + 1, count - 1),
|
|
538
|
+
ArrowLeft: (active) => Math.max(active - 1, 0),
|
|
539
|
+
ArrowRight: (active, count) => Math.min(active + 1, count - 1),
|
|
540
|
+
ArrowUp: (active) => Math.max(active - 1, 0),
|
|
541
|
+
End: (_active, count) => count - 1,
|
|
542
|
+
Escape: () => null,
|
|
543
|
+
Home: () => 0
|
|
490
544
|
};
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
*/
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
545
|
+
var YuwChartComponent = class YuwChartComponent {
|
|
546
|
+
constructor() {
|
|
547
|
+
this._id = inject(_IdGenerator).getId("yuw-chart-");
|
|
548
|
+
this._plot = viewChild("plot", ...ngDevMode ? [{ debugName: "_plot" }] : /* istanbul ignore next */ []);
|
|
549
|
+
this.ariaLabel = input.required(...ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []);
|
|
550
|
+
this.categoryFormat = input(String, ...ngDevMode ? [{ debugName: "categoryFormat" }] : /* istanbul ignore next */ []);
|
|
551
|
+
this.categoryKey = input(...ngDevMode ? [void 0, { debugName: "categoryKey" }] : /* istanbul ignore next */ []);
|
|
552
|
+
this.categoryLabel = input(...ngDevMode ? [void 0, { debugName: "categoryLabel" }] : /* istanbul ignore next */ []);
|
|
553
|
+
this.config = input.required(...ngDevMode ? [{ debugName: "config" }] : /* istanbul ignore next */ []);
|
|
554
|
+
this.data = input.required(...ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []);
|
|
555
|
+
this.description = input(...ngDevMode ? [void 0, { debugName: "description" }] : /* istanbul ignore next */ []);
|
|
556
|
+
this.emptyText = input.required(...ngDevMode ? [{ debugName: "emptyText" }] : /* istanbul ignore next */ []);
|
|
557
|
+
this.kind = input("bar", ...ngDevMode ? [{ debugName: "kind" }] : /* istanbul ignore next */ []);
|
|
558
|
+
this.legend = input(true, {
|
|
559
|
+
...ngDevMode ? { debugName: "legend" } : /* istanbul ignore next */ {},
|
|
560
|
+
transform: booleanAttribute
|
|
561
|
+
});
|
|
562
|
+
this.loading = input(false, {
|
|
563
|
+
...ngDevMode ? { debugName: "loading" } : /* istanbul ignore next */ {},
|
|
564
|
+
transform: booleanAttribute
|
|
565
|
+
});
|
|
566
|
+
this.userClass = input("", {
|
|
567
|
+
...ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {},
|
|
568
|
+
alias: "class"
|
|
569
|
+
});
|
|
570
|
+
this.valueFormat = input(String, ...ngDevMode ? [{ debugName: "valueFormat" }] : /* istanbul ignore next */ []);
|
|
571
|
+
this.descriptionId = `${this._id}-description`;
|
|
572
|
+
this.size = injectChartSize(this._plot);
|
|
573
|
+
this.scene = computed(() => YUW_CHART_LAYOUTS[this.kind()]({
|
|
574
|
+
categoryFormat: this.categoryFormat(),
|
|
575
|
+
categoryKey: this.categoryKey(),
|
|
576
|
+
categoryLabel: this.categoryLabel(),
|
|
577
|
+
config: this.config(),
|
|
578
|
+
data: this.data(),
|
|
579
|
+
height: this.size().height,
|
|
580
|
+
valueFormat: this.valueFormat(),
|
|
581
|
+
width: this.size().width
|
|
582
|
+
}), ...ngDevMode ? [{ debugName: "scene" }] : /* istanbul ignore next */ []);
|
|
583
|
+
this.active = linkedSignal({
|
|
584
|
+
...ngDevMode ? { debugName: "active" } : /* istanbul ignore next */ {},
|
|
585
|
+
source: this.scene,
|
|
586
|
+
computation: () => null
|
|
587
|
+
});
|
|
588
|
+
this.activeHit = computed(() => {
|
|
589
|
+
const active = this.active();
|
|
590
|
+
return active === null ? null : this.scene().hits[active] ?? null;
|
|
591
|
+
}, ...ngDevMode ? [{ debugName: "activeHit" }] : /* istanbul ignore next */ []);
|
|
592
|
+
this.activePoints = computed(() => this.activeHit()?.points ?? [], ...ngDevMode ? [{ debugName: "activePoints" }] : /* istanbul ignore next */ []);
|
|
593
|
+
this.announcement = computed(() => {
|
|
594
|
+
const tooltip = this.activeHit()?.tooltip;
|
|
595
|
+
if (!tooltip) return "";
|
|
596
|
+
return [tooltip.title, ...tooltip.items.map((item) => `${item.label}: ${item.value}`)].filter((part) => !!part).join(", ");
|
|
597
|
+
}, ...ngDevMode ? [{ debugName: "announcement" }] : /* istanbul ignore next */ []);
|
|
598
|
+
this.cursorClass = computed(() => CURSOR_CLASS[this.scene().cursorPaint], ...ngDevMode ? [{ debugName: "cursorClass" }] : /* istanbul ignore next */ []);
|
|
599
|
+
this.describedBy = computed(() => this.description() ? this.descriptionId : null, ...ngDevMode ? [{ debugName: "describedBy" }] : /* istanbul ignore next */ []);
|
|
600
|
+
this.drawable = computed(() => this.size().width > 0 && this.size().height > 0, ...ngDevMode ? [{ debugName: "drawable" }] : /* istanbul ignore next */ []);
|
|
601
|
+
this.interactive = computed(() => !this.loading() && this.scene().hits.length > 0, ...ngDevMode ? [{ debugName: "interactive" }] : /* istanbul ignore next */ []);
|
|
602
|
+
this.legendItems = computed(() => Object.entries(this.config()).map(([key, series]) => ({
|
|
603
|
+
key,
|
|
604
|
+
label: series.label,
|
|
605
|
+
color: cssColor(series.color)
|
|
606
|
+
})), ...ngDevMode ? [{ debugName: "legendItems" }] : /* istanbul ignore next */ []);
|
|
607
|
+
this.marks = computed(() => {
|
|
608
|
+
const active = this.active();
|
|
609
|
+
return this.scene().marks.map((mark) => ({
|
|
610
|
+
d: mark.d,
|
|
611
|
+
key: mark.key,
|
|
612
|
+
class: hlm(MARK_CLASS[mark.paint], active !== null && mark.hit !== null && mark.hit !== active && "opacity-40"),
|
|
613
|
+
style: { [MARK_COLOR_PROPERTY[mark.paint]]: mark.color }
|
|
614
|
+
}));
|
|
615
|
+
}, ...ngDevMode ? [{ debugName: "marks" }] : /* istanbul ignore next */ []);
|
|
616
|
+
this.origin = computed(() => `translate(${this.scene().origin.x},${this.scene().origin.y})`, ...ngDevMode ? [{ debugName: "origin" }] : /* istanbul ignore next */ []);
|
|
617
|
+
this.rootClass = computed(() => hlm("flex h-72 w-full flex-col gap-3", this.userClass()), ...ngDevMode ? [{ debugName: "rootClass" }] : /* istanbul ignore next */ []);
|
|
618
|
+
this.showLegend = computed(() => this.legend() && !this.loading() && !this.scene().empty, ...ngDevMode ? [{ debugName: "showLegend" }] : /* istanbul ignore next */ []);
|
|
619
|
+
this.tooltip = computed(() => {
|
|
620
|
+
const hit = this.activeHit();
|
|
621
|
+
if (!hit || hit.tooltip.items.length === 0) return null;
|
|
622
|
+
return {
|
|
623
|
+
...hit.tooltip,
|
|
624
|
+
left: hit.anchor.x,
|
|
625
|
+
top: hit.anchor.y,
|
|
626
|
+
class: TOOLTIP_SIDE_CLASS[hit.anchor.x > this.size().width / 2 ? "left" : "right"]
|
|
627
|
+
};
|
|
628
|
+
}, ...ngDevMode ? [{ debugName: "tooltip" }] : /* istanbul ignore next */ []);
|
|
629
|
+
this.viewBox = computed(() => `0 0 ${this.size().width} ${this.size().height}`, ...ngDevMode ? [{ debugName: "viewBox" }] : /* istanbul ignore next */ []);
|
|
630
|
+
}
|
|
631
|
+
activate(index) {
|
|
632
|
+
this.active.set(index);
|
|
633
|
+
}
|
|
634
|
+
clear() {
|
|
635
|
+
this.active.set(null);
|
|
636
|
+
}
|
|
637
|
+
onFocus(event) {
|
|
638
|
+
const target = event.target;
|
|
639
|
+
if (this.active() === null && target.matches(":focus-visible")) this.active.set(0);
|
|
640
|
+
}
|
|
641
|
+
onKeydown(event) {
|
|
642
|
+
const move = KEY_MOVES[event.key];
|
|
643
|
+
const count = this.scene().hits.length;
|
|
644
|
+
if (!move || count === 0) return;
|
|
645
|
+
event.preventDefault();
|
|
646
|
+
this.active.set(move(this.active() ?? -1, count));
|
|
647
|
+
}
|
|
648
|
+
static {
|
|
649
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
650
|
+
minVersion: "12.0.0",
|
|
651
|
+
version: "22.2.4",
|
|
652
|
+
ngImport: i0,
|
|
653
|
+
type: YuwChartComponent,
|
|
654
|
+
deps: [],
|
|
655
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
656
|
+
});
|
|
657
|
+
}
|
|
658
|
+
static {
|
|
659
|
+
this.ɵcmp = i0.ɵɵngDeclareComponent({
|
|
660
|
+
minVersion: "17.0.0",
|
|
661
|
+
version: "22.2.4",
|
|
662
|
+
type: YuwChartComponent,
|
|
663
|
+
isStandalone: true,
|
|
664
|
+
selector: "yuw-chart",
|
|
665
|
+
inputs: {
|
|
666
|
+
ariaLabel: {
|
|
667
|
+
classPropertyName: "ariaLabel",
|
|
668
|
+
publicName: "ariaLabel",
|
|
669
|
+
isSignal: true,
|
|
670
|
+
isRequired: true,
|
|
671
|
+
transformFunction: null
|
|
672
|
+
},
|
|
673
|
+
categoryFormat: {
|
|
674
|
+
classPropertyName: "categoryFormat",
|
|
675
|
+
publicName: "categoryFormat",
|
|
676
|
+
isSignal: true,
|
|
677
|
+
isRequired: false,
|
|
678
|
+
transformFunction: null
|
|
679
|
+
},
|
|
680
|
+
categoryKey: {
|
|
681
|
+
classPropertyName: "categoryKey",
|
|
682
|
+
publicName: "categoryKey",
|
|
683
|
+
isSignal: true,
|
|
684
|
+
isRequired: false,
|
|
685
|
+
transformFunction: null
|
|
686
|
+
},
|
|
687
|
+
categoryLabel: {
|
|
688
|
+
classPropertyName: "categoryLabel",
|
|
689
|
+
publicName: "categoryLabel",
|
|
690
|
+
isSignal: true,
|
|
691
|
+
isRequired: false,
|
|
692
|
+
transformFunction: null
|
|
693
|
+
},
|
|
694
|
+
config: {
|
|
695
|
+
classPropertyName: "config",
|
|
696
|
+
publicName: "config",
|
|
697
|
+
isSignal: true,
|
|
698
|
+
isRequired: true,
|
|
699
|
+
transformFunction: null
|
|
700
|
+
},
|
|
701
|
+
data: {
|
|
702
|
+
classPropertyName: "data",
|
|
703
|
+
publicName: "data",
|
|
704
|
+
isSignal: true,
|
|
705
|
+
isRequired: true,
|
|
706
|
+
transformFunction: null
|
|
707
|
+
},
|
|
708
|
+
description: {
|
|
709
|
+
classPropertyName: "description",
|
|
710
|
+
publicName: "description",
|
|
711
|
+
isSignal: true,
|
|
712
|
+
isRequired: false,
|
|
713
|
+
transformFunction: null
|
|
714
|
+
},
|
|
715
|
+
emptyText: {
|
|
716
|
+
classPropertyName: "emptyText",
|
|
717
|
+
publicName: "emptyText",
|
|
718
|
+
isSignal: true,
|
|
719
|
+
isRequired: true,
|
|
720
|
+
transformFunction: null
|
|
721
|
+
},
|
|
722
|
+
kind: {
|
|
723
|
+
classPropertyName: "kind",
|
|
724
|
+
publicName: "kind",
|
|
725
|
+
isSignal: true,
|
|
726
|
+
isRequired: false,
|
|
727
|
+
transformFunction: null
|
|
728
|
+
},
|
|
729
|
+
legend: {
|
|
730
|
+
classPropertyName: "legend",
|
|
731
|
+
publicName: "legend",
|
|
732
|
+
isSignal: true,
|
|
733
|
+
isRequired: false,
|
|
734
|
+
transformFunction: null
|
|
735
|
+
},
|
|
736
|
+
loading: {
|
|
737
|
+
classPropertyName: "loading",
|
|
738
|
+
publicName: "loading",
|
|
739
|
+
isSignal: true,
|
|
740
|
+
isRequired: false,
|
|
741
|
+
transformFunction: null
|
|
742
|
+
},
|
|
743
|
+
userClass: {
|
|
744
|
+
classPropertyName: "userClass",
|
|
745
|
+
publicName: "class",
|
|
746
|
+
isSignal: true,
|
|
747
|
+
isRequired: false,
|
|
748
|
+
transformFunction: null
|
|
749
|
+
},
|
|
750
|
+
valueFormat: {
|
|
751
|
+
classPropertyName: "valueFormat",
|
|
752
|
+
publicName: "valueFormat",
|
|
753
|
+
isSignal: true,
|
|
754
|
+
isRequired: false,
|
|
755
|
+
transformFunction: null
|
|
756
|
+
}
|
|
757
|
+
},
|
|
758
|
+
host: { classAttribute: "contents" },
|
|
759
|
+
viewQueries: [{
|
|
760
|
+
propertyName: "_plot",
|
|
761
|
+
first: true,
|
|
762
|
+
predicate: ["plot"],
|
|
763
|
+
descendants: true,
|
|
764
|
+
isSignal: true
|
|
765
|
+
}],
|
|
766
|
+
ngImport: i0,
|
|
767
|
+
template: "<div role=\"figure\" [class]=\"rootClass()\" [attr.aria-label]=\"ariaLabel()\" [attr.aria-busy]=\"loading() || null\">\n @if (description(); as text) {\n <p class=\"sr-only\" [id]=\"descriptionId\">{{ text }}</p>\n }\n\n <!-- Plot -->\n <div\n #plot\n role=\"group\"\n class=\"relative min-h-0 flex-1 rounded-md outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50\"\n [attr.aria-label]=\"ariaLabel()\"\n [attr.aria-describedby]=\"describedBy()\"\n [attr.tabindex]=\"interactive() ? 0 : null\"\n (focus)=\"onFocus($event)\"\n (blur)=\"clear()\"\n (keydown)=\"onKeydown($event)\"\n (pointerleave)=\"clear()\"\n >\n @if (loading()) {\n <div hlmSkeleton class=\"size-full\" aria-hidden=\"true\"></div>\n } @else if (scene().empty) {\n <div class=\"flex size-full items-center justify-center text-center text-sm text-muted-foreground\">\n {{ emptyText() }}\n </div>\n } @else if (drawable()) {\n <svg\n aria-hidden=\"true\"\n class=\"absolute inset-0 overflow-visible\"\n [attr.width]=\"size().width\"\n [attr.height]=\"size().height\"\n [attr.viewBox]=\"viewBox()\"\n >\n @for (line of scene().grid; track $index) {\n <path class=\"fill-none stroke-border [stroke-dasharray:3_3]\" [attr.d]=\"line\" />\n }\n\n @if (activeHit()?.cursor; as cursor) {\n <path [class]=\"cursorClass()\" [attr.d]=\"cursor\" />\n }\n\n <g [attr.transform]=\"origin()\">\n @for (mark of marks(); track $index) {\n <path [class]=\"mark.class\" [style]=\"mark.style\" [attr.d]=\"mark.d\" />\n }\n </g>\n\n @for (point of activePoints(); track point.key) {\n <circle\n r=\"4\"\n class=\"stroke-background stroke-2\"\n [style.fill]=\"point.color\"\n [attr.cx]=\"point.cx\"\n [attr.cy]=\"point.cy\"\n />\n }\n\n @for (tick of scene().ticks; track $index) {\n <text\n dominant-baseline=\"middle\"\n class=\"fill-muted-foreground text-xs\"\n [attr.x]=\"tick.x\"\n [attr.y]=\"tick.y\"\n [attr.text-anchor]=\"tick.anchor\"\n >\n {{ tick.label }}\n </text>\n }\n\n <g [attr.transform]=\"origin()\">\n @for (hit of scene().hits; track $index) {\n <path class=\"fill-transparent\" [attr.d]=\"hit.d\" (pointerenter)=\"activate($index)\" />\n }\n </g>\n </svg>\n\n @if (tooltip(); as tip) {\n <div\n aria-hidden=\"true\"\n class=\"pointer-events-none absolute z-10 grid min-w-32 -translate-y-1/2 gap-1.5 rounded-md border bg-popover px-2.5 py-1.5 text-xs text-popover-foreground shadow-md motion-safe:transition-[left,top] motion-safe:duration-150\"\n [class]=\"tip.class\"\n [style.left.px]=\"tip.left\"\n [style.top.px]=\"tip.top\"\n >\n @if (tip.title) {\n <span class=\"font-medium\">{{ tip.title }}</span>\n }\n @for (item of tip.items; track item.key) {\n <span class=\"flex items-center gap-2\">\n <span class=\"size-2.5 shrink-0 rounded-[2px]\" [style.background]=\"item.color\"></span>\n <span class=\"text-muted-foreground\">{{ item.label }}</span>\n <span class=\"ml-auto font-mono font-medium tabular-nums\">{{ item.value }}</span>\n </span>\n }\n </div>\n }\n }\n\n <div role=\"status\" class=\"sr-only\">{{ announcement() }}</div>\n </div>\n\n <!-- Legend -->\n @if (showLegend()) {\n <ul class=\"flex flex-wrap items-center justify-center gap-x-4 gap-y-1 text-xs text-muted-foreground\">\n @for (item of legendItems(); track item.key) {\n <li class=\"flex items-center gap-1.5\">\n <span aria-hidden=\"true\" class=\"size-2.5 shrink-0 rounded-[2px]\" [style.background]=\"item.color\"></span>\n {{ item.label }}\n </li>\n }\n </ul>\n }\n\n <!-- Accessible data -->\n <table class=\"sr-only\">\n <caption>\n {{ ariaLabel() }}\n </caption>\n <thead>\n <tr>\n @if (scene().table.corner !== null) {\n <th scope=\"col\">{{ scene().table.corner }}</th>\n }\n @for (head of scene().table.head; track $index) {\n <th scope=\"col\">{{ head }}</th>\n }\n </tr>\n </thead>\n <tbody>\n @for (row of scene().table.rows; track $index) {\n <tr>\n @if (row.header !== null) {\n <th scope=\"row\">{{ row.header }}</th>\n }\n @for (cell of row.cells; track $index) {\n <td>{{ cell }}</td>\n }\n </tr>\n }\n </tbody>\n </table>\n</div>\n",
|
|
768
|
+
dependencies: [{
|
|
769
|
+
kind: "directive",
|
|
770
|
+
type: HlmSkeleton,
|
|
771
|
+
selector: "[hlmSkeleton],hlm-skeleton"
|
|
772
|
+
}],
|
|
773
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
774
|
+
});
|
|
775
|
+
}
|
|
776
|
+
};
|
|
777
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
778
|
+
minVersion: "12.0.0",
|
|
779
|
+
version: "22.2.4",
|
|
780
|
+
ngImport: i0,
|
|
781
|
+
type: YuwChartComponent,
|
|
782
|
+
decorators: [{
|
|
783
|
+
type: Component,
|
|
784
|
+
args: [{
|
|
785
|
+
selector: "yuw-chart",
|
|
786
|
+
imports: [HlmSkeleton],
|
|
787
|
+
host: { class: "contents" },
|
|
788
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
789
|
+
template: "<div role=\"figure\" [class]=\"rootClass()\" [attr.aria-label]=\"ariaLabel()\" [attr.aria-busy]=\"loading() || null\">\n @if (description(); as text) {\n <p class=\"sr-only\" [id]=\"descriptionId\">{{ text }}</p>\n }\n\n <!-- Plot -->\n <div\n #plot\n role=\"group\"\n class=\"relative min-h-0 flex-1 rounded-md outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50\"\n [attr.aria-label]=\"ariaLabel()\"\n [attr.aria-describedby]=\"describedBy()\"\n [attr.tabindex]=\"interactive() ? 0 : null\"\n (focus)=\"onFocus($event)\"\n (blur)=\"clear()\"\n (keydown)=\"onKeydown($event)\"\n (pointerleave)=\"clear()\"\n >\n @if (loading()) {\n <div hlmSkeleton class=\"size-full\" aria-hidden=\"true\"></div>\n } @else if (scene().empty) {\n <div class=\"flex size-full items-center justify-center text-center text-sm text-muted-foreground\">\n {{ emptyText() }}\n </div>\n } @else if (drawable()) {\n <svg\n aria-hidden=\"true\"\n class=\"absolute inset-0 overflow-visible\"\n [attr.width]=\"size().width\"\n [attr.height]=\"size().height\"\n [attr.viewBox]=\"viewBox()\"\n >\n @for (line of scene().grid; track $index) {\n <path class=\"fill-none stroke-border [stroke-dasharray:3_3]\" [attr.d]=\"line\" />\n }\n\n @if (activeHit()?.cursor; as cursor) {\n <path [class]=\"cursorClass()\" [attr.d]=\"cursor\" />\n }\n\n <g [attr.transform]=\"origin()\">\n @for (mark of marks(); track $index) {\n <path [class]=\"mark.class\" [style]=\"mark.style\" [attr.d]=\"mark.d\" />\n }\n </g>\n\n @for (point of activePoints(); track point.key) {\n <circle\n r=\"4\"\n class=\"stroke-background stroke-2\"\n [style.fill]=\"point.color\"\n [attr.cx]=\"point.cx\"\n [attr.cy]=\"point.cy\"\n />\n }\n\n @for (tick of scene().ticks; track $index) {\n <text\n dominant-baseline=\"middle\"\n class=\"fill-muted-foreground text-xs\"\n [attr.x]=\"tick.x\"\n [attr.y]=\"tick.y\"\n [attr.text-anchor]=\"tick.anchor\"\n >\n {{ tick.label }}\n </text>\n }\n\n <g [attr.transform]=\"origin()\">\n @for (hit of scene().hits; track $index) {\n <path class=\"fill-transparent\" [attr.d]=\"hit.d\" (pointerenter)=\"activate($index)\" />\n }\n </g>\n </svg>\n\n @if (tooltip(); as tip) {\n <div\n aria-hidden=\"true\"\n class=\"pointer-events-none absolute z-10 grid min-w-32 -translate-y-1/2 gap-1.5 rounded-md border bg-popover px-2.5 py-1.5 text-xs text-popover-foreground shadow-md motion-safe:transition-[left,top] motion-safe:duration-150\"\n [class]=\"tip.class\"\n [style.left.px]=\"tip.left\"\n [style.top.px]=\"tip.top\"\n >\n @if (tip.title) {\n <span class=\"font-medium\">{{ tip.title }}</span>\n }\n @for (item of tip.items; track item.key) {\n <span class=\"flex items-center gap-2\">\n <span class=\"size-2.5 shrink-0 rounded-[2px]\" [style.background]=\"item.color\"></span>\n <span class=\"text-muted-foreground\">{{ item.label }}</span>\n <span class=\"ml-auto font-mono font-medium tabular-nums\">{{ item.value }}</span>\n </span>\n }\n </div>\n }\n }\n\n <div role=\"status\" class=\"sr-only\">{{ announcement() }}</div>\n </div>\n\n <!-- Legend -->\n @if (showLegend()) {\n <ul class=\"flex flex-wrap items-center justify-center gap-x-4 gap-y-1 text-xs text-muted-foreground\">\n @for (item of legendItems(); track item.key) {\n <li class=\"flex items-center gap-1.5\">\n <span aria-hidden=\"true\" class=\"size-2.5 shrink-0 rounded-[2px]\" [style.background]=\"item.color\"></span>\n {{ item.label }}\n </li>\n }\n </ul>\n }\n\n <!-- Accessible data -->\n <table class=\"sr-only\">\n <caption>\n {{ ariaLabel() }}\n </caption>\n <thead>\n <tr>\n @if (scene().table.corner !== null) {\n <th scope=\"col\">{{ scene().table.corner }}</th>\n }\n @for (head of scene().table.head; track $index) {\n <th scope=\"col\">{{ head }}</th>\n }\n </tr>\n </thead>\n <tbody>\n @for (row of scene().table.rows; track $index) {\n <tr>\n @if (row.header !== null) {\n <th scope=\"row\">{{ row.header }}</th>\n }\n @for (cell of row.cells; track $index) {\n <td>{{ cell }}</td>\n }\n </tr>\n }\n </tbody>\n </table>\n</div>\n"
|
|
790
|
+
}]
|
|
791
|
+
}],
|
|
792
|
+
propDecorators: {
|
|
793
|
+
_plot: [{
|
|
794
|
+
type: i0.ViewChild,
|
|
795
|
+
args: ["plot", { isSignal: true }]
|
|
796
|
+
}],
|
|
797
|
+
ariaLabel: [{
|
|
798
|
+
type: i0.Input,
|
|
799
|
+
args: [{
|
|
800
|
+
isSignal: true,
|
|
801
|
+
alias: "ariaLabel",
|
|
802
|
+
required: true
|
|
803
|
+
}]
|
|
804
|
+
}],
|
|
805
|
+
categoryFormat: [{
|
|
806
|
+
type: i0.Input,
|
|
807
|
+
args: [{
|
|
808
|
+
isSignal: true,
|
|
809
|
+
alias: "categoryFormat",
|
|
810
|
+
required: false
|
|
811
|
+
}]
|
|
812
|
+
}],
|
|
813
|
+
categoryKey: [{
|
|
814
|
+
type: i0.Input,
|
|
815
|
+
args: [{
|
|
816
|
+
isSignal: true,
|
|
817
|
+
alias: "categoryKey",
|
|
818
|
+
required: false
|
|
819
|
+
}]
|
|
820
|
+
}],
|
|
821
|
+
categoryLabel: [{
|
|
822
|
+
type: i0.Input,
|
|
823
|
+
args: [{
|
|
824
|
+
isSignal: true,
|
|
825
|
+
alias: "categoryLabel",
|
|
826
|
+
required: false
|
|
827
|
+
}]
|
|
828
|
+
}],
|
|
829
|
+
config: [{
|
|
830
|
+
type: i0.Input,
|
|
831
|
+
args: [{
|
|
832
|
+
isSignal: true,
|
|
833
|
+
alias: "config",
|
|
834
|
+
required: true
|
|
835
|
+
}]
|
|
836
|
+
}],
|
|
837
|
+
data: [{
|
|
838
|
+
type: i0.Input,
|
|
839
|
+
args: [{
|
|
840
|
+
isSignal: true,
|
|
841
|
+
alias: "data",
|
|
842
|
+
required: true
|
|
843
|
+
}]
|
|
844
|
+
}],
|
|
845
|
+
description: [{
|
|
846
|
+
type: i0.Input,
|
|
847
|
+
args: [{
|
|
848
|
+
isSignal: true,
|
|
849
|
+
alias: "description",
|
|
850
|
+
required: false
|
|
851
|
+
}]
|
|
852
|
+
}],
|
|
853
|
+
emptyText: [{
|
|
854
|
+
type: i0.Input,
|
|
855
|
+
args: [{
|
|
856
|
+
isSignal: true,
|
|
857
|
+
alias: "emptyText",
|
|
858
|
+
required: true
|
|
859
|
+
}]
|
|
860
|
+
}],
|
|
861
|
+
kind: [{
|
|
862
|
+
type: i0.Input,
|
|
863
|
+
args: [{
|
|
864
|
+
isSignal: true,
|
|
865
|
+
alias: "kind",
|
|
866
|
+
required: false
|
|
867
|
+
}]
|
|
868
|
+
}],
|
|
869
|
+
legend: [{
|
|
870
|
+
type: i0.Input,
|
|
871
|
+
args: [{
|
|
872
|
+
isSignal: true,
|
|
873
|
+
alias: "legend",
|
|
874
|
+
required: false
|
|
875
|
+
}]
|
|
876
|
+
}],
|
|
877
|
+
loading: [{
|
|
878
|
+
type: i0.Input,
|
|
879
|
+
args: [{
|
|
880
|
+
isSignal: true,
|
|
881
|
+
alias: "loading",
|
|
882
|
+
required: false
|
|
883
|
+
}]
|
|
884
|
+
}],
|
|
885
|
+
userClass: [{
|
|
886
|
+
type: i0.Input,
|
|
887
|
+
args: [{
|
|
888
|
+
isSignal: true,
|
|
889
|
+
alias: "class",
|
|
890
|
+
required: false
|
|
891
|
+
}]
|
|
892
|
+
}],
|
|
893
|
+
valueFormat: [{
|
|
894
|
+
type: i0.Input,
|
|
895
|
+
args: [{
|
|
896
|
+
isSignal: true,
|
|
897
|
+
alias: "valueFormat",
|
|
898
|
+
required: false
|
|
899
|
+
}]
|
|
900
|
+
}]
|
|
901
|
+
}
|
|
902
|
+
});
|
|
649
903
|
export { YUW_CHART_COLORS, YuwChartComponent, yuwChartColorAt };
|
|
650
|
-
|
|
904
|
+
|
|
905
|
+
//# sourceMappingURL=yukit-web-chart.mjs.map
|