@lostgradient/cinder 0.22.0 → 0.23.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/components.json +1 -1
  3. package/dist/_internal/chart/chart-bar-model.d.ts +24 -0
  4. package/dist/_internal/chart/chart-cartesian-model.d.ts +16 -0
  5. package/dist/_internal/chart/chart-layout.d.ts +23 -0
  6. package/dist/_internal/chart/chart-model-utilities.d.ts +157 -0
  7. package/dist/_internal/chart/chart-scale.d.ts +37 -0
  8. package/dist/_internal/chart/chart-utilities.d.ts +7 -164
  9. package/dist/_internal/chart/heatmap-utilities.d.ts +5 -4
  10. package/dist/components/_internal/chart-tooltip.css +21 -0
  11. package/dist/components/_internal/chart-tooltip.svelte.d.ts +11 -0
  12. package/dist/components/approval-card/index.js +5 -5
  13. package/dist/components/area-chart/area-chart.css +27 -23
  14. package/dist/components/area-chart/area-chart.schema.js +38 -1
  15. package/dist/components/area-chart/area-chart.types.d.ts +6 -2
  16. package/dist/components/area-chart/index.js +1589 -768
  17. package/dist/components/badge/badge.css +2 -2
  18. package/dist/components/badge/badge.schema.js +2 -2
  19. package/dist/components/badge/badge.types.d.ts +3 -3
  20. package/dist/components/badge/index.js +4 -4
  21. package/dist/components/bar-chart/bar-chart.css +27 -21
  22. package/dist/components/bar-chart/bar-chart.schema.js +38 -1
  23. package/dist/components/bar-chart/bar-chart.types.d.ts +7 -3
  24. package/dist/components/bar-chart/index.js +1544 -740
  25. package/dist/components/chart.types.d.ts +98 -2
  26. package/dist/components/json-schema-editor/index.js +4 -4
  27. package/dist/components/line-chart/index.js +1587 -785
  28. package/dist/components/line-chart/line-chart.css +25 -24
  29. package/dist/components/line-chart/line-chart.schema.js +38 -1
  30. package/dist/components/line-chart/line-chart.types.d.ts +6 -2
  31. package/dist/components/matrix-chart/index.js +1038 -429
  32. package/dist/components/matrix-chart/matrix-chart.css +12 -6
  33. package/dist/components/matrix-chart/matrix-chart.schema.js +26 -1
  34. package/dist/components/matrix-chart/matrix-chart.types.d.ts +5 -1
  35. package/dist/components/payload-inspector/index.js +4 -4
  36. package/dist/components/run-step-timeline/index.js +6 -6
  37. package/dist/components/sparkbar/index.js +1291 -4
  38. package/dist/components/sparkbar/sparkbar.css +5 -4
  39. package/dist/components/sparkbar/sparkbar.schema.js +26 -1
  40. package/dist/components/sparkbar/sparkbar.types.d.ts +5 -0
  41. package/dist/components/spectrogram/index.js +1076 -437
  42. package/dist/components/spectrogram/spectrogram.css +7 -6
  43. package/dist/components/spectrogram/spectrogram.schema.js +26 -1
  44. package/dist/components/spectrogram/spectrogram.types.d.ts +5 -1
  45. package/dist/components/spectrum-chart/index.js +1037 -423
  46. package/dist/components/spectrum-chart/spectrum-chart.css +8 -7
  47. package/dist/components/spectrum-chart/spectrum-chart.schema.js +26 -1
  48. package/dist/components/spectrum-chart/spectrum-chart.types.d.ts +5 -1
  49. package/dist/components/statistic/index.js +1288 -2
  50. package/dist/components/statistic/statistic.css +6 -5
  51. package/dist/components/statistic/statistic.schema.js +26 -1
  52. package/dist/components/statistic/statistic.types.d.ts +5 -0
  53. package/dist/components/statistic-group/index.js +1288 -2
  54. package/dist/components/waveform/index.js +1004 -404
  55. package/dist/components/waveform/waveform.css +8 -7
  56. package/dist/components/waveform/waveform.schema.js +26 -1
  57. package/dist/components/waveform/waveform.types.d.ts +5 -1
  58. package/dist/index.d.ts +1 -1
  59. package/dist/index.js +17734 -16540
  60. package/dist/server/components/approval-card/index.js +3 -3
  61. package/dist/server/components/area-chart/index.js +3 -3
  62. package/dist/server/components/badge/index.js +2 -2
  63. package/dist/server/components/bar-chart/index.js +3 -3
  64. package/dist/server/components/json-schema-editor/index.js +2 -2
  65. package/dist/server/components/line-chart/index.js +3 -3
  66. package/dist/server/components/matrix-chart/index.js +3 -3
  67. package/dist/server/components/payload-inspector/index.js +3 -3
  68. package/dist/server/components/run-step-timeline/index.js +2 -2
  69. package/dist/server/components/sparkbar/index.js +3 -2
  70. package/dist/server/components/spectrogram/index.js +3 -3
  71. package/dist/server/components/spectrum-chart/index.js +2 -2
  72. package/dist/server/components/statistic/index.js +4 -3
  73. package/dist/server/components/statistic-group/index.js +4 -3
  74. package/dist/server/components/waveform/index.js +2 -2
  75. package/dist/server/index.js +21 -21
  76. package/dist/server/{index.server-3dkwzkd3.js → index.server-10r7yf13.js} +110 -27
  77. package/dist/server/{index.server-pp2n6def.js → index.server-2y0xz53g.js} +37 -14
  78. package/dist/server/{index.server-bd8rcgf0.js → index.server-4hvjet4z.js} +1 -1
  79. package/dist/server/{index.server-bsm39gpy.js → index.server-5d83fkyg.js} +75 -21
  80. package/dist/server/{index.server-abqbstkt.js → index.server-9gj583qs.js} +41 -14
  81. package/dist/server/{index.server-2nmwsacy.js → index.server-9scm7zf9.js} +4 -4
  82. package/dist/server/{index.server-5j6jv7rm.js → index.server-9vwxyy06.js} +108 -29
  83. package/dist/server/{index.server-abjsjsw8.js → index.server-afpjvfz1.js} +111 -35
  84. package/dist/server/{index.server-wm8957be.js → index.server-bp0vzxby.js} +14 -1
  85. package/dist/server/{index.server-86sw5ea6.js → index.server-dw9bz17h.js} +4 -4
  86. package/dist/server/{index.server-d26jzn2m.js → index.server-en31rprd.js} +3 -3
  87. package/dist/server/{index.server-dx58qant.js → index.server-f3a0ecqg.js} +72 -9
  88. package/dist/server/{index.server-d63pwytk.js → index.server-kz8aeeq5.js} +18 -10
  89. package/dist/server/index.server-mmmrgvyd.js +1274 -0
  90. package/dist/server/{index.server-93943z3e.js → index.server-rx9aszk6.js} +1 -1
  91. package/dist/server/{index.server-1221p7e4.js → index.server-scahngwv.js} +13 -1
  92. package/dist/server/{index.server-nj8kk5bv.js → index.server-t73q59c1.js} +1 -1
  93. package/dist/server/{index.server-5schb2vt.js → index.server-tdrncj5e.js} +16 -6
  94. package/dist/server/{index.server-4wweyb2e.js → index.server-vnr1h5g5.js} +1 -1
  95. package/dist/server/{index.server-fphvzcfb.js → index.server-wqajghn9.js} +1 -1
  96. package/dist/server/{index.server-yd9shwqq.js → index.server-zjcjzcv6.js} +1 -1
  97. package/package.json +1 -1
  98. package/src/_internal/chart/chart-bar-model.ts +330 -0
  99. package/src/_internal/chart/chart-cartesian-model.ts +450 -0
  100. package/src/_internal/chart/chart-interaction.svelte.ts +25 -6
  101. package/src/_internal/chart/chart-layout.ts +348 -0
  102. package/src/_internal/chart/chart-model-utilities.ts +357 -0
  103. package/src/_internal/chart/chart-scale.ts +487 -0
  104. package/src/_internal/chart/chart-utilities.ts +22 -1078
  105. package/src/_internal/chart/heatmap-utilities.ts +21 -17
  106. package/src/components/_internal/chart-tooltip.css +21 -0
  107. package/src/components/_internal/chart-tooltip.svelte +44 -0
  108. package/src/components/approval-card/approval-card.svelte +1 -1
  109. package/src/components/area-chart/area-chart.css +27 -23
  110. package/src/components/area-chart/area-chart.examples.json +1 -1
  111. package/src/components/area-chart/area-chart.schema.json +37 -0
  112. package/src/components/area-chart/area-chart.schema.ts +40 -0
  113. package/src/components/area-chart/area-chart.svelte +103 -35
  114. package/src/components/area-chart/area-chart.types.ts +7 -1
  115. package/src/components/badge/badge.css +2 -2
  116. package/src/components/badge/badge.schema.json +1 -1
  117. package/src/components/badge/badge.schema.ts +1 -1
  118. package/src/components/badge/badge.svelte +2 -2
  119. package/src/components/badge/badge.types.ts +3 -3
  120. package/src/components/bar-chart/bar-chart.css +27 -21
  121. package/src/components/bar-chart/bar-chart.schema.json +37 -0
  122. package/src/components/bar-chart/bar-chart.schema.ts +40 -0
  123. package/src/components/bar-chart/bar-chart.svelte +94 -33
  124. package/src/components/bar-chart/bar-chart.types.ts +9 -2
  125. package/src/components/chart.types.ts +112 -2
  126. package/src/components/line-chart/line-chart.css +25 -24
  127. package/src/components/line-chart/line-chart.examples.json +1 -1
  128. package/src/components/line-chart/line-chart.schema.json +37 -0
  129. package/src/components/line-chart/line-chart.schema.ts +40 -0
  130. package/src/components/line-chart/line-chart.svelte +95 -40
  131. package/src/components/line-chart/line-chart.types.ts +7 -1
  132. package/src/components/matrix-chart/matrix-chart.css +12 -6
  133. package/src/components/matrix-chart/matrix-chart.schema.json +25 -0
  134. package/src/components/matrix-chart/matrix-chart.schema.ts +25 -0
  135. package/src/components/matrix-chart/matrix-chart.svelte +30 -12
  136. package/src/components/matrix-chart/matrix-chart.types.ts +5 -1
  137. package/src/components/run-step-timeline/run-step-timeline.svelte +2 -2
  138. package/src/components/sparkbar/sparkbar.css +5 -4
  139. package/src/components/sparkbar/sparkbar.schema.json +25 -0
  140. package/src/components/sparkbar/sparkbar.schema.ts +26 -0
  141. package/src/components/sparkbar/sparkbar.svelte +8 -1
  142. package/src/components/sparkbar/sparkbar.types.ts +5 -0
  143. package/src/components/spectrogram/spectrogram.css +7 -6
  144. package/src/components/spectrogram/spectrogram.schema.json +25 -0
  145. package/src/components/spectrogram/spectrogram.schema.ts +25 -0
  146. package/src/components/spectrogram/spectrogram.svelte +73 -28
  147. package/src/components/spectrogram/spectrogram.types.ts +5 -1
  148. package/src/components/spectrum-chart/spectrum-chart.css +8 -7
  149. package/src/components/spectrum-chart/spectrum-chart.schema.json +25 -0
  150. package/src/components/spectrum-chart/spectrum-chart.schema.ts +26 -0
  151. package/src/components/spectrum-chart/spectrum-chart.svelte +38 -12
  152. package/src/components/spectrum-chart/spectrum-chart.types.ts +5 -1
  153. package/src/components/statistic/statistic.css +6 -5
  154. package/src/components/statistic/statistic.schema.json +25 -0
  155. package/src/components/statistic/statistic.schema.ts +26 -0
  156. package/src/components/statistic/statistic.svelte +42 -1
  157. package/src/components/statistic/statistic.types.ts +5 -0
  158. package/src/components/waveform/waveform.css +8 -7
  159. package/src/components/waveform/waveform.schema.json +25 -0
  160. package/src/components/waveform/waveform.schema.ts +26 -0
  161. package/src/components/waveform/waveform.svelte +16 -3
  162. package/src/components/waveform/waveform.types.ts +5 -1
  163. package/src/index.ts +8 -0
  164. package/dist/server/index.server-6vbpz6dd.js +0 -690
