@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
|
@@ -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-line-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-line-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);
|
|
@@ -56,7 +59,8 @@
|
|
|
56
59
|
}
|
|
57
60
|
|
|
58
61
|
.cinder-line-chart__gridline {
|
|
59
|
-
stroke: var(--
|
|
62
|
+
stroke: var(--_cinder-chart-grid, currentColor);
|
|
63
|
+
opacity: 0.22;
|
|
60
64
|
stroke-width: 1;
|
|
61
65
|
}
|
|
62
66
|
|
|
@@ -65,10 +69,12 @@
|
|
|
65
69
|
stroke-width: 2.25;
|
|
66
70
|
stroke-linecap: round;
|
|
67
71
|
stroke-linejoin: round;
|
|
72
|
+
transition: d 0.3s ease;
|
|
68
73
|
}
|
|
69
74
|
|
|
70
75
|
.cinder-line-chart__crosshair {
|
|
71
|
-
stroke: var(--
|
|
76
|
+
stroke: var(--_cinder-chart-muted, currentColor);
|
|
77
|
+
opacity: 0.72;
|
|
72
78
|
stroke-dasharray: 4 4;
|
|
73
79
|
}
|
|
74
80
|
|
|
@@ -142,34 +148,29 @@
|
|
|
142
148
|
}
|
|
143
149
|
}
|
|
144
150
|
|
|
145
|
-
.cinder-line-chart__tick-label
|
|
146
|
-
|
|
151
|
+
.cinder-line-chart__tick-label,
|
|
152
|
+
.cinder-line-chart__axis-title {
|
|
153
|
+
fill: var(--_cinder-chart-muted, currentColor);
|
|
147
154
|
font-size: var(--cinder-text-xs);
|
|
148
155
|
}
|
|
149
156
|
|
|
157
|
+
.cinder-line-chart__tick-label {
|
|
158
|
+
opacity: 0.72;
|
|
159
|
+
}
|
|
160
|
+
|
|
150
161
|
.cinder-line-chart__state {
|
|
151
162
|
position: absolute;
|
|
152
163
|
inset: 0;
|
|
153
164
|
display: grid;
|
|
154
165
|
place-items: center;
|
|
155
|
-
color: var(--
|
|
156
|
-
background:
|
|
166
|
+
color: var(--_cinder-chart-muted, currentColor);
|
|
167
|
+
background: var(--_cinder-chart-background, transparent);
|
|
157
168
|
z-index: 1;
|
|
158
169
|
}
|
|
159
170
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
gap: 0.125rem;
|
|
165
|
-
max-inline-size: 16rem;
|
|
166
|
-
border: 1px solid var(--cinder-border);
|
|
167
|
-
border-radius: var(--cinder-radius-sm);
|
|
168
|
-
background: var(--cinder-surface-raised);
|
|
169
|
-
box-shadow: var(--cinder-shadow-md);
|
|
170
|
-
color: var(--cinder-text);
|
|
171
|
-
font-size: var(--cinder-text-sm);
|
|
172
|
-
padding: var(--cinder-space-2);
|
|
173
|
-
pointer-events: none;
|
|
171
|
+
@media (prefers-reduced-motion: reduce) {
|
|
172
|
+
.cinder-line-chart__line {
|
|
173
|
+
transition: none;
|
|
174
|
+
}
|
|
174
175
|
}
|
|
175
176
|
}
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"title": "Revenue trend",
|
|
21
21
|
"description": "A single-series line chart for monthly recurring revenue.",
|
|
22
22
|
"featured": true,
|
|
23
|
-
"code": "<script lang=\"ts\">\n import { LineChart } from '@lostgradient/cinder/line-chart';\n\n const series = [\n {\n id: 'revenue',\n label: 'Revenue',\n data: [\n { x: 'Jan', y: 120 },\n { x: 'Feb', y: 148 },\n { x: 'Mar', y: 172 },\n { x: 'Apr', y: 196 },\n ],\n },\n ];\n</script>\n\n<LineChart label=\"Monthly recurring revenue\" {series} dataTableVisibility=\"visible\" />\n"
|
|
23
|
+
"code": "<script lang=\"ts\">\n import { LineChart } from '@lostgradient/cinder/line-chart';\n\n const series = [\n {\n id: 'revenue',\n label: 'Revenue',\n data: [\n { x: 'Jan', y: 120 },\n { x: 'Feb', y: 148 },\n { x: 'Mar', y: 172 },\n { x: 'Apr', y: 196 },\n ],\n },\n ];\n</script>\n\n<LineChart label=\"Monthly recurring revenue\" {series} tooltip dataTableVisibility=\"visible\" />\n"
|
|
24
24
|
}
|
|
25
25
|
]
|
|
26
26
|
}
|
|
@@ -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."
|
|
@@ -133,6 +165,11 @@
|
|
|
133
165
|
{
|
|
134
166
|
"name": "loadingContent",
|
|
135
167
|
"reason": "function-or-snippet"
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
"name": "mark",
|
|
171
|
+
"reason": "function-or-snippet",
|
|
172
|
+
"description": "Per-series renderer override. The chart retains scales, guides, focus, and data-table semantics."
|
|
136
173
|
}
|
|
137
174
|
]
|
|
138
175
|
}
|
|
@@ -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.',
|
|
@@ -138,6 +172,12 @@ const schema = {
|
|
|
138
172
|
name: 'loadingContent',
|
|
139
173
|
reason: 'function-or-snippet',
|
|
140
174
|
},
|
|
175
|
+
{
|
|
176
|
+
name: 'mark',
|
|
177
|
+
reason: 'function-or-snippet',
|
|
178
|
+
description:
|
|
179
|
+
'Per-series renderer override. The chart retains scales, guides, focus, and data-table semantics.',
|
|
180
|
+
},
|
|
141
181
|
],
|
|
142
182
|
},
|
|
143
183
|
} 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, createCartesianModel, dataTableClass, formatDataTableCaption, formatNumericValue, legendVisible, observeChartFontLoading, } from '../../_internal/chart/chart-utilities.ts';
|
|
7
8
|
import { DEFAULT_CHART_FOCUS_RING_STROKE_PADDING, createPointFocusRingGeometry, } 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, series, 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, series, 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);
|
|
@@ -16,6 +18,14 @@ const descriptionId = $derived(description ? `${rootId}-description` : undefined
|
|
|
16
18
|
// Pointer axis defaults to 'x', which is correct for line/area charts.
|
|
17
19
|
const interaction = new ChartInteraction();
|
|
18
20
|
let rootElement = $state();
|
|
21
|
+
let measureText = $state(false);
|
|
22
|
+
let measurementVersion = $state(0);
|
|
23
|
+
onMount(() => {
|
|
24
|
+
measureText = true;
|
|
25
|
+
return observeChartFontLoading(() => {
|
|
26
|
+
measurementVersion += 1;
|
|
27
|
+
});
|
|
28
|
+
});
|
|
19
29
|
$effect(() => {
|
|
20
30
|
if (!rootElement)
|
|
21
31
|
return;
|
|
@@ -29,6 +39,10 @@ const model = $derived(createCartesianModel({
|
|
|
29
39
|
height,
|
|
30
40
|
xAxis,
|
|
31
41
|
yAxis,
|
|
42
|
+
theme,
|
|
43
|
+
measureText,
|
|
44
|
+
measurementElement: rootElement,
|
|
45
|
+
measurementVersion,
|
|
32
46
|
}));
|
|
33
47
|
const keyboardEnabled = $derived(model.targets.length > 0 && model.targets.length <= maximumInteractivePoints);
|
|
34
48
|
const hasDataTable = $derived(dataTableVisibility !== 'hidden');
|
|
@@ -96,6 +110,10 @@ function handleTargetKeydown(event) {
|
|
|
96
110
|
bind:this={rootElement}
|
|
97
111
|
id={rootId}
|
|
98
112
|
class={classNames('cinder-line-chart', customClassName)}
|
|
113
|
+
style:--_cinder-chart-foreground={model.theme.foreground}
|
|
114
|
+
style:--_cinder-chart-muted={model.theme.muted}
|
|
115
|
+
style:--_cinder-chart-grid={model.theme.grid}
|
|
116
|
+
style:--_cinder-chart-background={model.theme.background}
|
|
99
117
|
aria-label={label}
|
|
100
118
|
aria-describedby={descriptionId}
|
|
101
119
|
>
|
|
@@ -111,7 +129,8 @@ function handleTargetKeydown(event) {
|
|
|
111
129
|
aria-pressed={!hiddenSeriesIds.includes(item.id)}
|
|
112
130
|
onclick={() => (hiddenSeriesIds = interaction.toggleSeries(hiddenSeriesIds, item.id))}
|
|
113
131
|
>
|
|
114
|
-
<span style:background={item.color ?? chartPaletteColor(index)}
|
|
132
|
+
<span style:background={item.color ?? chartPaletteColor(index, model.theme.palette)}
|
|
133
|
+
></span>{item.label}
|
|
115
134
|
</button>
|
|
116
135
|
{/each}
|
|
117
136
|
</div>
|
|
@@ -161,39 +180,74 @@ function handleTargetKeydown(event) {
|
|
|
161
180
|
>{formatNumericValue(tick, yAxis, undefined, { index })}</text
|
|
162
181
|
>
|
|
163
182
|
{/each}
|
|
183
|
+
{#if yAxis?.label}
|
|
184
|
+
<text
|
|
185
|
+
class="cinder-line-chart__axis-title"
|
|
186
|
+
x={-model.geometry.plotHeight / 2}
|
|
187
|
+
y={-model.geometry.marginLeft + 12}
|
|
188
|
+
text-anchor="middle"
|
|
189
|
+
transform="rotate(-90)">{yAxis.label}</text
|
|
190
|
+
>
|
|
191
|
+
{/if}
|
|
164
192
|
{#each model.xTicks as tick (tick.label)}
|
|
165
193
|
<text
|
|
166
194
|
class="cinder-line-chart__tick-label"
|
|
167
195
|
x={tick.x}
|
|
168
196
|
y={model.geometry.plotHeight + 20}
|
|
197
|
+
transform={xAxis?.tickLabelRotation
|
|
198
|
+
? `rotate(${xAxis.tickLabelRotation} ${tick.x} ${model.geometry.plotHeight + 20})`
|
|
199
|
+
: undefined}
|
|
169
200
|
text-anchor="middle">{tick.label}</text
|
|
170
201
|
>
|
|
171
202
|
{/each}
|
|
203
|
+
{#if xAxis?.label}
|
|
204
|
+
<text
|
|
205
|
+
class="cinder-line-chart__axis-title"
|
|
206
|
+
x={model.geometry.plotWidth / 2}
|
|
207
|
+
y={model.geometry.plotHeight + model.geometry.marginBottom - 4}
|
|
208
|
+
text-anchor="middle">{xAxis.label}</text
|
|
209
|
+
>
|
|
210
|
+
{/if}
|
|
172
211
|
<!-- Series-specific rendering: connected line paths + data points. -->
|
|
173
|
-
{#
|
|
174
|
-
{#
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
{#if point.y !== null}
|
|
184
|
-
<circle
|
|
185
|
-
class="cinder-line-chart__point"
|
|
186
|
-
cx={point.pixelX}
|
|
187
|
-
cy={point.pixelY}
|
|
188
|
-
r="3"
|
|
189
|
-
fill={item.color}
|
|
190
|
-
aria-hidden="true"
|
|
191
|
-
data-cinder-series={item.id}
|
|
192
|
-
/>
|
|
212
|
+
{#if mark}
|
|
213
|
+
{#each model.normalizedSeries as item (item.id)}
|
|
214
|
+
{#if !hiddenSeriesIds.includes(item.id)}
|
|
215
|
+
{@const sourceSeries = series.find((candidate) => candidate.id === item.id)}
|
|
216
|
+
{#if sourceSeries}
|
|
217
|
+
{@render mark({
|
|
218
|
+
series: sourceSeries,
|
|
219
|
+
points: item.points,
|
|
220
|
+
geometry: model.geometry,
|
|
221
|
+
})}
|
|
193
222
|
{/if}
|
|
194
|
-
{/
|
|
195
|
-
{/
|
|
196
|
-
{
|
|
223
|
+
{/if}
|
|
224
|
+
{/each}
|
|
225
|
+
{:else}
|
|
226
|
+
{#each model.normalizedSeries as item (item.id)}
|
|
227
|
+
{#if !hiddenSeriesIds.includes(item.id) && item.path}
|
|
228
|
+
<path
|
|
229
|
+
class="cinder-line-chart__line"
|
|
230
|
+
d={item.path}
|
|
231
|
+
stroke={item.color}
|
|
232
|
+
aria-hidden="true"
|
|
233
|
+
data-cinder-series={item.id}
|
|
234
|
+
/>
|
|
235
|
+
{#each item.points as point (point.x.key)}
|
|
236
|
+
{#if point.y !== null}
|
|
237
|
+
<circle
|
|
238
|
+
class="cinder-line-chart__point"
|
|
239
|
+
cx={point.pixelX}
|
|
240
|
+
cy={point.pixelY}
|
|
241
|
+
r="3"
|
|
242
|
+
fill={item.color}
|
|
243
|
+
aria-hidden="true"
|
|
244
|
+
data-cinder-series={item.id}
|
|
245
|
+
/>
|
|
246
|
+
{/if}
|
|
247
|
+
{/each}
|
|
248
|
+
{/if}
|
|
249
|
+
{/each}
|
|
250
|
+
{/if}
|
|
197
251
|
{#if interaction.activeTarget}
|
|
198
252
|
<!-- Vertical crosshair — line charts always use a vertical indicator. -->
|
|
199
253
|
<line
|
|
@@ -230,7 +284,7 @@ function handleTargetKeydown(event) {
|
|
|
230
284
|
? 'true'
|
|
231
285
|
: undefined}
|
|
232
286
|
aria-label={`${target.seriesLabel}, ${target.xLabel}, ${target.valueLabel}`}
|
|
233
|
-
aria-describedby={interaction.activeTarget?.id === target.id
|
|
287
|
+
aria-describedby={tooltip && interaction.activeTarget?.id === target.id
|
|
234
288
|
? `${rootId}-tooltip`
|
|
235
289
|
: undefined}
|
|
236
290
|
onfocus={() => handleTargetFocus(target)}
|
|
@@ -300,17 +354,13 @@ function handleTargetKeydown(event) {
|
|
|
300
354
|
</g>
|
|
301
355
|
{/if}
|
|
302
356
|
</svg>
|
|
303
|
-
{#if
|
|
304
|
-
<
|
|
305
|
-
id=
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
>
|
|
311
|
-
<strong>{interaction.activeTarget.seriesLabel}</strong>
|
|
312
|
-
<span>{interaction.activeTarget.xLabel}: {interaction.activeTarget.valueLabel}</span>
|
|
313
|
-
</div>
|
|
357
|
+
{#if tooltip}
|
|
358
|
+
<ChartTooltip
|
|
359
|
+
id={`${rootId}-tooltip`}
|
|
360
|
+
target={interaction.activeTarget}
|
|
361
|
+
geometry={model.geometry}
|
|
362
|
+
content={tooltip}
|
|
363
|
+
/>
|
|
314
364
|
{/if}
|
|
315
365
|
</div>
|
|
316
366
|
|
|
@@ -322,7 +372,11 @@ function handleTargetKeydown(event) {
|
|
|
322
372
|
|
|
323
373
|
{#if hasDataTable}
|
|
324
374
|
<ChartDataTable
|
|
325
|
-
caption={
|
|
375
|
+
caption={formatDataTableCaption(
|
|
376
|
+
dataTableCaption ?? label,
|
|
377
|
+
model.tableRows.length,
|
|
378
|
+
model.targets.length,
|
|
379
|
+
)}
|
|
326
380
|
headers={['Series', 'X', 'Value']}
|
|
327
381
|
rows={model.tableRows.map((row) => ({
|
|
328
382
|
id: row.id,
|
|
@@ -342,7 +396,8 @@ function handleTargetKeydown(event) {
|
|
|
342
396
|
aria-pressed={!hiddenSeriesIds.includes(item.id)}
|
|
343
397
|
onclick={() => (hiddenSeriesIds = interaction.toggleSeries(hiddenSeriesIds, item.id))}
|
|
344
398
|
>
|
|
345
|
-
<span style:background={item.color ?? chartPaletteColor(index)}
|
|
399
|
+
<span style:background={item.color ?? chartPaletteColor(index, model.theme.palette)}
|
|
400
|
+
></span>{item.label}
|
|
346
401
|
</button>
|
|
347
402
|
{/each}
|
|
348
403
|
</div>
|
|
@@ -5,6 +5,8 @@ import type {
|
|
|
5
5
|
ChartJsonXValue,
|
|
6
6
|
ChartLegendPosition,
|
|
7
7
|
ChartSharedProps,
|
|
8
|
+
ChartThemeSchema,
|
|
9
|
+
ChartXAxisSchemaConfiguration,
|
|
8
10
|
} from '../chart.types.ts';
|
|
9
11
|
|
|
10
12
|
export type LineChartProps = ChartSharedProps & {
|
|
@@ -34,7 +36,7 @@ export type LineChartSchemaProps = {
|
|
|
34
36
|
/** Pixel height of the chart viewport. Default `280`. */
|
|
35
37
|
height?: number;
|
|
36
38
|
/** Configuration for the x-axis label and tick count. */
|
|
37
|
-
xAxis?:
|
|
39
|
+
xAxis?: ChartXAxisSchemaConfiguration;
|
|
38
40
|
/** Configuration for the y-axis label and tick count. */
|
|
39
41
|
yAxis?: ChartAxisSchemaConfiguration;
|
|
40
42
|
/** Where to render the series legend relative to the chart. Default `top`. */
|
|
@@ -49,6 +51,10 @@ export type LineChartSchemaProps = {
|
|
|
49
51
|
dataTableVisibility?: ChartDataTableVisibility;
|
|
50
52
|
/** Maximum number of interactive focus targets before keyboard navigation is disabled. Default `500`. */
|
|
51
53
|
maximumInteractivePoints?: number;
|
|
54
|
+
/** Partial visual theme override. Omitted fields inherit the surrounding application. */
|
|
55
|
+
theme?: ChartThemeSchema;
|
|
56
|
+
/** Enable the default visual tooltip. Custom snippet tooltips are available in the TypeScript API. */
|
|
57
|
+
tooltip?: boolean;
|
|
52
58
|
/** Custom class applied to the root element. */
|
|
53
59
|
class?: string;
|
|
54
60
|
/** Series to render as one or more connected line paths. */
|
|
@@ -4,12 +4,13 @@
|
|
|
4
4
|
.cinder-matrix-chart {
|
|
5
5
|
display: grid;
|
|
6
6
|
gap: var(--cinder-space-3);
|
|
7
|
-
color: var(--
|
|
7
|
+
color: var(--_cinder-chart-foreground, currentColor);
|
|
8
|
+
background: var(--_cinder-chart-background, transparent);
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
.cinder-matrix-chart__description {
|
|
11
12
|
margin: 0;
|
|
12
|
-
color: var(--
|
|
13
|
+
color: var(--_cinder-chart-muted, currentColor);
|
|
13
14
|
font-size: var(--cinder-text-sm);
|
|
14
15
|
}
|
|
15
16
|
|
|
@@ -25,7 +26,7 @@
|
|
|
25
26
|
|
|
26
27
|
.cinder-matrix-chart__cell {
|
|
27
28
|
rx: 2;
|
|
28
|
-
stroke: var(--
|
|
29
|
+
stroke: var(--_cinder-chart-grid, currentColor);
|
|
29
30
|
stroke-width: 1.5;
|
|
30
31
|
}
|
|
31
32
|
|
|
@@ -33,13 +34,18 @@
|
|
|
33
34
|
filter: brightness(1.15);
|
|
34
35
|
}
|
|
35
36
|
|
|
37
|
+
.cinder-matrix-chart__cell-group {
|
|
38
|
+
isolation: isolate;
|
|
39
|
+
}
|
|
40
|
+
|
|
36
41
|
.cinder-matrix-chart__cell-label {
|
|
37
42
|
font-size: var(--cinder-text-xs);
|
|
43
|
+
mix-blend-mode: difference;
|
|
38
44
|
pointer-events: none;
|
|
39
45
|
}
|
|
40
46
|
|
|
41
47
|
.cinder-matrix-chart__tick-label {
|
|
42
|
-
fill: var(--
|
|
48
|
+
fill: var(--_cinder-chart-muted, currentColor);
|
|
43
49
|
font-size: var(--cinder-text-xs);
|
|
44
50
|
}
|
|
45
51
|
|
|
@@ -48,8 +54,8 @@
|
|
|
48
54
|
inset: 0;
|
|
49
55
|
display: grid;
|
|
50
56
|
place-items: center;
|
|
51
|
-
color: var(--
|
|
52
|
-
background:
|
|
57
|
+
color: var(--_cinder-chart-muted, currentColor);
|
|
58
|
+
background: var(--_cinder-chart-background, transparent);
|
|
53
59
|
z-index: 1;
|
|
54
60
|
}
|
|
55
61
|
}
|
|
@@ -71,6 +71,31 @@
|
|
|
71
71
|
"description": "Controls data table visibility. Default `screen-reader-only`.",
|
|
72
72
|
"default": "screen-reader-only"
|
|
73
73
|
},
|
|
74
|
+
"theme": {
|
|
75
|
+
"type": "object",
|
|
76
|
+
"properties": {
|
|
77
|
+
"foreground": {
|
|
78
|
+
"type": "string"
|
|
79
|
+
},
|
|
80
|
+
"muted": {
|
|
81
|
+
"type": "string"
|
|
82
|
+
},
|
|
83
|
+
"grid": {
|
|
84
|
+
"type": "string"
|
|
85
|
+
},
|
|
86
|
+
"background": {
|
|
87
|
+
"type": "string"
|
|
88
|
+
},
|
|
89
|
+
"palette": {
|
|
90
|
+
"type": "array",
|
|
91
|
+
"items": {
|
|
92
|
+
"type": "string"
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
"additionalProperties": false,
|
|
97
|
+
"description": "Partial visual theme override."
|
|
98
|
+
},
|
|
74
99
|
"class": {
|
|
75
100
|
"type": "string",
|
|
76
101
|
"description": "Custom class applied to the root element."
|
|
@@ -74,6 +74,31 @@ const schema = {
|
|
|
74
74
|
description: 'Controls data table visibility. Default `screen-reader-only`.',
|
|
75
75
|
default: 'screen-reader-only',
|
|
76
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: 'Partial visual theme override.',
|
|
101
|
+
},
|
|
77
102
|
class: {
|
|
78
103
|
type: 'string',
|
|
79
104
|
description: 'Custom class applied to the root element.',
|