@lostgradient/cinder 0.22.0 → 0.23.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/CHANGELOG.md +31 -0
- package/components.json +1 -1
- package/dist/_internal/chart/chart-bar-model.d.ts +24 -0
- package/dist/_internal/chart/chart-cartesian-model.d.ts +16 -0
- package/dist/_internal/chart/chart-layout.d.ts +23 -0
- package/dist/_internal/chart/chart-model-utilities.d.ts +157 -0
- package/dist/_internal/chart/chart-scale.d.ts +37 -0
- package/dist/_internal/chart/chart-utilities.d.ts +7 -164
- package/dist/_internal/chart/heatmap-utilities.d.ts +5 -4
- package/dist/components/_internal/chart-tooltip.css +21 -0
- package/dist/components/_internal/chart-tooltip.svelte.d.ts +11 -0
- package/dist/components/approval-card/index.js +5 -5
- package/dist/components/area-chart/area-chart.css +27 -23
- package/dist/components/area-chart/area-chart.schema.js +38 -1
- package/dist/components/area-chart/area-chart.types.d.ts +6 -2
- package/dist/components/area-chart/index.js +1589 -768
- package/dist/components/badge/badge.css +2 -2
- package/dist/components/badge/badge.schema.js +2 -2
- package/dist/components/badge/badge.types.d.ts +3 -3
- package/dist/components/badge/index.js +4 -4
- package/dist/components/bar-chart/bar-chart.css +27 -21
- package/dist/components/bar-chart/bar-chart.schema.js +38 -1
- package/dist/components/bar-chart/bar-chart.types.d.ts +7 -3
- package/dist/components/bar-chart/index.js +1544 -740
- package/dist/components/chart.types.d.ts +98 -2
- package/dist/components/json-schema-editor/index.js +4 -4
- package/dist/components/line-chart/index.js +1587 -785
- package/dist/components/line-chart/line-chart.css +25 -24
- package/dist/components/line-chart/line-chart.schema.js +38 -1
- package/dist/components/line-chart/line-chart.types.d.ts +6 -2
- package/dist/components/matrix-chart/index.js +1038 -429
- package/dist/components/matrix-chart/matrix-chart.css +12 -6
- package/dist/components/matrix-chart/matrix-chart.schema.js +26 -1
- package/dist/components/matrix-chart/matrix-chart.types.d.ts +5 -1
- package/dist/components/payload-inspector/index.js +4 -4
- package/dist/components/run-step-timeline/index.js +6 -6
- package/dist/components/sparkbar/index.js +1291 -4
- package/dist/components/sparkbar/sparkbar.css +5 -4
- package/dist/components/sparkbar/sparkbar.schema.js +26 -1
- package/dist/components/sparkbar/sparkbar.types.d.ts +5 -0
- package/dist/components/spectrogram/index.js +1076 -437
- package/dist/components/spectrogram/spectrogram.css +7 -6
- package/dist/components/spectrogram/spectrogram.schema.js +26 -1
- package/dist/components/spectrogram/spectrogram.types.d.ts +5 -1
- package/dist/components/spectrum-chart/index.js +1037 -423
- package/dist/components/spectrum-chart/spectrum-chart.css +8 -7
- package/dist/components/spectrum-chart/spectrum-chart.schema.js +26 -1
- package/dist/components/spectrum-chart/spectrum-chart.types.d.ts +5 -1
- package/dist/components/statistic/index.js +1284 -2
- package/dist/components/statistic/statistic.css +6 -5
- package/dist/components/statistic/statistic.schema.js +26 -1
- package/dist/components/statistic/statistic.types.d.ts +5 -0
- package/dist/components/statistic-group/index.js +1284 -2
- package/dist/components/waveform/index.js +1004 -404
- package/dist/components/waveform/waveform.css +8 -7
- package/dist/components/waveform/waveform.schema.js +26 -1
- package/dist/components/waveform/waveform.types.d.ts +5 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +17730 -16540
- package/dist/server/components/approval-card/index.js +3 -3
- package/dist/server/components/area-chart/index.js +3 -3
- package/dist/server/components/badge/index.js +2 -2
- package/dist/server/components/bar-chart/index.js +3 -3
- package/dist/server/components/json-schema-editor/index.js +2 -2
- package/dist/server/components/line-chart/index.js +3 -3
- package/dist/server/components/matrix-chart/index.js +3 -3
- package/dist/server/components/payload-inspector/index.js +3 -3
- package/dist/server/components/run-step-timeline/index.js +2 -2
- package/dist/server/components/sparkbar/index.js +3 -2
- package/dist/server/components/spectrogram/index.js +3 -3
- package/dist/server/components/spectrum-chart/index.js +2 -2
- package/dist/server/components/statistic/index.js +4 -3
- package/dist/server/components/statistic-group/index.js +4 -3
- package/dist/server/components/waveform/index.js +2 -2
- package/dist/server/index.js +21 -21
- package/dist/server/{index.server-3dkwzkd3.js → index.server-10r7yf13.js} +110 -27
- package/dist/server/{index.server-93943z3e.js → index.server-151dt1tx.js} +1 -1
- package/dist/server/{index.server-pp2n6def.js → index.server-2y0xz53g.js} +37 -14
- package/dist/server/{index.server-bd8rcgf0.js → index.server-4hvjet4z.js} +1 -1
- package/dist/server/{index.server-bsm39gpy.js → index.server-5d83fkyg.js} +75 -21
- package/dist/server/{index.server-4wweyb2e.js → index.server-8dh2rtnc.js} +1 -1
- package/dist/server/{index.server-abqbstkt.js → index.server-9gj583qs.js} +41 -14
- package/dist/server/{index.server-2nmwsacy.js → index.server-9scm7zf9.js} +4 -4
- package/dist/server/{index.server-5j6jv7rm.js → index.server-9vwxyy06.js} +108 -29
- package/dist/server/{index.server-abjsjsw8.js → index.server-afpjvfz1.js} +111 -35
- package/dist/server/{index.server-86sw5ea6.js → index.server-dw9bz17h.js} +4 -4
- package/dist/server/{index.server-d26jzn2m.js → index.server-en31rprd.js} +3 -3
- package/dist/server/{index.server-dx58qant.js → index.server-f3a0ecqg.js} +72 -9
- package/dist/server/{index.server-d63pwytk.js → index.server-kz8aeeq5.js} +18 -10
- package/dist/server/index.server-mmmrgvyd.js +1274 -0
- package/dist/server/{index.server-1221p7e4.js → index.server-scahngwv.js} +13 -1
- package/dist/server/{index.server-nj8kk5bv.js → index.server-t73q59c1.js} +1 -1
- package/dist/server/{index.server-5schb2vt.js → index.server-tdrncj5e.js} +16 -6
- package/dist/server/{index.server-wm8957be.js → index.server-veqke4sq.js} +10 -1
- package/dist/server/{index.server-fphvzcfb.js → index.server-wqajghn9.js} +1 -1
- package/dist/server/{index.server-yd9shwqq.js → index.server-zjcjzcv6.js} +1 -1
- package/package.json +1 -1
- package/src/_internal/chart/chart-bar-model.ts +330 -0
- package/src/_internal/chart/chart-cartesian-model.ts +450 -0
- package/src/_internal/chart/chart-interaction.svelte.ts +25 -6
- package/src/_internal/chart/chart-layout.ts +348 -0
- package/src/_internal/chart/chart-model-utilities.ts +357 -0
- package/src/_internal/chart/chart-scale.ts +487 -0
- package/src/_internal/chart/chart-utilities.ts +22 -1078
- package/src/_internal/chart/heatmap-utilities.ts +21 -17
- package/src/components/_internal/chart-tooltip.css +21 -0
- package/src/components/_internal/chart-tooltip.svelte +44 -0
- package/src/components/approval-card/approval-card.svelte +1 -1
- package/src/components/area-chart/area-chart.css +27 -23
- package/src/components/area-chart/area-chart.examples.json +1 -1
- package/src/components/area-chart/area-chart.schema.json +37 -0
- package/src/components/area-chart/area-chart.schema.ts +40 -0
- package/src/components/area-chart/area-chart.svelte +103 -35
- package/src/components/area-chart/area-chart.types.ts +7 -1
- package/src/components/badge/badge.css +2 -2
- package/src/components/badge/badge.schema.json +1 -1
- package/src/components/badge/badge.schema.ts +1 -1
- package/src/components/badge/badge.svelte +2 -2
- package/src/components/badge/badge.types.ts +3 -3
- package/src/components/bar-chart/bar-chart.css +27 -21
- package/src/components/bar-chart/bar-chart.schema.json +37 -0
- package/src/components/bar-chart/bar-chart.schema.ts +40 -0
- package/src/components/bar-chart/bar-chart.svelte +94 -33
- package/src/components/bar-chart/bar-chart.types.ts +9 -2
- package/src/components/chart.types.ts +112 -2
- package/src/components/line-chart/line-chart.css +25 -24
- package/src/components/line-chart/line-chart.examples.json +1 -1
- package/src/components/line-chart/line-chart.schema.json +37 -0
- package/src/components/line-chart/line-chart.schema.ts +40 -0
- package/src/components/line-chart/line-chart.svelte +95 -40
- package/src/components/line-chart/line-chart.types.ts +7 -1
- package/src/components/matrix-chart/matrix-chart.css +12 -6
- package/src/components/matrix-chart/matrix-chart.schema.json +25 -0
- package/src/components/matrix-chart/matrix-chart.schema.ts +25 -0
- package/src/components/matrix-chart/matrix-chart.svelte +30 -12
- package/src/components/matrix-chart/matrix-chart.types.ts +5 -1
- package/src/components/run-step-timeline/run-step-timeline.svelte +2 -2
- package/src/components/sparkbar/sparkbar.css +5 -4
- package/src/components/sparkbar/sparkbar.schema.json +25 -0
- package/src/components/sparkbar/sparkbar.schema.ts +26 -0
- package/src/components/sparkbar/sparkbar.svelte +8 -1
- package/src/components/sparkbar/sparkbar.types.ts +5 -0
- package/src/components/spectrogram/spectrogram.css +7 -6
- package/src/components/spectrogram/spectrogram.schema.json +25 -0
- package/src/components/spectrogram/spectrogram.schema.ts +25 -0
- package/src/components/spectrogram/spectrogram.svelte +73 -28
- package/src/components/spectrogram/spectrogram.types.ts +5 -1
- package/src/components/spectrum-chart/spectrum-chart.css +8 -7
- package/src/components/spectrum-chart/spectrum-chart.schema.json +25 -0
- package/src/components/spectrum-chart/spectrum-chart.schema.ts +26 -0
- package/src/components/spectrum-chart/spectrum-chart.svelte +38 -12
- package/src/components/spectrum-chart/spectrum-chart.types.ts +5 -1
- package/src/components/statistic/statistic.css +6 -5
- package/src/components/statistic/statistic.schema.json +25 -0
- package/src/components/statistic/statistic.schema.ts +26 -0
- package/src/components/statistic/statistic.svelte +6 -1
- package/src/components/statistic/statistic.types.ts +5 -0
- package/src/components/waveform/waveform.css +8 -7
- package/src/components/waveform/waveform.schema.json +25 -0
- package/src/components/waveform/waveform.schema.ts +26 -0
- package/src/components/waveform/waveform.svelte +16 -3
- package/src/components/waveform/waveform.types.ts +5 -1
- package/src/index.ts +8 -0
- package/dist/server/index.server-6vbpz6dd.js +0 -690
|
@@ -18,7 +18,7 @@ const subscriptionStateConfigurations = {
|
|
|
18
18
|
expired: { variant: 'danger', label: 'Expired' },
|
|
19
19
|
refunded: { variant: 'neutral', label: 'Refunded' },
|
|
20
20
|
};
|
|
21
|
-
let { variant = 'neutral', size = 'md',
|
|
21
|
+
let { variant = 'neutral', size = 'md', monospace = false, subscriptionState, class: customClassName, children, ...rest } = $props();
|
|
22
22
|
const subscriptionStateConfiguration = $derived(subscriptionState === undefined
|
|
23
23
|
? undefined
|
|
24
24
|
: subscriptionStateConfigurations[subscriptionState]);
|
|
@@ -29,7 +29,7 @@ const resolvedVariant = $derived(subscriptionStateConfiguration?.variant ?? vari
|
|
|
29
29
|
class={classNames('cinder-badge', customClassName)}
|
|
30
30
|
data-cinder-variant={resolvedVariant}
|
|
31
31
|
data-cinder-size={size}
|
|
32
|
-
data-cinder-
|
|
32
|
+
data-cinder-monospace={monospace ? '' : undefined}
|
|
33
33
|
data-cinder-subscription-state={subscriptionState}
|
|
34
34
|
{...rest}
|
|
35
35
|
>
|
|
@@ -22,7 +22,7 @@ export type BadgeProps =
|
|
|
22
22
|
variant?: BadgeVariant;
|
|
23
23
|
size?: BadgeSize;
|
|
24
24
|
/** Render the badge label in a monospace font. */
|
|
25
|
-
|
|
25
|
+
monospace?: boolean;
|
|
26
26
|
class?: string;
|
|
27
27
|
/** Render a standardized subscription lifecycle badge without hand-wiring tone, icon, and label. */
|
|
28
28
|
subscriptionState: BadgeSubscriptionState;
|
|
@@ -33,7 +33,7 @@ export type BadgeProps =
|
|
|
33
33
|
variant?: BadgeVariant;
|
|
34
34
|
size?: BadgeSize;
|
|
35
35
|
/** Render the badge label in a monospace font. */
|
|
36
|
-
|
|
36
|
+
monospace?: boolean;
|
|
37
37
|
class?: string;
|
|
38
38
|
subscriptionState?: undefined;
|
|
39
39
|
/**
|
|
@@ -59,7 +59,7 @@ export interface BadgeSchemaProps {
|
|
|
59
59
|
* Render the badge label in a monospace font. Useful for version strings, error codes, or other technical labels.
|
|
60
60
|
* @default false
|
|
61
61
|
*/
|
|
62
|
-
|
|
62
|
+
monospace?: boolean;
|
|
63
63
|
/** Render a standardized subscription lifecycle badge without hand-wiring tone, icon, and label. */
|
|
64
64
|
subscriptionState?: BadgeSubscriptionState;
|
|
65
65
|
/** Custom class merged with `.cinder-badge`. */
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
@layer cinder.tokens, cinder.foundation, cinder.components, cinder.utilities;
|
|
2
2
|
@import '../table/table.css';
|
|
3
|
+
@import '../_internal/chart-tooltip.css';
|
|
3
4
|
@layer cinder.components {
|
|
4
5
|
.cinder-bar-chart {
|
|
5
6
|
display: grid;
|
|
6
7
|
gap: var(--cinder-space-3);
|
|
7
|
-
color: var(--
|
|
8
|
+
color: var(--_cinder-chart-foreground, currentColor);
|
|
9
|
+
background: var(--_cinder-chart-background, transparent);
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
.cinder-bar-chart__description {
|
|
11
13
|
margin: 0;
|
|
12
|
-
color: var(--
|
|
14
|
+
color: var(--_cinder-chart-muted, currentColor);
|
|
15
|
+
opacity: 0.72;
|
|
13
16
|
font-size: var(--cinder-text-sm);
|
|
14
17
|
}
|
|
15
18
|
|
|
@@ -25,8 +28,8 @@
|
|
|
25
28
|
gap: var(--cinder-space-1);
|
|
26
29
|
border: 1px solid var(--cinder-border);
|
|
27
30
|
border-radius: var(--cinder-radius-sm);
|
|
28
|
-
background: var(--
|
|
29
|
-
color:
|
|
31
|
+
background: var(--_cinder-chart-background, transparent);
|
|
32
|
+
color: inherit;
|
|
30
33
|
cursor: pointer;
|
|
31
34
|
font: inherit;
|
|
32
35
|
font-size: var(--cinder-text-sm);
|
|
@@ -55,6 +58,11 @@
|
|
|
55
58
|
|
|
56
59
|
.cinder-bar-chart__bar {
|
|
57
60
|
rx: 3;
|
|
61
|
+
transition:
|
|
62
|
+
x 0.3s ease,
|
|
63
|
+
y 0.3s ease,
|
|
64
|
+
width 0.3s ease,
|
|
65
|
+
height 0.3s ease;
|
|
58
66
|
}
|
|
59
67
|
|
|
60
68
|
.cinder-bar-chart__bar[data-cinder-active] {
|
|
@@ -62,8 +70,9 @@
|
|
|
62
70
|
}
|
|
63
71
|
|
|
64
72
|
.cinder-bar-chart__crosshair {
|
|
65
|
-
stroke: var(--
|
|
73
|
+
stroke: var(--_cinder-chart-muted, currentColor);
|
|
66
74
|
stroke-dasharray: 4 4;
|
|
75
|
+
opacity: 0.72;
|
|
67
76
|
}
|
|
68
77
|
|
|
69
78
|
.cinder-bar-chart__hit-surface {
|
|
@@ -136,32 +145,29 @@
|
|
|
136
145
|
}
|
|
137
146
|
}
|
|
138
147
|
|
|
139
|
-
.cinder-bar-chart__tick-label
|
|
140
|
-
|
|
148
|
+
.cinder-bar-chart__tick-label,
|
|
149
|
+
.cinder-bar-chart__axis-title {
|
|
150
|
+
fill: var(--_cinder-chart-muted, currentColor);
|
|
141
151
|
font-size: var(--cinder-text-xs);
|
|
142
152
|
}
|
|
143
153
|
|
|
154
|
+
.cinder-bar-chart__tick-label {
|
|
155
|
+
opacity: 0.72;
|
|
156
|
+
}
|
|
157
|
+
|
|
144
158
|
.cinder-bar-chart__state {
|
|
145
159
|
position: absolute;
|
|
146
160
|
inset: 0;
|
|
147
161
|
display: grid;
|
|
148
162
|
place-items: center;
|
|
149
|
-
color: var(--
|
|
150
|
-
background:
|
|
163
|
+
color: var(--_cinder-chart-muted, currentColor);
|
|
164
|
+
background: var(--_cinder-chart-background, transparent);
|
|
151
165
|
z-index: 1;
|
|
152
166
|
}
|
|
153
167
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
gap: 0.125rem;
|
|
159
|
-
border: 1px solid var(--cinder-border);
|
|
160
|
-
border-radius: var(--cinder-radius-sm);
|
|
161
|
-
background: var(--cinder-surface-raised);
|
|
162
|
-
box-shadow: var(--cinder-shadow-md);
|
|
163
|
-
font-size: var(--cinder-text-sm);
|
|
164
|
-
padding: var(--cinder-space-2);
|
|
165
|
-
pointer-events: none;
|
|
168
|
+
@media (prefers-reduced-motion: reduce) {
|
|
169
|
+
.cinder-bar-chart__bar {
|
|
170
|
+
transition: none;
|
|
171
|
+
}
|
|
166
172
|
}
|
|
167
173
|
}
|
|
@@ -22,6 +22,9 @@
|
|
|
22
22
|
},
|
|
23
23
|
"tickCount": {
|
|
24
24
|
"type": "number"
|
|
25
|
+
},
|
|
26
|
+
"tickLabelRotation": {
|
|
27
|
+
"type": "number"
|
|
25
28
|
}
|
|
26
29
|
},
|
|
27
30
|
"additionalProperties": false,
|
|
@@ -67,6 +70,35 @@
|
|
|
67
70
|
"type": "number",
|
|
68
71
|
"description": "Maximum number of interactive focus targets before keyboard navigation is disabled. Default `500`."
|
|
69
72
|
},
|
|
73
|
+
"theme": {
|
|
74
|
+
"type": "object",
|
|
75
|
+
"properties": {
|
|
76
|
+
"foreground": {
|
|
77
|
+
"type": "string"
|
|
78
|
+
},
|
|
79
|
+
"muted": {
|
|
80
|
+
"type": "string"
|
|
81
|
+
},
|
|
82
|
+
"grid": {
|
|
83
|
+
"type": "string"
|
|
84
|
+
},
|
|
85
|
+
"background": {
|
|
86
|
+
"type": "string"
|
|
87
|
+
},
|
|
88
|
+
"palette": {
|
|
89
|
+
"type": "array",
|
|
90
|
+
"items": {
|
|
91
|
+
"type": "string"
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
"additionalProperties": false,
|
|
96
|
+
"description": "Partial visual theme override. Omitted fields inherit the surrounding application."
|
|
97
|
+
},
|
|
98
|
+
"tooltip": {
|
|
99
|
+
"type": "boolean",
|
|
100
|
+
"description": "Enable the default visual tooltip. Custom snippet tooltips are available in the TypeScript API."
|
|
101
|
+
},
|
|
70
102
|
"class": {
|
|
71
103
|
"type": "string",
|
|
72
104
|
"description": "Custom class applied to the root element."
|
|
@@ -138,6 +170,11 @@
|
|
|
138
170
|
{
|
|
139
171
|
"name": "loadingContent",
|
|
140
172
|
"reason": "function-or-snippet"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"name": "mark",
|
|
176
|
+
"reason": "function-or-snippet",
|
|
177
|
+
"description": "Per-series renderer override. The chart retains scales, guides, focus, and data-table semantics."
|
|
141
178
|
}
|
|
142
179
|
]
|
|
143
180
|
}
|
|
@@ -25,6 +25,9 @@ const schema = {
|
|
|
25
25
|
tickCount: {
|
|
26
26
|
type: 'number',
|
|
27
27
|
},
|
|
28
|
+
tickLabelRotation: {
|
|
29
|
+
type: 'number',
|
|
30
|
+
},
|
|
28
31
|
},
|
|
29
32
|
additionalProperties: false,
|
|
30
33
|
description: 'Configuration for the x-axis label and tick count.',
|
|
@@ -71,6 +74,37 @@ const schema = {
|
|
|
71
74
|
description:
|
|
72
75
|
'Maximum number of interactive focus targets before keyboard navigation is disabled. Default `500`.',
|
|
73
76
|
},
|
|
77
|
+
theme: {
|
|
78
|
+
type: 'object',
|
|
79
|
+
properties: {
|
|
80
|
+
foreground: {
|
|
81
|
+
type: 'string',
|
|
82
|
+
},
|
|
83
|
+
muted: {
|
|
84
|
+
type: 'string',
|
|
85
|
+
},
|
|
86
|
+
grid: {
|
|
87
|
+
type: 'string',
|
|
88
|
+
},
|
|
89
|
+
background: {
|
|
90
|
+
type: 'string',
|
|
91
|
+
},
|
|
92
|
+
palette: {
|
|
93
|
+
type: 'array',
|
|
94
|
+
items: {
|
|
95
|
+
type: 'string',
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
additionalProperties: false,
|
|
100
|
+
description:
|
|
101
|
+
'Partial visual theme override. Omitted fields inherit the surrounding application.',
|
|
102
|
+
},
|
|
103
|
+
tooltip: {
|
|
104
|
+
type: 'boolean',
|
|
105
|
+
description:
|
|
106
|
+
'Enable the default visual tooltip. Custom snippet tooltips are available in the TypeScript API.',
|
|
107
|
+
},
|
|
74
108
|
class: {
|
|
75
109
|
type: 'string',
|
|
76
110
|
description: 'Custom class applied to the root element.',
|
|
@@ -146,6 +180,12 @@ const schema = {
|
|
|
146
180
|
name: 'loadingContent',
|
|
147
181
|
reason: 'function-or-snippet',
|
|
148
182
|
},
|
|
183
|
+
{
|
|
184
|
+
name: 'mark',
|
|
185
|
+
reason: 'function-or-snippet',
|
|
186
|
+
description:
|
|
187
|
+
'Per-series renderer override. The chart retains scales, guides, focus, and data-table semantics.',
|
|
188
|
+
},
|
|
149
189
|
],
|
|
150
190
|
},
|
|
151
191
|
} satisfies ComponentSchema;
|
|
@@ -3,12 +3,14 @@ export {};
|
|
|
3
3
|
</script>
|
|
4
4
|
|
|
5
5
|
<script lang="ts">
|
|
6
|
-
import {
|
|
6
|
+
import { onMount } from 'svelte';
|
|
7
|
+
import { assertValidNonNegativeInteger, chartPaletteColor, createBarModel, dataTableClass, formatNumericValue, legendVisible, observeChartFontLoading, } from '../../_internal/chart/chart-utilities.ts';
|
|
7
8
|
import { DEFAULT_CHART_FOCUS_RING_STROKE_PADDING, createBarFocusRingGeometry, } from '../../_internal/chart/chart-focus-ring.ts';
|
|
8
9
|
import { ChartInteraction } from '../../_internal/chart/chart-interaction.svelte.ts';
|
|
9
10
|
import ChartDataTable from '../_internal/chart-data-table.svelte';
|
|
11
|
+
import ChartTooltip from '../_internal/chart-tooltip.svelte';
|
|
10
12
|
import { classNames } from '../../utilities/class-names.ts';
|
|
11
|
-
let { label, description, data, categoryKey, series, orientation = 'vertical', mode = 'grouped', height = 280, xAxis, yAxis, legendPosition = 'top', hiddenSeriesIds = $bindable([]), loading = false, dataTableCaption, dataTableVisibility = 'screen-reader-only', maximumInteractivePoints = 500, class: customClassName, empty, loadingContent, id, ...rest } = $props();
|
|
13
|
+
let { label, description, data, categoryKey, series, orientation = 'vertical', mode = 'grouped', height = 280, xAxis, yAxis, legendPosition = 'top', hiddenSeriesIds = $bindable([]), loading = false, dataTableCaption, dataTableVisibility = 'screen-reader-only', maximumInteractivePoints = 500, theme, tooltip = false, mark, class: customClassName, empty, loadingContent, id, ...rest } = $props();
|
|
12
14
|
const generatedId = $props.id();
|
|
13
15
|
const rootId = $derived(id ?? generatedId);
|
|
14
16
|
const descriptionId = $derived(description ? `${rootId}-description` : undefined);
|
|
@@ -21,6 +23,14 @@ const interaction = new ChartInteraction({
|
|
|
21
23
|
pointerAxis: () => (orientation === 'vertical' ? 'x' : 'y'),
|
|
22
24
|
});
|
|
23
25
|
let rootElement = $state();
|
|
26
|
+
let measureText = $state(false);
|
|
27
|
+
let measurementVersion = $state(0);
|
|
28
|
+
onMount(() => {
|
|
29
|
+
measureText = true;
|
|
30
|
+
return observeChartFontLoading(() => {
|
|
31
|
+
measurementVersion += 1;
|
|
32
|
+
});
|
|
33
|
+
});
|
|
24
34
|
$effect(() => {
|
|
25
35
|
if (!rootElement)
|
|
26
36
|
return;
|
|
@@ -37,7 +47,22 @@ const model = $derived(createBarModel({
|
|
|
37
47
|
mode,
|
|
38
48
|
xAxis,
|
|
39
49
|
yAxis,
|
|
50
|
+
theme,
|
|
51
|
+
measureText,
|
|
52
|
+
measurementElement: rootElement,
|
|
53
|
+
measurementVersion,
|
|
40
54
|
}));
|
|
55
|
+
const barsBySeriesId = $derived.by(() => {
|
|
56
|
+
const groupedBars = new Map();
|
|
57
|
+
for (const bar of model.bars) {
|
|
58
|
+
const bars = groupedBars.get(bar.seriesId);
|
|
59
|
+
if (bars)
|
|
60
|
+
bars.push(bar);
|
|
61
|
+
else
|
|
62
|
+
groupedBars.set(bar.seriesId, [bar]);
|
|
63
|
+
}
|
|
64
|
+
return groupedBars;
|
|
65
|
+
});
|
|
41
66
|
const keyboardEnabled = $derived(model.targets.length > 0 && model.targets.length <= maximumInteractivePoints);
|
|
42
67
|
const hasDataTable = $derived(dataTableVisibility !== 'hidden');
|
|
43
68
|
const guidanceId = $derived(!keyboardEnabled && hasDataTable && model.targets.length > 0
|
|
@@ -104,6 +129,10 @@ function handleTargetKeydown(event) {
|
|
|
104
129
|
bind:this={rootElement}
|
|
105
130
|
id={rootId}
|
|
106
131
|
class={classNames('cinder-bar-chart', customClassName)}
|
|
132
|
+
style:--_cinder-chart-foreground={model.theme.foreground}
|
|
133
|
+
style:--_cinder-chart-muted={model.theme.muted}
|
|
134
|
+
style:--_cinder-chart-grid={model.theme.grid}
|
|
135
|
+
style:--_cinder-chart-background={model.theme.background}
|
|
107
136
|
aria-label={label}
|
|
108
137
|
aria-describedby={descriptionId}
|
|
109
138
|
data-cinder-orientation={orientation}
|
|
@@ -119,7 +148,7 @@ function handleTargetKeydown(event) {
|
|
|
119
148
|
type="button"
|
|
120
149
|
aria-pressed={!hiddenSeriesIds.includes(item.id)}
|
|
121
150
|
onclick={() => (hiddenSeriesIds = interaction.toggleSeries(hiddenSeriesIds, item.id))}
|
|
122
|
-
><span style:background={item.color ?? chartPaletteColor(index)}
|
|
151
|
+
><span style:background={item.color ?? chartPaletteColor(index, model.theme.palette)}
|
|
123
152
|
></span>{item.label}</button
|
|
124
153
|
>
|
|
125
154
|
{/each}
|
|
@@ -165,6 +194,9 @@ function handleTargetKeydown(event) {
|
|
|
165
194
|
((tick - model.valueDomain[0]) / (model.valueDomain[1] - model.valueDomain[0])) *
|
|
166
195
|
model.geometry.plotHeight
|
|
167
196
|
: model.geometry.plotHeight + 20}
|
|
197
|
+
transform={orientation === 'horizontal' && xAxis?.tickLabelRotation
|
|
198
|
+
? `rotate(${xAxis.tickLabelRotation} ${((tick - model.valueDomain[0]) / (model.valueDomain[1] - model.valueDomain[0])) * model.geometry.plotWidth} ${model.geometry.plotHeight + 20})`
|
|
199
|
+
: undefined}
|
|
168
200
|
text-anchor={orientation === 'vertical' ? 'end' : 'middle'}
|
|
169
201
|
dominant-baseline={orientation === 'vertical' ? 'middle' : undefined}
|
|
170
202
|
>{formatNumericValue(tick, orientation === 'vertical' ? yAxis : xAxis, undefined, {
|
|
@@ -172,24 +204,45 @@ function handleTargetKeydown(event) {
|
|
|
172
204
|
})}</text
|
|
173
205
|
>
|
|
174
206
|
{/each}
|
|
207
|
+
{#if yAxis?.label}
|
|
208
|
+
<text
|
|
209
|
+
class="cinder-bar-chart__axis-title"
|
|
210
|
+
x={-model.geometry.plotHeight / 2}
|
|
211
|
+
y={-model.geometry.marginLeft + 12}
|
|
212
|
+
text-anchor="middle"
|
|
213
|
+
transform="rotate(-90)">{yAxis.label}</text
|
|
214
|
+
>
|
|
215
|
+
{/if}
|
|
175
216
|
<!-- Series-specific rendering: rectangular bars. -->
|
|
176
|
-
{#
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
217
|
+
{#if mark}
|
|
218
|
+
{#each series as item (item.id)}
|
|
219
|
+
{#if !hiddenSeriesIds.includes(item.id)}
|
|
220
|
+
{@render mark({
|
|
221
|
+
series: item,
|
|
222
|
+
points: barsBySeriesId.get(item.id) ?? [],
|
|
223
|
+
geometry: model.geometry,
|
|
224
|
+
})}
|
|
225
|
+
{/if}
|
|
226
|
+
{/each}
|
|
227
|
+
{:else}
|
|
228
|
+
{#each model.bars as bar (bar.id)}
|
|
229
|
+
<rect
|
|
230
|
+
class="cinder-bar-chart__bar"
|
|
231
|
+
x={bar.x}
|
|
232
|
+
y={bar.y}
|
|
233
|
+
width={bar.width}
|
|
234
|
+
height={bar.height}
|
|
235
|
+
fill={bar.color}
|
|
236
|
+
aria-hidden="true"
|
|
237
|
+
data-cinder-series={bar.seriesId}
|
|
238
|
+
data-cinder-category={bar.categoryLabel}
|
|
239
|
+
data-cinder-active={interaction.activeTarget?.seriesId === bar.seriesId &&
|
|
240
|
+
interaction.activeTarget?.xLabel === bar.categoryLabel
|
|
241
|
+
? ''
|
|
242
|
+
: undefined}
|
|
243
|
+
/>
|
|
244
|
+
{/each}
|
|
245
|
+
{/if}
|
|
193
246
|
{#each model.categoryTicks as tick (tick.categoryKey)}
|
|
194
247
|
<!--
|
|
195
248
|
Category axis labels differ by orientation:
|
|
@@ -200,12 +253,23 @@ function handleTargetKeydown(event) {
|
|
|
200
253
|
class="cinder-bar-chart__tick-label"
|
|
201
254
|
x={tick.x}
|
|
202
255
|
y={tick.y}
|
|
256
|
+
transform={orientation === 'vertical' && xAxis?.tickLabelRotation
|
|
257
|
+
? `rotate(${xAxis.tickLabelRotation} ${tick.x} ${tick.y})`
|
|
258
|
+
: undefined}
|
|
203
259
|
text-anchor={orientation === 'vertical' ? 'middle' : 'end'}
|
|
204
260
|
dominant-baseline={orientation === 'vertical' ? undefined : 'middle'}
|
|
205
261
|
>{#if tick.label !== tick.fullLabel}<title>{tick.fullLabel}</title
|
|
206
262
|
>{/if}{tick.label}</text
|
|
207
263
|
>
|
|
208
264
|
{/each}
|
|
265
|
+
{#if xAxis?.label}
|
|
266
|
+
<text
|
|
267
|
+
class="cinder-bar-chart__axis-title"
|
|
268
|
+
x={model.geometry.plotWidth / 2}
|
|
269
|
+
y={model.geometry.plotHeight + model.geometry.marginBottom - 4}
|
|
270
|
+
text-anchor="middle">{xAxis.label}</text
|
|
271
|
+
>
|
|
272
|
+
{/if}
|
|
209
273
|
{#if interaction.activeTarget}
|
|
210
274
|
<!--
|
|
211
275
|
Bar chart crosshair direction depends on orientation:
|
|
@@ -264,7 +328,7 @@ function handleTargetKeydown(event) {
|
|
|
264
328
|
? 'true'
|
|
265
329
|
: undefined}
|
|
266
330
|
aria-label={`${target.seriesLabel}, ${target.xLabel}, ${target.valueLabel}`}
|
|
267
|
-
aria-describedby={interaction.activeTarget?.id === target.id
|
|
331
|
+
aria-describedby={tooltip && interaction.activeTarget?.id === target.id
|
|
268
332
|
? `${rootId}-tooltip`
|
|
269
333
|
: undefined}
|
|
270
334
|
onfocus={() => handleTargetFocus(target)}
|
|
@@ -297,17 +361,14 @@ function handleTargetKeydown(event) {
|
|
|
297
361
|
</g>
|
|
298
362
|
{/if}
|
|
299
363
|
</svg>
|
|
300
|
-
{#if
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
>{interaction.activeTarget.xLabel}: {interaction.activeTarget.valueLabel}</span
|
|
309
|
-
>
|
|
310
|
-
</div>{/if}
|
|
364
|
+
{#if tooltip}
|
|
365
|
+
<ChartTooltip
|
|
366
|
+
id={`${rootId}-tooltip`}
|
|
367
|
+
target={interaction.activeTarget}
|
|
368
|
+
geometry={model.geometry}
|
|
369
|
+
content={tooltip}
|
|
370
|
+
/>
|
|
371
|
+
{/if}
|
|
311
372
|
</div>
|
|
312
373
|
{#if guidanceId}<p id={guidanceId} class="cinder-sr-only">
|
|
313
374
|
Use the data table to inspect this chart with a keyboard.
|
|
@@ -339,7 +400,7 @@ function handleTargetKeydown(event) {
|
|
|
339
400
|
type="button"
|
|
340
401
|
aria-pressed={!hiddenSeriesIds.includes(item.id)}
|
|
341
402
|
onclick={() => (hiddenSeriesIds = interaction.toggleSeries(hiddenSeriesIds, item.id))}
|
|
342
|
-
><span style:background={item.color ?? chartPaletteColor(index)}
|
|
403
|
+
><span style:background={item.color ?? chartPaletteColor(index, model.theme.palette)}
|
|
343
404
|
></span>{item.label}</button
|
|
344
405
|
>
|
|
345
406
|
{/each}
|
|
@@ -2,6 +2,7 @@ import type {
|
|
|
2
2
|
BarChartDatum,
|
|
3
3
|
BarChartMode,
|
|
4
4
|
BarChartOrientation,
|
|
5
|
+
BarChartPlacedBar,
|
|
5
6
|
BarChartSchemaDatum,
|
|
6
7
|
BarChartSchemaSeries,
|
|
7
8
|
BarChartSeries,
|
|
@@ -9,9 +10,11 @@ import type {
|
|
|
9
10
|
ChartDataTableVisibility,
|
|
10
11
|
ChartLegendPosition,
|
|
11
12
|
ChartSharedProps,
|
|
13
|
+
ChartThemeSchema,
|
|
14
|
+
ChartXAxisSchemaConfiguration,
|
|
12
15
|
} from '../chart.types.ts';
|
|
13
16
|
|
|
14
|
-
export type BarChartProps = ChartSharedProps & {
|
|
17
|
+
export type BarChartProps = ChartSharedProps<BarChartSeries, BarChartPlacedBar> & {
|
|
15
18
|
/** Rows containing the category and value-key fields used by each series. */
|
|
16
19
|
data: BarChartDatum[];
|
|
17
20
|
/** Datum key used for the category axis. Runtime validation requires string, number, or Date values. */
|
|
@@ -32,7 +35,7 @@ export type BarChartSchemaProps = {
|
|
|
32
35
|
/** Pixel height of the chart viewport. Default `280`. */
|
|
33
36
|
height?: number;
|
|
34
37
|
/** Configuration for the x-axis label and tick count. */
|
|
35
|
-
xAxis?:
|
|
38
|
+
xAxis?: ChartXAxisSchemaConfiguration;
|
|
36
39
|
/** Configuration for the y-axis label and tick count. */
|
|
37
40
|
yAxis?: ChartAxisSchemaConfiguration;
|
|
38
41
|
/** Where to render the series legend relative to the chart. Default `top`. */
|
|
@@ -47,6 +50,10 @@ export type BarChartSchemaProps = {
|
|
|
47
50
|
dataTableVisibility?: ChartDataTableVisibility;
|
|
48
51
|
/** Maximum number of interactive focus targets before keyboard navigation is disabled. Default `500`. */
|
|
49
52
|
maximumInteractivePoints?: number;
|
|
53
|
+
/** Partial visual theme override. Omitted fields inherit the surrounding application. */
|
|
54
|
+
theme?: ChartThemeSchema;
|
|
55
|
+
/** Enable the default visual tooltip. Custom snippet tooltips are available in the TypeScript API. */
|
|
56
|
+
tooltip?: boolean;
|
|
50
57
|
/** Custom class applied to the root element. */
|
|
51
58
|
class?: string;
|
|
52
59
|
/** JSON-safe data rows. Schema cannot express dynamic categoryKey/valueKey relationships; runtime validation narrows value-key fields to number, null, or undefined. */
|
|
@@ -25,6 +25,11 @@ export type ChartAxisConfiguration = {
|
|
|
25
25
|
format?: ChartTickFormatter;
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
+
export type ChartXAxisConfiguration = ChartAxisConfiguration & {
|
|
29
|
+
/** Tick-label rotation in degrees. Default `0`. */
|
|
30
|
+
tickLabelRotation?: number;
|
|
31
|
+
};
|
|
32
|
+
|
|
28
33
|
export type ChartPoint = {
|
|
29
34
|
x: ChartXValue;
|
|
30
35
|
y: ChartNumericValue;
|
|
@@ -38,7 +43,90 @@ export type ChartCartesianSeries = {
|
|
|
38
43
|
valueFormatter?: ChartValueFormatter;
|
|
39
44
|
};
|
|
40
45
|
|
|
41
|
-
export type
|
|
46
|
+
export type ChartTheme = {
|
|
47
|
+
foreground?: string;
|
|
48
|
+
muted?: string;
|
|
49
|
+
grid?: string;
|
|
50
|
+
background?: string;
|
|
51
|
+
palette?: string[];
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export type ResolvedChartTheme = {
|
|
55
|
+
foreground: string;
|
|
56
|
+
muted: string;
|
|
57
|
+
grid: string;
|
|
58
|
+
background: string;
|
|
59
|
+
palette: string[];
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export type NormalizedXValue = {
|
|
63
|
+
raw: ChartXValue;
|
|
64
|
+
key: string;
|
|
65
|
+
label: string;
|
|
66
|
+
comparable: string | number;
|
|
67
|
+
kind: 'string' | 'number' | 'date';
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export type PlacedPoint = {
|
|
71
|
+
seriesId: string;
|
|
72
|
+
seriesLabel: string;
|
|
73
|
+
color: string;
|
|
74
|
+
x: NormalizedXValue;
|
|
75
|
+
y: number | null;
|
|
76
|
+
originalY: ChartNumericValue;
|
|
77
|
+
index: number;
|
|
78
|
+
pixelX: number;
|
|
79
|
+
pixelY: number;
|
|
80
|
+
/** Pixel-space baseline for filled marks. In stacked areas, this is the lower stack coordinate. */
|
|
81
|
+
pixelY0: number;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export type ChartGeometry = {
|
|
85
|
+
plotWidth: number;
|
|
86
|
+
plotHeight: number;
|
|
87
|
+
marginTop: number;
|
|
88
|
+
marginRight: number;
|
|
89
|
+
marginBottom: number;
|
|
90
|
+
marginLeft: number;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export type ChartTarget = {
|
|
94
|
+
id: string;
|
|
95
|
+
seriesId: string;
|
|
96
|
+
seriesLabel: string;
|
|
97
|
+
xLabel: string;
|
|
98
|
+
valueLabel: string;
|
|
99
|
+
x: number;
|
|
100
|
+
y: number;
|
|
101
|
+
width?: number;
|
|
102
|
+
height?: number;
|
|
103
|
+
color: string;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export type BarChartPlacedBar = {
|
|
107
|
+
id: string;
|
|
108
|
+
seriesId: string;
|
|
109
|
+
seriesLabel: string;
|
|
110
|
+
categoryLabel: string;
|
|
111
|
+
valueLabel: string;
|
|
112
|
+
x: number;
|
|
113
|
+
y: number;
|
|
114
|
+
width: number;
|
|
115
|
+
height: number;
|
|
116
|
+
color: string;
|
|
117
|
+
hidden: boolean;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export type ChartMarkContext<TSeries = ChartCartesianSeries, TPoint = PlacedPoint> = {
|
|
121
|
+
series: TSeries;
|
|
122
|
+
points: TPoint[];
|
|
123
|
+
geometry: ChartGeometry;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
export type ChartSharedProps<TSeries = ChartCartesianSeries, TPoint = PlacedPoint> = Omit<
|
|
127
|
+
HTMLAttributes<HTMLElement>,
|
|
128
|
+
'class'
|
|
129
|
+
> & {
|
|
42
130
|
/** Accessible label for the chart. Required for screen readers. */
|
|
43
131
|
label: string;
|
|
44
132
|
/** Optional description rendered below the label. */
|
|
@@ -46,7 +134,7 @@ export type ChartSharedProps = Omit<HTMLAttributes<HTMLElement>, 'class'> & {
|
|
|
46
134
|
/** Pixel height of the chart viewport. Default `280`. */
|
|
47
135
|
height?: number;
|
|
48
136
|
/** Configuration for the x-axis label and tick formatting. */
|
|
49
|
-
xAxis?:
|
|
137
|
+
xAxis?: ChartXAxisConfiguration;
|
|
50
138
|
/** Configuration for the y-axis label and tick formatting. */
|
|
51
139
|
yAxis?: ChartAxisConfiguration;
|
|
52
140
|
/** Where to render the series legend relative to the chart. Default `top`. */
|
|
@@ -61,6 +149,12 @@ export type ChartSharedProps = Omit<HTMLAttributes<HTMLElement>, 'class'> & {
|
|
|
61
149
|
dataTableVisibility?: ChartDataTableVisibility;
|
|
62
150
|
/** Maximum number of interactive focus targets before keyboard navigation is disabled. Default `500`. */
|
|
63
151
|
maximumInteractivePoints?: number;
|
|
152
|
+
/** Partial visual theme override. Omitted fields inherit the surrounding application. */
|
|
153
|
+
theme?: ChartTheme;
|
|
154
|
+
/** Opt-in visual tooltip. Pass a snippet to replace the default visual content. */
|
|
155
|
+
tooltip?: boolean | Snippet<[ChartTarget]>;
|
|
156
|
+
/** Per-series renderer override. The chart retains scales, guides, focus, and data-table semantics. */
|
|
157
|
+
mark?: Snippet<[ChartMarkContext<TSeries, TPoint>]>;
|
|
64
158
|
/** Custom class applied to the root element. */
|
|
65
159
|
class?: string;
|
|
66
160
|
empty?: Snippet;
|
|
@@ -90,6 +184,22 @@ export type ChartAxisSchemaConfiguration = {
|
|
|
90
184
|
tickCount?: number;
|
|
91
185
|
};
|
|
92
186
|
|
|
187
|
+
/** @schemaObject */
|
|
188
|
+
export type ChartXAxisSchemaConfiguration = {
|
|
189
|
+
label?: string;
|
|
190
|
+
tickCount?: number;
|
|
191
|
+
tickLabelRotation?: number;
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
/** @schemaObject */
|
|
195
|
+
export type ChartThemeSchema = {
|
|
196
|
+
foreground?: string;
|
|
197
|
+
muted?: string;
|
|
198
|
+
grid?: string;
|
|
199
|
+
background?: string;
|
|
200
|
+
palette?: string[];
|
|
201
|
+
};
|
|
202
|
+
|
|
93
203
|
/** @schemaObject */
|
|
94
204
|
export type ChartSchemaPoint = {
|
|
95
205
|
x: ChartJsonXValue;
|