@@ -7,6 +7,8 @@
7
7
  * two component implementations.
8
8
  */
9
9
 
10
+ import { chartPaletteColor } from './chart-utilities.ts';
11
+
10
12
  export type HeatmapColorScale = 'sequential' | 'diverging';
11
13
 
12
14
  /**
@@ -125,35 +127,37 @@ export function heatmapCellFill(
125
127
  value: number | null,
126
128
  domain: HeatmapDomain,
127
129
  scale: HeatmapColorScale = 'sequential',
130
+ palette?: readonly string[],
131
+ background = 'var(--cinder-surface-inset)',
128
132
  ): string {
129
- if (value === null) return 'var(--cinder-surface-inset)';
133
+ if (value === null) return background;
130
134
  const normalized = normalizeHeatmapValue(value, domain, scale);
131
135
 
132
136
  if (scale === 'diverging') {
137
+ const coolColor = chartPaletteColor(4, palette);
138
+ let warmColor = chartPaletteColor(2, palette);
139
+ // Short custom palettes wrap around. Keep the two diverging ends distinct
140
+ // whenever callers provide at least two colors.
141
+ if (palette && palette.length >= 2 && warmColor === coolColor) {
142
+ warmColor = chartPaletteColor(1, palette);
143
+ }
133
144
  if (normalized < 0.5) {
134
145
  const ratio = (0.5 - normalized) * 2;
135
- return `color-mix(in oklch, var(--cinder-chart-series-5) ${Math.round(ratio * 100)}%, var(--cinder-surface-inset))`;
146
+ return `color-mix(in oklch, ${coolColor} ${Math.round(ratio * 100)}%, ${background})`;
136
147
  }
137
148
  const ratio = (normalized - 0.5) * 2;
138
- return `color-mix(in oklch, var(--cinder-chart-series-3) ${Math.round(ratio * 100)}%, var(--cinder-surface-inset))`;
149
+ return `color-mix(in oklch, ${warmColor} ${Math.round(ratio * 100)}%, ${background})`;
139
150
  }
140
151
 
141
- return `color-mix(in oklch, var(--cinder-chart-series-1) ${Math.round(normalized * 100)}%, var(--cinder-surface-inset))`;
152
+ return `color-mix(in oklch, ${chartPaletteColor(0, palette)} ${Math.round(normalized * 100)}%, ${background})`;
142
153
  }
143
154
 
144
155
  /**
145
- * Choose a readable label colour for a cell: a light colour over high-intensity
146
- * (dark) fills, a dark colour over low-intensity (light) fills.
156
+ * Provide the opaque source colour used by the MatrixChart's difference blend.
157
+ * The browser composites this against the actual rendered cell, so arbitrary
158
+ * custom palettes remain readable without guessing their luminance in JavaScript.
147
159
  */
