iryx-ui 0.15.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/component-names.d.ts +1 -1
- package/dist/component-names.js +1 -1
- package/dist/components/BarChart.vue.d.ts +8 -0
- package/dist/components/BarChart.vue_vue_type_script_setup_true_lang.js +169 -151
- package/dist/components/DonutChart.js +5 -0
- package/dist/components/DonutChart.vue.d.ts +96 -0
- package/dist/components/DonutChart.vue_vue_type_script_setup_true_lang.js +234 -0
- package/dist/components/LineChart.vue.d.ts +8 -0
- package/dist/components/LineChart.vue_vue_type_script_setup_true_lang.js +160 -141
- package/dist/components/Sparkline.vue.d.ts +9 -0
- package/dist/components/Sparkline.vue_vue_type_script_setup_true_lang.js +90 -53
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +90 -88
- package/dist/composables/cartesian.d.ts +10 -2
- package/dist/composables/chart-reveal.d.ts +45 -0
- package/dist/composables/chart-reveal.js +93 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +134 -131
- package/dist/theme/donut-chart.d.ts +104 -0
- package/dist/theme/donut-chart.js +17 -0
- package/dist/theme/index.d.ts +1 -0
- package/dist/theme/sparkline.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* Consumed by the Vue plugin (global registration) and the Nuxt module
|
|
4
4
|
* (auto-imports). Keep in sync with `src/components/index.ts`.
|
|
5
5
|
*/
|
|
6
|
-
export declare const componentNames: readonly ["Accordion", "Alert", "App", "AppShell", "AspectRatio", "Avatar", "AvatarGroup", "Badge", "BarChart", "Banner", "Breadcrumb", "Button", "ButtonGroup", "Card", "ChartLegend", "Checkbox", "ColorPicker", "Combobox", "Collapsible", "CommandPalette", "Container", "ConfirmDialog", "ContextMenu", "DatePicker", "DateRangePicker", "Dialog", "Drawer", "DropdownMenu", "EmptyState", "FileUpload", "Form", "FormField", "Icon", "Input", "Kbd", "Label", "LineChart", "NavigationMenu", "NumberInput", "Menubar", "PageHeader", "Pagination", "PasswordInput", "PinInput", "Popover", "Progress", "RadioGroup", "ScrollArea", "ScrollFade", "Select", "Separator", "Sidebar", "SignaturePad", "Skeleton", "Slider", "Sparkline", "Splitter", "Stat", "Stepper", "Switch", "Table", "Tabs", "TagsInput", "Textarea", "Toaster", "Toggle", "ToggleGroup", "TimeField", "Timeline", "Toolbar", "Tooltip", "Tree"];
|
|
6
|
+
export declare const componentNames: readonly ["Accordion", "Alert", "App", "AppShell", "AspectRatio", "Avatar", "AvatarGroup", "Badge", "BarChart", "Banner", "Breadcrumb", "Button", "ButtonGroup", "Card", "ChartLegend", "Checkbox", "ColorPicker", "Combobox", "Collapsible", "CommandPalette", "Container", "ConfirmDialog", "ContextMenu", "DatePicker", "DateRangePicker", "Dialog", "DonutChart", "Drawer", "DropdownMenu", "EmptyState", "FileUpload", "Form", "FormField", "Icon", "Input", "Kbd", "Label", "LineChart", "NavigationMenu", "NumberInput", "Menubar", "PageHeader", "Pagination", "PasswordInput", "PinInput", "Popover", "Progress", "RadioGroup", "ScrollArea", "ScrollFade", "Select", "Separator", "Sidebar", "SignaturePad", "Skeleton", "Slider", "Sparkline", "Splitter", "Stat", "Stepper", "Switch", "Table", "Tabs", "TagsInput", "Textarea", "Toaster", "Toggle", "ToggleGroup", "TimeField", "Timeline", "Toolbar", "Tooltip", "Tree"];
|
|
7
7
|
export type ComponentName = (typeof componentNames)[number];
|
package/dist/component-names.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
//#region src/component-names.ts
|
|
2
|
-
var e = /* @__PURE__ */ "Accordion.Alert.App.AppShell.AspectRatio.Avatar.AvatarGroup.Badge.BarChart.Banner.Breadcrumb.Button.ButtonGroup.Card.ChartLegend.Checkbox.ColorPicker.Combobox.Collapsible.CommandPalette.Container.ConfirmDialog.ContextMenu.DatePicker.DateRangePicker.Dialog.Drawer.DropdownMenu.EmptyState.FileUpload.Form.FormField.Icon.Input.Kbd.Label.LineChart.NavigationMenu.NumberInput.Menubar.PageHeader.Pagination.PasswordInput.PinInput.Popover.Progress.RadioGroup.ScrollArea.ScrollFade.Select.Separator.Sidebar.SignaturePad.Skeleton.Slider.Sparkline.Splitter.Stat.Stepper.Switch.Table.Tabs.TagsInput.Textarea.Toaster.Toggle.ToggleGroup.TimeField.Timeline.Toolbar.Tooltip.Tree".split(".");
|
|
2
|
+
var e = /* @__PURE__ */ "Accordion.Alert.App.AppShell.AspectRatio.Avatar.AvatarGroup.Badge.BarChart.Banner.Breadcrumb.Button.ButtonGroup.Card.ChartLegend.Checkbox.ColorPicker.Combobox.Collapsible.CommandPalette.Container.ConfirmDialog.ContextMenu.DatePicker.DateRangePicker.Dialog.DonutChart.Drawer.DropdownMenu.EmptyState.FileUpload.Form.FormField.Icon.Input.Kbd.Label.LineChart.NavigationMenu.NumberInput.Menubar.PageHeader.Pagination.PasswordInput.PinInput.Popover.Progress.RadioGroup.ScrollArea.ScrollFade.Select.Separator.Sidebar.SignaturePad.Skeleton.Slider.Sparkline.Splitter.Stat.Stepper.Switch.Table.Tabs.TagsInput.Textarea.Toaster.Toggle.ToggleGroup.TimeField.Timeline.Toolbar.Tooltip.Tree".split(".");
|
|
3
3
|
//#endregion
|
|
4
4
|
export { e as componentNames };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ChartSeries } from '../composables/cartesian';
|
|
2
|
+
import type { ChartAnimate } from '../composables/chart-reveal';
|
|
2
3
|
import type { SparseValue } from '../composables/scale';
|
|
3
4
|
/**
|
|
4
5
|
* A row. `value` is the single-series shortcut; with `series` set, each entry
|
|
@@ -37,6 +38,12 @@ export interface BarChartProps {
|
|
|
37
38
|
ticks?: number;
|
|
38
39
|
/** Drop the value axis and its gridlines. */
|
|
39
40
|
axis?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Grow the bars out of the baseline on the first paint. Skipped for a
|
|
43
|
+
* reader who has asked for reduced motion, and played once — not again when
|
|
44
|
+
* the data changes underneath it.
|
|
45
|
+
*/
|
|
46
|
+
animate?: ChartAnimate;
|
|
40
47
|
/** Drop the legend. Only honoured for a single series — see below. */
|
|
41
48
|
legend?: boolean;
|
|
42
49
|
/** Word for the stacked tooltip's sum — override for non-English apps. */
|
|
@@ -95,6 +102,7 @@ declare const __VLS_base: import("vue").DefineComponent<BarChartProps, {}, {}, {
|
|
|
95
102
|
orientation: "vertical" | "horizontal";
|
|
96
103
|
data: readonly BarChartDatum[];
|
|
97
104
|
legend: boolean;
|
|
105
|
+
animate: ChartAnimate;
|
|
98
106
|
height: number;
|
|
99
107
|
ticks: number;
|
|
100
108
|
axis: boolean;
|
|
@@ -1,39 +1,40 @@
|
|
|
1
1
|
import { useIryxUiConfig as e } from "../config.js";
|
|
2
2
|
import { useElementSize as t } from "../composables/element-size.js";
|
|
3
3
|
import { cartesianLayout as n, clampTooltip as r, seriesColor as i, slotOf as a, tooltipHalfWidth as o, warnOnSlotOverflow as s } from "../composables/cartesian.js";
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
4
|
+
import { useChartAnimation as c, useChartReveal as l } from "../composables/chart-reveal.js";
|
|
5
|
+
import { barChartTheme as u } from "../theme/bar-chart.js";
|
|
6
|
+
import d from "./ChartLegend.js";
|
|
7
|
+
import { Fragment as f, computed as p, createBlock as m, createCommentVNode as h, createElementBlock as g, createElementVNode as _, defineComponent as v, guardReactiveProps as y, normalizeClass as b, normalizeProps as x, normalizeStyle as S, openBlock as C, ref as w, renderList as T, renderSlot as E, toDisplayString as D, unref as O } from "vue";
|
|
7
8
|
//#region src/components/BarChart.vue?vue&type=script&setup=true&lang.ts
|
|
8
|
-
var ee = ["role", "aria-label"],
|
|
9
|
+
var ee = ["role", "aria-label"], te = [
|
|
9
10
|
"width",
|
|
10
11
|
"height",
|
|
11
12
|
"viewBox"
|
|
12
|
-
],
|
|
13
|
+
], ne = [
|
|
13
14
|
"x1",
|
|
14
15
|
"y1",
|
|
15
16
|
"x2",
|
|
16
17
|
"y2"
|
|
17
|
-
],
|
|
18
|
+
], re = [
|
|
18
19
|
"x",
|
|
19
20
|
"y",
|
|
20
21
|
"text-anchor",
|
|
21
22
|
"dominant-baseline"
|
|
22
|
-
],
|
|
23
|
+
], ie = ["d"], k = [
|
|
23
24
|
"x",
|
|
24
25
|
"y",
|
|
25
26
|
"text-anchor",
|
|
26
27
|
"dominant-baseline"
|
|
27
|
-
],
|
|
28
|
+
], ae = [
|
|
28
29
|
"x",
|
|
29
30
|
"y",
|
|
30
31
|
"width",
|
|
31
32
|
"height",
|
|
32
33
|
"onPointerenter"
|
|
33
|
-
],
|
|
34
|
+
], oe = {
|
|
34
35
|
key: 2,
|
|
35
36
|
class: "flex items-center gap-1.5 border-t border-border pt-1"
|
|
36
|
-
},
|
|
37
|
+
}, se = { scope: "row" }, ce = .7, A = /*@__PURE__*/ v({
|
|
37
38
|
__name: "BarChart",
|
|
38
39
|
props: {
|
|
39
40
|
data: { default: () => [] },
|
|
@@ -46,6 +47,10 @@ var ee = ["role", "aria-label"], D = [
|
|
|
46
47
|
type: Boolean,
|
|
47
48
|
default: !0
|
|
48
49
|
},
|
|
50
|
+
animate: {
|
|
51
|
+
type: [Boolean, Object],
|
|
52
|
+
default: !0
|
|
53
|
+
},
|
|
49
54
|
legend: {
|
|
50
55
|
type: Boolean,
|
|
51
56
|
default: !0
|
|
@@ -61,60 +66,60 @@ var ee = ["role", "aria-label"], D = [
|
|
|
61
66
|
class: {},
|
|
62
67
|
ui: {}
|
|
63
68
|
},
|
|
64
|
-
setup(
|
|
65
|
-
let
|
|
66
|
-
function
|
|
67
|
-
return
|
|
69
|
+
setup(v) {
|
|
70
|
+
let A = v, j = e(), M = p(() => A.unstyled ?? j.unstyled), N = w(), { width: P } = t(N), le = p(() => new Intl.NumberFormat(A.locale, A.format));
|
|
71
|
+
function F(e) {
|
|
72
|
+
return le.value.format(e);
|
|
68
73
|
}
|
|
69
|
-
let
|
|
70
|
-
let e =
|
|
74
|
+
let I = p(() => {
|
|
75
|
+
let e = A.series?.length ? [...A.series] : [{ key: "value" }];
|
|
71
76
|
return s(e.length), e;
|
|
72
|
-
}),
|
|
73
|
-
function
|
|
77
|
+
}), L = p(() => I.value.length > 1), ue = p(() => L.value || A.legend && I.value[0].name != null);
|
|
78
|
+
function R(e, t) {
|
|
74
79
|
let n = e[t];
|
|
75
80
|
return typeof n == "number" && Number.isFinite(n) ? n : null;
|
|
76
81
|
}
|
|
77
|
-
let
|
|
78
|
-
function
|
|
82
|
+
let z = p(() => A.orientation === "horizontal"), B = p(() => A.stacked && L.value);
|
|
83
|
+
function V(e) {
|
|
79
84
|
let t = 0, n = 0;
|
|
80
|
-
for (let r of
|
|
81
|
-
let i =
|
|
85
|
+
for (let r of I.value) {
|
|
86
|
+
let i = R(e, r.key);
|
|
82
87
|
i != null && (i >= 0 ? t += i : n += i);
|
|
83
88
|
}
|
|
84
89
|
return [t, n];
|
|
85
90
|
}
|
|
86
|
-
let
|
|
87
|
-
orientation:
|
|
88
|
-
values:
|
|
89
|
-
categories:
|
|
90
|
-
longestLabel: Math.max(...
|
|
91
|
-
width:
|
|
92
|
-
height:
|
|
93
|
-
tickCount:
|
|
94
|
-
showAxis:
|
|
95
|
-
formatTick:
|
|
91
|
+
let H = p(() => n({
|
|
92
|
+
orientation: A.orientation,
|
|
93
|
+
values: B.value ? A.data.flatMap(V) : A.data.flatMap((e) => I.value.map((t) => R(e, t.key))),
|
|
94
|
+
categories: A.data.length,
|
|
95
|
+
longestLabel: Math.max(...A.data.map((e) => e.label.length), 1),
|
|
96
|
+
width: P.value,
|
|
97
|
+
height: A.height,
|
|
98
|
+
tickCount: A.ticks,
|
|
99
|
+
showAxis: A.axis,
|
|
100
|
+
formatTick: F,
|
|
96
101
|
includeZero: !0
|
|
97
|
-
})),
|
|
98
|
-
if (!
|
|
99
|
-
let e =
|
|
100
|
-
return
|
|
101
|
-
let a = 0, o = 0, s =
|
|
102
|
-
let i =
|
|
102
|
+
})), U = p(() => H.value.plot), W = p(() => H.value.y), G = p(() => H.value.bandWidth), de = p(() => G.value * ce), K = p(() => Math.max(2, Math.min(24, de.value / (B.value ? 1 : I.value.length)))), q = p(() => {
|
|
103
|
+
if (!P.value || !A.data.length) return [];
|
|
104
|
+
let e = H.value.value(0), t = I.value.length, n = +(t > 1 && !B.value);
|
|
105
|
+
return A.data.flatMap((r, i) => {
|
|
106
|
+
let a = 0, o = 0, s = I.value.reduce((e, t, n) => {
|
|
107
|
+
let i = R(r, t.key);
|
|
103
108
|
return i != null && i >= 0 ? n : e;
|
|
104
|
-
}, -1), c =
|
|
105
|
-
let i =
|
|
109
|
+
}, -1), c = I.value.reduce((e, t, n) => {
|
|
110
|
+
let i = R(r, t.key);
|
|
106
111
|
return i != null && i < 0 ? n : e;
|
|
107
112
|
}, -1);
|
|
108
|
-
return
|
|
109
|
-
let d =
|
|
113
|
+
return I.value.flatMap((l, u) => {
|
|
114
|
+
let d = R(r, l.key);
|
|
110
115
|
if (d == null) return [];
|
|
111
116
|
let f = e, p;
|
|
112
|
-
if (
|
|
117
|
+
if (B.value) {
|
|
113
118
|
let e = d >= 0 ? a : o, t = e + d;
|
|
114
|
-
f =
|
|
115
|
-
} else p =
|
|
116
|
-
let m =
|
|
117
|
-
return [
|
|
119
|
+
f = H.value.value(e), p = H.value.value(t), d >= 0 ? a = t : o = t;
|
|
120
|
+
} else p = H.value.value(d);
|
|
121
|
+
let m = B.value ? K.value : K.value * t, h = H.value.bandCentre(i) - m / 2 + (B.value ? 0 : K.value * u) + n, g = Math.max(K.value - n * 2, 1), _ = B.value ? Math.min(2, Math.abs(p - f) / 2) : 0, v = Math.max(Math.abs(p - f) - _, 0), y = p < f ? p + _ : f, b = !B.value || u === (d >= 0 ? s : c);
|
|
122
|
+
return [z.value ? {
|
|
118
123
|
x: y,
|
|
119
124
|
y: h,
|
|
120
125
|
width: v,
|
|
@@ -136,7 +141,7 @@ var ee = ["role", "aria-label"], D = [
|
|
|
136
141
|
});
|
|
137
142
|
});
|
|
138
143
|
});
|
|
139
|
-
function
|
|
144
|
+
function fe(e) {
|
|
140
145
|
let { x: t, y: n, width: r, height: i } = e, a = t + r;
|
|
141
146
|
if (!e.capped) return `M${t} ${n} L${a} ${n} L${a} ${n + i} L${t} ${n + i} Z`;
|
|
142
147
|
let o = n + i, s = Math.min(4, r / 2, i / 2, e.direction === "up" || e.direction === "down" ? i : r);
|
|
@@ -147,154 +152,167 @@ var ee = ["role", "aria-label"], D = [
|
|
|
147
152
|
default: return `M${a} ${n} L${t + s} ${n} Q${t} ${n} ${t} ${n + s} L${t} ${o - s} Q${t} ${o} ${t + s} ${o} L${a} ${o} Z`;
|
|
148
153
|
}
|
|
149
154
|
}
|
|
150
|
-
let
|
|
151
|
-
if (
|
|
152
|
-
let e =
|
|
155
|
+
let J = p(() => H.value.labelStep), Y = w(), X = p(() => {
|
|
156
|
+
if (Y.value == null) return;
|
|
157
|
+
let e = A.data[Y.value];
|
|
153
158
|
if (!e) return;
|
|
154
|
-
let t =
|
|
159
|
+
let t = I.value.map((t, n) => ({
|
|
155
160
|
name: t.name ?? t.key,
|
|
156
161
|
color: i(a(t, n)),
|
|
157
|
-
value:
|
|
162
|
+
value: R(e, t.key)
|
|
158
163
|
})).filter((e) => e.value != null).map((e) => ({
|
|
159
164
|
...e,
|
|
160
|
-
value:
|
|
165
|
+
value: F(e.value)
|
|
161
166
|
}));
|
|
162
167
|
if (!t.length) return;
|
|
163
|
-
let n =
|
|
164
|
-
if (
|
|
165
|
-
let i =
|
|
166
|
-
let n =
|
|
167
|
-
return n == null ? -Infinity :
|
|
168
|
-
})), a = "x".repeat(s), l = o(a), u = i + l + 8, d = u + l <=
|
|
168
|
+
let n = B.value ? F(V(e).reduce((e, t) => e + t, 0)) : void 0, s = L.value ? Math.max(e.label.length, n ? n.length + 6 : 0, ...t.map((e) => e.name.length + e.value.length + 3)) : e.label.length + t[0].value.length + 2, c = H.value.bandCentre(Y.value);
|
|
169
|
+
if (z.value) {
|
|
170
|
+
let i = B.value ? H.value.value(V(e)[0]) : Math.max(...I.value.map((t) => {
|
|
171
|
+
let n = R(e, t.key);
|
|
172
|
+
return n == null ? -Infinity : H.value.value(n);
|
|
173
|
+
})), a = "x".repeat(s), l = o(a), u = i + l + 8, d = u + l <= P.value;
|
|
169
174
|
return {
|
|
170
175
|
label: e.label,
|
|
171
176
|
rows: t,
|
|
172
177
|
total: n,
|
|
173
|
-
multi:
|
|
174
|
-
x: r(d ? u : i - l - 8, a,
|
|
178
|
+
multi: L.value,
|
|
179
|
+
x: r(d ? u : i - l - 8, a, P.value),
|
|
175
180
|
y: c
|
|
176
181
|
};
|
|
177
182
|
}
|
|
178
|
-
let l =
|
|
179
|
-
let n =
|
|
180
|
-
return n == null ? Infinity : Math.min(
|
|
183
|
+
let l = B.value ? H.value.value(V(e)[0]) : Math.min(...I.value.map((t) => {
|
|
184
|
+
let n = R(e, t.key);
|
|
185
|
+
return n == null ? Infinity : Math.min(H.value.value(n), H.value.value(0));
|
|
181
186
|
}));
|
|
182
187
|
return {
|
|
183
188
|
label: e.label,
|
|
184
189
|
rows: t,
|
|
185
190
|
total: n,
|
|
186
|
-
multi:
|
|
187
|
-
x: r(c, "x".repeat(s),
|
|
191
|
+
multi: L.value,
|
|
192
|
+
x: r(c, "x".repeat(s), P.value),
|
|
188
193
|
y: l
|
|
189
194
|
};
|
|
190
|
-
}),
|
|
191
|
-
function
|
|
192
|
-
let n =
|
|
193
|
-
return
|
|
195
|
+
}), Z = p(() => u());
|
|
196
|
+
function Q(e, t) {
|
|
197
|
+
let n = A.ui?.[e];
|
|
198
|
+
return M.value ? [n, t] : Z.value[e]({ class: [n, t] });
|
|
199
|
+
}
|
|
200
|
+
let pe = p(() => !!(P.value && q.value.length)), $ = c(p(() => A.animate)), { revealed: me } = l(pe, $);
|
|
201
|
+
function he(e) {
|
|
202
|
+
let t = H.value.value(0), n = z.value ? e.y + e.height / 2 : e.x + e.width / 2, r = z.value ? "scaleX" : "scaleY";
|
|
203
|
+
return {
|
|
204
|
+
transformOrigin: z.value ? `${t}px ${n}px` : `${n}px ${t}px`,
|
|
205
|
+
transform: `${r}(${+!!me.value})`,
|
|
206
|
+
transition: `transform ${$.value.duration}ms ${$.value.css}`,
|
|
207
|
+
transitionDelay: `${Math.min(e.categoryIndex * 30, 200)}ms`
|
|
208
|
+
};
|
|
194
209
|
}
|
|
195
|
-
function
|
|
196
|
-
let t =
|
|
197
|
-
return
|
|
210
|
+
function ge(e) {
|
|
211
|
+
let t = Y.value != null && Y.value !== e.categoryIndex;
|
|
212
|
+
return M.value ? [A.ui?.bar] : Z.value.bar({ class: [A.ui?.bar, t ? Z.value.faded() : void 0] });
|
|
198
213
|
}
|
|
199
|
-
return (e, t) => (
|
|
214
|
+
return (e, t) => (C(), g("div", {
|
|
200
215
|
ref_key: "root",
|
|
201
|
-
ref:
|
|
202
|
-
role:
|
|
203
|
-
"aria-label":
|
|
204
|
-
class:
|
|
216
|
+
ref: N,
|
|
217
|
+
role: A.label ? "figure" : void 0,
|
|
218
|
+
"aria-label": A.label,
|
|
219
|
+
class: b(Q("root", A.class))
|
|
205
220
|
}, [
|
|
206
|
-
|
|
221
|
+
ue.value ? (C(), m(d, {
|
|
207
222
|
key: 0,
|
|
208
|
-
series:
|
|
209
|
-
unstyled:
|
|
210
|
-
}, null, 8, ["series", "unstyled"])) :
|
|
211
|
-
|
|
212
|
-
width:
|
|
213
|
-
height:
|
|
214
|
-
viewBox: `0 0 ${
|
|
223
|
+
series: I.value,
|
|
224
|
+
unstyled: A.unstyled
|
|
225
|
+
}, null, 8, ["series", "unstyled"])) : h("", !0),
|
|
226
|
+
_("div", { class: b(M.value ? void 0 : Z.value.plot()) }, [(C(), g("svg", {
|
|
227
|
+
width: O(P),
|
|
228
|
+
height: A.height,
|
|
229
|
+
viewBox: `0 0 ${O(P)} ${A.height}`,
|
|
215
230
|
"aria-hidden": "true",
|
|
216
|
-
class:
|
|
231
|
+
class: b(Q("svg"))
|
|
217
232
|
}, [
|
|
218
|
-
|
|
219
|
-
x1:
|
|
220
|
-
y1:
|
|
221
|
-
x2:
|
|
222
|
-
y2:
|
|
233
|
+
A.axis ? (C(!0), g(f, { key: 0 }, T(H.value.ticks, (e) => (C(), g("g", { key: `tick-${e}` }, [_("line", {
|
|
234
|
+
x1: z.value ? H.value.value(e) : U.value.left,
|
|
235
|
+
y1: z.value ? U.value.top : W.value(e),
|
|
236
|
+
x2: z.value ? H.value.value(e) : U.value.left + U.value.width,
|
|
237
|
+
y2: z.value ? U.value.top + U.value.height : W.value(e),
|
|
223
238
|
"stroke-width": "1",
|
|
224
|
-
class:
|
|
225
|
-
}, null, 10,
|
|
226
|
-
x:
|
|
227
|
-
y:
|
|
228
|
-
"text-anchor":
|
|
229
|
-
"dominant-baseline":
|
|
230
|
-
class:
|
|
231
|
-
},
|
|
232
|
-
|
|
233
|
-
(
|
|
239
|
+
class: b(Q("grid"))
|
|
240
|
+
}, null, 10, ne), _("text", {
|
|
241
|
+
x: z.value ? H.value.value(e) : U.value.left - O(8),
|
|
242
|
+
y: z.value ? U.value.top + U.value.height + 14 : W.value(e),
|
|
243
|
+
"text-anchor": z.value ? "middle" : "end",
|
|
244
|
+
"dominant-baseline": z.value ? void 0 : "middle",
|
|
245
|
+
class: b(Q("tick"))
|
|
246
|
+
}, D(F(e)), 11, re)]))), 128)) : h("", !0),
|
|
247
|
+
E(e.$slots, "underlay", x(y(H.value))),
|
|
248
|
+
(C(!0), g(f, null, T(q.value, (e, t) => (C(), g("path", {
|
|
234
249
|
key: `bar-${e.categoryIndex}-${e.seriesIndex}-${t}`,
|
|
235
|
-
d:
|
|
236
|
-
style:
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
250
|
+
d: fe(e),
|
|
251
|
+
style: S({
|
|
252
|
+
fill: O(i)(O(a)(I.value[e.seriesIndex], e.seriesIndex)),
|
|
253
|
+
...he(e)
|
|
254
|
+
}),
|
|
255
|
+
class: b(ge(e))
|
|
256
|
+
}, null, 14, ie))), 128)),
|
|
257
|
+
(C(!0), g(f, null, T(A.data, (e, t) => (C(), g(f, { key: `label-${e.label}-${t}` }, [t % J.value === 0 ? (C(), g("text", {
|
|
240
258
|
key: 0,
|
|
241
|
-
x:
|
|
242
|
-
y:
|
|
243
|
-
"text-anchor":
|
|
244
|
-
"dominant-baseline":
|
|
245
|
-
class:
|
|
246
|
-
},
|
|
247
|
-
|
|
248
|
-
(
|
|
259
|
+
x: z.value ? U.value.left - O(8) : H.value.bandCentre(t),
|
|
260
|
+
y: z.value ? H.value.bandCentre(t) : U.value.top + U.value.height + 14,
|
|
261
|
+
"text-anchor": z.value ? "end" : "middle",
|
|
262
|
+
"dominant-baseline": z.value ? "middle" : void 0,
|
|
263
|
+
class: b(Q("category"))
|
|
264
|
+
}, D(e.label), 11, k)) : h("", !0)], 64))), 128)),
|
|
265
|
+
E(e.$slots, "overlay", x(y(H.value))),
|
|
266
|
+
(C(!0), g(f, null, T(A.data, (e, n) => (C(), g("rect", {
|
|
249
267
|
key: `hit-${e.label}-${n}`,
|
|
250
|
-
x:
|
|
251
|
-
y:
|
|
252
|
-
width:
|
|
253
|
-
height:
|
|
254
|
-
class:
|
|
255
|
-
onPointerenter: (e) =>
|
|
256
|
-
onPointerleave: t[0] ||= (e) =>
|
|
257
|
-
}, null, 42,
|
|
258
|
-
], 10,
|
|
268
|
+
x: z.value ? U.value.left : U.value.left + G.value * n,
|
|
269
|
+
y: z.value ? U.value.top + G.value * n : U.value.top,
|
|
270
|
+
width: z.value ? U.value.width : G.value,
|
|
271
|
+
height: z.value ? G.value : U.value.height,
|
|
272
|
+
class: b(M.value ? void 0 : Z.value.hit()),
|
|
273
|
+
onPointerenter: (e) => Y.value = n,
|
|
274
|
+
onPointerleave: t[0] ||= (e) => Y.value = void 0
|
|
275
|
+
}, null, 42, ae))), 128))
|
|
276
|
+
], 10, te)), X.value ? (C(), g("div", {
|
|
259
277
|
key: 0,
|
|
260
|
-
class:
|
|
261
|
-
style:
|
|
262
|
-
left: `${
|
|
263
|
-
top: `${
|
|
264
|
-
transform:
|
|
278
|
+
class: b(Q("tooltip", X.value.multi ? "flex-col items-start gap-1" : void 0)),
|
|
279
|
+
style: S({
|
|
280
|
+
left: `${X.value.x}px`,
|
|
281
|
+
top: `${X.value.y}px`,
|
|
282
|
+
transform: z.value ? "translate(-50%, -50%)" : "translate(-50%, -100%) translateY(-8px)"
|
|
265
283
|
})
|
|
266
284
|
}, [
|
|
267
|
-
|
|
268
|
-
|
|
285
|
+
_("span", { class: b(Q("tooltipLabel")) }, D(X.value.label), 3),
|
|
286
|
+
X.value.multi ? (C(!0), g(f, { key: 0 }, T(X.value.rows, (e) => (C(), g("span", {
|
|
269
287
|
key: e.name,
|
|
270
288
|
class: "flex items-center gap-1.5"
|
|
271
289
|
}, [
|
|
272
|
-
|
|
290
|
+
_("span", {
|
|
273
291
|
class: "size-2 shrink-0 rounded-full",
|
|
274
|
-
style:
|
|
292
|
+
style: S({ background: e.color })
|
|
275
293
|
}, null, 4),
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
]))), 128)) : (
|
|
294
|
+
_("span", { class: b(Q("tooltipLabel")) }, D(e.name), 3),
|
|
295
|
+
_("span", { class: b(Q("tooltipValue")) }, D(e.value), 3)
|
|
296
|
+
]))), 128)) : (C(), g("span", {
|
|
279
297
|
key: 1,
|
|
280
|
-
class:
|
|
281
|
-
},
|
|
282
|
-
|
|
283
|
-
t[1] ||=
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
])) :
|
|
287
|
-
], 6)) :
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
298
|
+
class: b(Q("tooltipValue"))
|
|
299
|
+
}, D(X.value.rows[0].value), 3)),
|
|
300
|
+
X.value.total ? (C(), g("span", oe, [
|
|
301
|
+
t[1] ||= _("span", { class: "size-2 shrink-0" }, null, -1),
|
|
302
|
+
_("span", { class: b(Q("tooltipLabel")) }, D(A.totalLabel), 3),
|
|
303
|
+
_("span", { class: b(Q("tooltipValue")) }, D(X.value.total), 3)
|
|
304
|
+
])) : h("", !0)
|
|
305
|
+
], 6)) : h("", !0)], 2),
|
|
306
|
+
_("div", { class: b(Q("table")) }, [_("table", null, [
|
|
307
|
+
_("caption", null, D(A.label), 1),
|
|
308
|
+
_("thead", null, [_("tr", null, [t[2] ||= _("th", { scope: "col" }, " Category ", -1), (C(!0), g(f, null, T(I.value, (e) => (C(), g("th", {
|
|
291
309
|
key: e.key,
|
|
292
310
|
scope: "col"
|
|
293
|
-
},
|
|
294
|
-
|
|
311
|
+
}, D(e.name ?? "Value"), 1))), 128))])]),
|
|
312
|
+
_("tbody", null, [(C(!0), g(f, null, T(A.data, (e, t) => (C(), g("tr", { key: `row-${e.label}-${t}` }, [_("th", se, D(e.label), 1), (C(!0), g(f, null, T(I.value, (t) => (C(), g("td", { key: t.key }, D(R(e, t.key) == null ? "—" : F(R(e, t.key))), 1))), 128))]))), 128))])
|
|
295
313
|
])], 2)
|
|
296
314
|
], 10, ee));
|
|
297
315
|
}
|
|
298
316
|
});
|
|
299
317
|
//#endregion
|
|
300
|
-
export {
|
|
318
|
+
export { A as default };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { ChartAnimate } from '../composables/chart-reveal';
|
|
2
|
+
import type { SparseValue } from '../composables/scale';
|
|
3
|
+
/**
|
|
4
|
+
* One slice. Unlike the cartesian charts there is no second axis to hold a
|
|
5
|
+
* series, so the row *is* the identity: its `label` names it and its `slot`
|
|
6
|
+
* pins its colour.
|
|
7
|
+
*/
|
|
8
|
+
export interface DonutChartDatum {
|
|
9
|
+
label: string;
|
|
10
|
+
/** `null` is a missing reading — the slice is dropped, which is not a zero. */
|
|
11
|
+
value?: SparseValue;
|
|
12
|
+
/**
|
|
13
|
+
* Pin this slice to a palette slot (0-based) instead of taking its position
|
|
14
|
+
* in the array. Pin every slice that can be filtered out, so the survivors
|
|
15
|
+
* keep the colours the reader already learned.
|
|
16
|
+
*/
|
|
17
|
+
slot?: number;
|
|
18
|
+
}
|
|
19
|
+
export interface DonutChartProps {
|
|
20
|
+
data?: readonly DonutChartDatum[];
|
|
21
|
+
/**
|
|
22
|
+
* Rendered height in px. The ring is a circle centred in whatever width the
|
|
23
|
+
* container gives, so this is also its diameter once the box is wide enough.
|
|
24
|
+
*/
|
|
25
|
+
size?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Ring thickness in px. Defaults to two fifths of the radius, which keeps
|
|
28
|
+
* the hole large enough to hold a total at every size. Ignored when `pie`.
|
|
29
|
+
*/
|
|
30
|
+
thickness?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Fill the middle in and draw a pie instead.
|
|
33
|
+
*
|
|
34
|
+
* The ring is the better default: a pie asks the reader to compare angles
|
|
35
|
+
* and areas, a donut only arc lengths, and the hole is somewhere to put the
|
|
36
|
+
* total the slices add up to.
|
|
37
|
+
*/
|
|
38
|
+
pie?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* The gap between neighbouring slices, in px. `0` closes it and lets them
|
|
41
|
+
* touch.
|
|
42
|
+
*
|
|
43
|
+
* A width rather than an angle, and held the same all the way across: each
|
|
44
|
+
* edge is pushed half a gap off its own radius, so the divider reads as a
|
|
45
|
+
* line instead of a wedge that widens towards the rim. In a pie that is
|
|
46
|
+
* also why a slice stops a hair short of the centre — two parallel edges
|
|
47
|
+
* meet before they reach it.
|
|
48
|
+
*/
|
|
49
|
+
gap?: number;
|
|
50
|
+
/**
|
|
51
|
+
* Sweep the ring open on the first paint. Skipped for a reader who has
|
|
52
|
+
* asked for reduced motion, and played once — not again when the data
|
|
53
|
+
* changes underneath it.
|
|
54
|
+
*/
|
|
55
|
+
animate?: ChartAnimate;
|
|
56
|
+
/** Drop the legend. */
|
|
57
|
+
legend?: boolean;
|
|
58
|
+
/** Locale and options for every number shown — the total and the tooltip. */
|
|
59
|
+
locale?: string;
|
|
60
|
+
format?: Intl.NumberFormatOptions;
|
|
61
|
+
/**
|
|
62
|
+
* Accessible name for the figure. The slices are hidden from assistive tech
|
|
63
|
+
* and the data is exposed as a table instead, so this names what that is.
|
|
64
|
+
*/
|
|
65
|
+
label?: string;
|
|
66
|
+
/** Skip built-in classes; you take over styling entirely. */
|
|
67
|
+
unstyled?: boolean;
|
|
68
|
+
class?: string;
|
|
69
|
+
ui?: Partial<Record<'root' | 'svg' | 'slice' | 'center' | 'tooltip' | 'tooltipLabel' | 'tooltipValue' | 'tooltipShare' | 'table', string>>;
|
|
70
|
+
}
|
|
71
|
+
type __VLS_Slots = {
|
|
72
|
+
/**
|
|
73
|
+
* The hole. Given the total and its formatted form, so the usual figure
|
|
74
|
+
* plus caption is one line of markup.
|
|
75
|
+
*/
|
|
76
|
+
center?: (props: {
|
|
77
|
+
total: number;
|
|
78
|
+
formatted: string;
|
|
79
|
+
}) => unknown;
|
|
80
|
+
};
|
|
81
|
+
declare const __VLS_base: import("vue").DefineComponent<DonutChartProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<DonutChartProps> & Readonly<{}>, {
|
|
82
|
+
size: number;
|
|
83
|
+
unstyled: boolean;
|
|
84
|
+
data: readonly DonutChartDatum[];
|
|
85
|
+
legend: boolean;
|
|
86
|
+
animate: ChartAnimate;
|
|
87
|
+
gap: number;
|
|
88
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
89
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
90
|
+
declare const _default: typeof __VLS_export;
|
|
91
|
+
export default _default;
|
|
92
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
93
|
+
new (): {
|
|
94
|
+
$slots: S;
|
|
95
|
+
};
|
|
96
|
+
};
|