148
- export function heatmapLabelFill(
149
- value: number | null,
150
- domain: HeatmapDomain,
151
- scale: HeatmapColorScale = 'sequential',
152
- ): string {
153
- if (value === null) return 'var(--cinder-text-muted)';
154
- const intensity =
155
- scale === 'diverging'
156
- ? Math.abs(normalizeHeatmapValue(value, domain, scale) - 0.5) * 2
157
- : normalizeHeatmapValue(value, domain, scale);
158
- return intensity > 0.5 ? 'var(--cinder-surface)' : 'var(--cinder-text)';
160
+ export function heatmapLabelFill(value: number | null, muted = 'currentColor'): string {
161
+ if (value === null) return muted;
162
+ return 'var(--cinder-text-inverse)';
159
163
  }
@@ -0,0 +1,21 @@
1
+ @layer cinder.tokens, cinder.foundation, cinder.components, cinder.utilities;
2
+ @layer cinder.components {
3
+ .cinder-chart-tooltip-anchor {
4
+ position: absolute;
5
+ width: 1px;
6
+ height: 1px;
7
+ pointer-events: none;
8
+ }
9
+
10
+ .cinder-chart-tooltip {
11
+ display: grid;
12
+ gap: var(--cinder-space-1);
13
+ color: inherit;
14
+ font-size: var(--cinder-text-sm);
15
+ }
16
+
17
+ .cinder-chart-tooltip strong,
18
+ .cinder-chart-tooltip span {
19
+ display: block;
20
+ }
21
+ }
@@ -0,0 +1,44 @@
1
+ <script lang="ts">
2
+ import Popover from '@lostgradient/cinder/popover';
3
+ let { id, target, geometry, content, } = $props();
4
+ let anchorElement = $state(null);
5
+ const outsideClickIgnoreRefs = [() => anchorElement?.ownerDocument.body ?? null];
6
+ const customContent = $derived(typeof content === 'function' ? content : undefined);
7
+ const open = $derived(Boolean(anchorElement && target && content));
8
+ </script>
9
+
10
+ <span
11
+ bind:this={anchorElement}
12
+ class="cinder-chart-tooltip-anchor"
13
+ aria-hidden="true"
14
+ style:left={`${geometry.marginLeft + (target?.x ?? 0)}px`}
15
+ style:top={`${geometry.marginTop + (target?.y ?? 0)}px`}
16
+ ></span>
17
+
18
+ <!-- This non-interactive tooltip stays controlled by the chart's active target. -->
19
+ <Popover
20
+ id={`${id}-popover`}
21
+ {open}
22
+ triggerRef={anchorElement}
23
+ placement="right"
24
+ arrowVisible
25
+ role="group"
26
+ focusManagement="preserve"
27
+ {outsideClickIgnoreRefs}
28
+ wireTriggerAria={false}
29
+ closeOnEscape={false}
30
+ widthMode="content"
31
+ >
32
+ {#snippet children()}
33
+ {#if target}
34
+ <div {id} role="tooltip" class="cinder-chart-tooltip">
35
+ {#if customContent}
36
+ {@render customContent(target)}
37
+ {:else}
38
+ <strong>{target.seriesLabel}</strong>
39
+ <span>{target.xLabel}: {target.valueLabel}</span>
40
+ {/if}
41
+ </div>
42
+ {/if}
43
+ {/snippet}
44
+ </Popover>
@@ -221,7 +221,7 @@ function resolveIfActionable(resolution) {
221
221
  >
222
222
  {#each environmentNames as environmentName (environmentName)}
223
223
  <li>
224
- <Badge size="sm" monochrome>{environmentName}</Badge>
224
+ <Badge size="sm" monospace>{environmentName}</Badge>
225
225
  </li>
226
226
  {/each}
227
227
  </ul>
@@ -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-area-chart {
5
6
  display: grid;
6
7
  gap: var(--cinder-space-3);
7
- color: var(--cinder-text);
8
+ color: var(--_cinder-chart-foreground, currentColor);
9
+ background: var(--_cinder-chart-background, transparent);
8
10
  }
9
11
 
10
12
  .cinder-area-chart__description {
11
13
  margin: 0;
12
- color: var(--cinder-text-muted);
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(--cinder-surface-raised);
29
- color: var(--cinder-text);
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);
@@ -54,22 +57,25 @@
54
57
  }
55
58
 
56
59
  .cinder-area-chart__area {
57
- opacity: 0.22;
60
+ transition: d 0.3s ease;
58
61
  }
59
62
 
60
63
  .cinder-area-chart__line {
61
64
  fill: none;
62
65
  stroke-width: 2;
66
+ transition: d 0.3s ease;
63
67
  }
64
68
 
65
69
  .cinder-area-chart__gridline {
66
- stroke: var(--cinder-border-muted);
70
+ stroke: var(--_cinder-chart-grid, currentColor);
67
71
  stroke-width: 1;
72
+ opacity: 0.22;
68
73
  }
69
74
 
70
75
  .cinder-area-chart__crosshair {
71
- stroke: var(--cinder-text-muted);
76
+ stroke: var(--_cinder-chart-muted, currentColor);
72
77
  stroke-dasharray: 4 4;
78
+ opacity: 0.72;
73
79
  }
74
80
 
75
81
  .cinder-area-chart__hit-surface {
@@ -142,32 +148,30 @@
142
148
  }
143
149
  }
144
150
 
145
- .cinder-area-chart__tick-label {
146
- fill: var(--cinder-text-muted);
151
+ .cinder-area-chart__tick-label,
152
+ .cinder-area-chart__axis-title {
153
+ fill: var(--_cinder-chart-muted, currentColor);
147
154
  font-size: var(--cinder-text-xs);
148
155
  }
149
156
 
157
+ .cinder-area-chart__tick-label {
158
+ opacity: 0.72;
159
+ }
160
+
150
161
  .cinder-area-chart__state {
151
162
  position: absolute;
152
163
  inset: 0;
153
164
  display: grid;
154
165
  place-items: center;
155
- color: var(--cinder-text-muted);
156
- background: color-mix(in oklch, var(--cinder-surface) 88%, transparent);
166
+ color: var(--_cinder-chart-muted, currentColor);
167
+ background: var(--_cinder-chart-background, transparent);
157
168
  z-index: 1;
158
169
  }
159
170
 
160
- .cinder-area-chart__tooltip {
161
- position: absolute;
162
- transform: translate(0.5rem, -50%);
163
- display: grid;
164
- gap: 0.125rem;
165
- border: 1px solid var(--cinder-border);
166
- border-radius: var(--cinder-radius-sm);
167
- background: var(--cinder-surface-raised);
168
- box-shadow: var(--cinder-shadow-md);
169
- font-size: var(--cinder-text-sm);
170
- padding: var(--cinder-space-2);
171
- pointer-events: none;
171
+ @media (prefers-reduced-motion: reduce) {
172
+ .cinder-area-chart__area,
173
+ .cinder-area-chart__line {
174
+ transition: none;
175
+ }
172
176
  }
173
177
  }
@@ -20,7 +20,7 @@
20
20
  "title": "Usage area",
21
21
  "description": "A single-series area chart for product usage.",
22
22
  "featured": true,
23
- "code": "<script lang=\"ts\">\n import { AreaChart } from '@lostgradient/cinder/area-chart';\n\n const series = [\n {\n id: 'usage',\n label: 'Usage',\n data: [\n { x: 'Jan', y: 44 },\n { x: 'Feb', y: 61 },\n { x: 'Mar', y: 79 },\n ],\n },\n ];\n</script>\n\n<AreaChart label=\"Product usage\" {series} />\n"
23
+ "code": "<script lang=\"ts\">\n import { AreaChart } from '@lostgradient/cinder/area-chart';\n\n const series = [\n {\n id: 'usage',\n label: 'Usage',\n data: [\n { x: 'Jan', y: 44 },\n { x: 'Feb', y: 61 },\n { x: 'Mar', y: 79 },\n ],\n },\n ];\n</script>\n\n<AreaChart label=\"Product usage\" {series} tooltip />\n"
24
24
  },
25
25
  {
26
26
  "id": "stacked",
@@ -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."
@@ -137,6 +169,11 @@
137
169
  {
138
170
  "name": "loadingContent",
139
171
  "reason": "function-or-snippet"
172
+ },
173
+ {
174
+ "name": "mark",
175
+ "reason": "function-or-snippet",
176
+ "description": "Per-series renderer override. The chart retains scales, guides, focus, and data-table semantics."
140
177
  }
141
178
  ]
142
179
  }
@@ -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.',
@@ -142,6 +176,12 @@ const schema = {
142
176
  name: 'loadingContent',
143
177
  reason: 'function-or-snippet',
144
178
  },
179
+ {
180
+ name: 'mark',
181
+ reason: 'function-or-snippet',
182
+ description:
183
+ 'Per-series renderer override. The chart retains scales, guides, focus, and data-table semantics.',
184
+ },
145
185
  ],
146
186
  },
147
187
  } satisfies ComponentSchema;
@@ -3,12 +3,14 @@ export {};
3
3
  </script>
4
4
 
5
5
  <script lang="ts">
6
- import { assertValidNonNegativeInteger, chartPaletteColor, createCartesianModel, dataTableClass, formatNumericValue, legendVisible, } from '../../_internal/chart/chart-utilities.ts';
6
+ import { onMount } from 'svelte';
7
+ import { assertValidNonNegativeInteger, chartPaletteColor, chartResourceId, 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, mode = 'single', 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, mode = 'single', 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;
@@ -30,6 +40,10 @@ const model = $derived(createCartesianModel({
30
40
  xAxis,
31
41
  yAxis,
32
42
  stackedArea: mode === 'stacked',
43
+ theme,
44
+ measureText,
45
+ measurementElement: rootElement,
46
+ measurementVersion,
33
47
  }));
34
48
  const keyboardEnabled = $derived(model.targets.length > 0 && model.targets.length <= maximumInteractivePoints);
35
49
  const hasDataTable = $derived(dataTableVisibility !== 'hidden');
@@ -97,6 +111,10 @@ function handleTargetKeydown(event) {
97
111
  bind:this={rootElement}
98
112
  id={rootId}
99
113
  class={classNames('cinder-area-chart', customClassName)}
114
+ style:--_cinder-chart-foreground={model.theme.foreground}
115
+ style:--_cinder-chart-muted={model.theme.muted}
116
+ style:--_cinder-chart-grid={model.theme.grid}
117
+ style:--_cinder-chart-background={model.theme.background}
100
118
  aria-label={label}
101
119
  aria-describedby={descriptionId}
102
120
  data-cinder-mode={mode}
@@ -111,7 +129,7 @@ function handleTargetKeydown(event) {
111
129
  type="button"
112
130
  aria-pressed={!hiddenSeriesIds.includes(item.id)}
113
131
  onclick={() => (hiddenSeriesIds = interaction.toggleSeries(hiddenSeriesIds, item.id))}
114
- ><span style:background={item.color ?? chartPaletteColor(index)}
132
+ ><span style:background={item.color ?? chartPaletteColor(index, model.theme.palette)}
115
133
  ></span>{item.label}</button
116
134
  >
117
135
  {/each}
@@ -161,33 +179,82 @@ function handleTargetKeydown(event) {
161
179
  >{formatNumericValue(tick, yAxis, undefined, { index })}</text
162
180
  >
163
181
  {/each}
182
+ {#if yAxis?.label}
183
+ <text
184
+ class="cinder-area-chart__axis-title"
185
+ x={-model.geometry.plotHeight / 2}
186
+ y={-model.geometry.marginLeft + 12}
187
+ text-anchor="middle"
188
+ transform="rotate(-90)">{yAxis.label}</text
189
+ >
190
+ {/if}
164
191
  {#each model.xTicks as tick (tick.label)}
165
192
  <text
166
193
  class="cinder-area-chart__tick-label"
167
194
  x={tick.x}
168
195
  y={model.geometry.plotHeight + 20}
196
+ transform={xAxis?.tickLabelRotation
197
+ ? `rotate(${xAxis.tickLabelRotation} ${tick.x} ${model.geometry.plotHeight + 20})`
198
+ : undefined}
169
199
  text-anchor="middle">{tick.label}</text
170
200
  >
171
201
  {/each}
202
+ {#if xAxis?.label}
203
+ <text
204
+ class="cinder-area-chart__axis-title"
205
+ x={model.geometry.plotWidth / 2}
206
+ y={model.geometry.plotHeight + model.geometry.marginBottom - 4}
207
+ text-anchor="middle">{xAxis.label}</text
208
+ >
209
+ {/if}
210
+ <defs>
211
+ {#each model.normalizedSeries as item (item.id)}
212
+ <linearGradient
213
+ id={chartResourceId(rootId, 'gradient', item.id)}
214
+ x1="0"
215
+ x2="0"
216
+ y1="0"
217
+ y2="1"
218
+ >
219
+ <stop offset="0" stop-color={item.color} stop-opacity="0.42" />
220
+ <stop offset="1" stop-color={item.color} stop-opacity="0.08" />
221
+ </linearGradient>
222
+ {/each}
223
+ </defs>
172
224
  <!-- Series-specific rendering: filled area paths + stroke line paths. -->
173
- {#each model.normalizedSeries as item (item.id)}
174
- {#if !item.hidden && item.areaPath}
175
- <path
176
- class="cinder-area-chart__area"
177
- d={item.areaPath}
178
- fill={item.color}
179
- aria-hidden="true"
180
- data-cinder-series={item.id}
181
- />
182
- <path
183
- class="cinder-area-chart__line"
184
- d={item.path}
185
- stroke={item.color}
186
- aria-hidden="true"
187
- data-cinder-series={item.id}
188
- />
189
- {/if}
190
- {/each}
225
+ {#if mark}
226
+ {#each model.normalizedSeries as item (item.id)}
227
+ {#if !hiddenSeriesIds.includes(item.id)}
228
+ {@const sourceSeries = series.find((candidate) => candidate.id === item.id)}
229
+ {#if sourceSeries}
230
+ {@render mark({
231
+ series: sourceSeries,
232
+ points: item.points,
233
+ geometry: model.geometry,
234
+ })}
235
+ {/if}
236
+ {/if}
237
+ {/each}
238
+ {:else}
239
+ {#each model.normalizedSeries as item (item.id)}
240
+ {#if !hiddenSeriesIds.includes(item.id) && item.areaPath}
241
+ <path
242
+ class="cinder-area-chart__area"
243
+ d={item.areaPath}
244
+ fill={`url(#${chartResourceId(rootId, 'gradient', item.id)})`}
245
+ aria-hidden="true"
246
+ data-cinder-series={item.id}
247
+ />
248
+ <path
249
+ class="cinder-area-chart__line"
250
+ d={item.path}
251
+ stroke={item.color}
252
+ aria-hidden="true"
253
+ data-cinder-series={item.id}
254
+ />
255
+ {/if}
256
+ {/each}
257
+ {/if}
191
258
  {#if interaction.activeTarget}
192
259
  <!-- Vertical crosshair — area charts always use a vertical indicator. -->
193
260
  <line
@@ -224,7 +291,7 @@ function handleTargetKeydown(event) {
224
291
  ? 'true'
225
292
  : undefined}
226
293
  aria-label={`${target.seriesLabel}, ${target.xLabel}, ${target.valueLabel}`}
227
- aria-describedby={interaction.activeTarget?.id === target.id
294
+ aria-describedby={tooltip && interaction.activeTarget?.id === target.id
228
295
  ? `${rootId}-tooltip`
229
296
  : undefined}
230
297
  onfocus={() => handleTargetFocus(target)}
@@ -294,24 +361,25 @@ function handleTargetKeydown(event) {
294
361
  </g>
295
362
  {/if}
296
363
  </svg>
297
- {#if interaction.activeTarget}<div
298
- id="{rootId}-tooltip"
299
- role="tooltip"
300
- class="cinder-area-chart__tooltip"
301
- style:left="{model.geometry.marginLeft + interaction.activeTarget.x}px"
302
- style:top="{model.geometry.marginTop + interaction.activeTarget.y}px"
303
- >
304
- <strong>{interaction.activeTarget.seriesLabel}</strong><span
305
- >{interaction.activeTarget.xLabel}: {interaction.activeTarget.valueLabel}</span
306
- >
307
- </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}
308
372
  </div>
309
373
  {#if guidanceId}<p id={guidanceId} class="cinder-sr-only">
310
374
  Use the data table to inspect this chart with a keyboard.
311
375
  </p>{/if}
312
376
  {#if hasDataTable}
313
377
  <ChartDataTable
314
- caption={dataTableCaption ?? label}
378
+ caption={formatDataTableCaption(
379
+ dataTableCaption ?? label,
380
+ model.tableRows.length,
381
+ model.targets.length,
382
+ )}
315
383
  headers={['Series', 'X', 'Value']}
316
384
  rows={model.tableRows.map((row) => ({
317
385
  id: row.id,
@@ -329,7 +397,7 @@ function handleTargetKeydown(event) {
329
397
  type="button"
330
398
  aria-pressed={!hiddenSeriesIds.includes(item.id)}
331
399
  onclick={() => (hiddenSeriesIds = interaction.toggleSeries(hiddenSeriesIds, item.id))}
332
- ><span style:background={item.color ?? chartPaletteColor(index)}
400
+ ><span style:background={item.color ?? chartPaletteColor(index, model.theme.palette)}
333
401
  ></span>{item.label}</button
334
402
  >
335
403
  {/each}
@@ -6,6 +6,8 @@ import type {
6
6
  ChartJsonXValue,
7
7
  ChartLegendPosition,
8
8
  ChartSharedProps,
9
+ ChartThemeSchema,
10
+ ChartXAxisSchemaConfiguration,
9
11
  } from '../chart.types.ts';
10
12
 
11
13
  export type AreaChartProps = ChartSharedProps & {
@@ -37,7 +39,7 @@ export type AreaChartSchemaProps = {
37
39
  /** Pixel height of the chart viewport. Default `280`. */
38
40
  height?: number;
39
41
  /** Configuration for the x-axis label and tick count. */
40
- xAxis?: ChartAxisSchemaConfiguration;
42
+ xAxis?: ChartXAxisSchemaConfiguration;
41
43
  /** Configuration for the y-axis label and tick count. */
42
44
  yAxis?: ChartAxisSchemaConfiguration;
43
45
  /** Where to render the series legend relative to the chart. Default `top`. */
@@ -52,6 +54,10 @@ export type AreaChartSchemaProps = {
52
54
  dataTableVisibility?: ChartDataTableVisibility;
53
55
  /** Maximum number of interactive focus targets before keyboard navigation is disabled. Default `500`. */
54
56
  maximumInteractivePoints?: number;
57
+ /** Partial visual theme override. Omitted fields inherit the surrounding application. */
58
+ theme?: ChartThemeSchema;
59
+ /** Enable the default visual tooltip. Custom snippet tooltips are available in the TypeScript API. */
60
+ tooltip?: boolean;
55
61
  /** Custom class applied to the root element. */
56
62
  class?: string;
57
63
  /** Series rendered as independent filled areas or stacked areas. */
@@ -84,10 +84,10 @@
84
84
  }
85
85
 
86
86
  /* ----------------------------------------
87
- * Monochrome affordance
87
+ * Monospace affordance
88
88
  * ---------------------------------------- */
89
89
 
90
- .cinder-badge[data-cinder-monochrome] {
90
+ .cinder-badge[data-cinder-monospace] {
91
91
  font-family: var(
92
92
  --cinder-font-mono,
93
93
  ui-monospace,
@@ -12,7 +12,7 @@
12
12
  "description": "Size of the badge.",
13
13
  "default": "md"
14
14
  },
15
- "monochrome": {
15
+ "monospace": {
16
16
  "type": "boolean",
17
17
  "description": "Render the badge label in a monospace font. Useful for version strings, error codes, or other technical labels.",
18
18
  "default": false
@@ -14,7 +14,7 @@ const schema = {
14
14
  description: 'Size of the badge.',
15
15
  default: 'md',
16
16
  },
17
- monochrome: {
17
+ monospace: {
18
18
  type: 'boolean',
19
19
  description:
20
20
  'Render the badge label in a monospace font. Useful for version strings, error codes, or other technical labels.',