@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
@@ -56,9 +56,208 @@ import"@lostgradient/cinder/line-chart/styles";
56
56
 
57
57
  // src/components/line-chart/line-chart.svelte
58
58
  import"svelte/internal/disclose-version";
59
- import * as $10 from "svelte/internal/client";
59
+ import * as $11 from "svelte/internal/client";
60
+ import { onMount } from "svelte";
61
+
62
+ // src/_internal/chart/chart-layout.ts
63
+ var CHART_OUTER_PADDING = 16;
64
+ var CHART_GUIDE_GAP = 8;
65
+ var CHART_AXIS_TITLE_GAP = 12;
66
+ var HORIZONTAL_CATEGORY_LABEL_GAP = 8;
67
+ var HORIZONTAL_CATEGORY_LABEL_OUTER_PADDING = 8;
68
+ var MAXIMUM_HORIZONTAL_CATEGORY_LABEL_FRACTION = 0.4;
69
+ var MAXIMUM_CHART_TEXT_MEASUREMENTS = 1024;
70
+ function createChartGeometry(width, height, options = {}) {
71
+ const xTickRotation = options.xAxis?.tickLabelRotation ?? 0;
72
+ if (!Number.isFinite(xTickRotation)) {
73
+ throw new Error(`[cinder/chart] rule=invalid-tick-label-rotation tickLabelRotation="${xTickRotation}": expected a finite number.`);
74
+ }
75
+ const xTickLabels = options.xTickLabels ?? [];
76
+ const yTickLabels = options.yTickLabels ?? [];
77
+ const measurementContext = createChartTextMeasurementContext(options.measureText ?? false, options.measurementElement, options.measurementVersion ?? 0);
78
+ const textMeasurements = measureChartTexts([
79
+ ...xTickLabels.map((label) => ({ label, rotation: xTickRotation })),
80
+ ...yTickLabels.map((label) => ({ label, rotation: 0 })),
81
+ ...options.xAxis?.label ? [{ label: options.xAxis.label, rotation: 0 }] : [],
82
+ ...options.yAxis?.label ? [{ label: options.yAxis.label, rotation: -90 }] : []
83
+ ], measurementContext);
84
+ const measurementFor = (label, rotation) => textMeasurements.get(chartTextMeasurementKey(label, rotation, measurementContext.cacheKey)) ?? fallbackChartTextMeasurement(label, rotation);
85
+ const xTickHeight = maximumMeasurement(xTickLabels, (label) => measurementFor(label, xTickRotation).height);
86
+ const firstXTickWidth = xTickLabels[0] ? measurementFor(xTickLabels[0], xTickRotation).width : 0;
87
+ const lastXTickLabel = xTickLabels.at(-1);
88
+ const lastXTickWidth = lastXTickLabel ? measurementFor(lastXTickLabel, xTickRotation).width : 0;
89
+ const yTickWidth = maximumMeasurement(yTickLabels, (label) => measurementFor(label, 0).width);
90
+ const xAxisTitleHeight = options.xAxis?.label ? measurementFor(options.xAxis.label, 0).height + CHART_AXIS_TITLE_GAP : 0;
91
+ const yAxisTitleWidth = options.yAxis?.label ? measurementFor(options.yAxis.label, -90).width + CHART_AXIS_TITLE_GAP : 0;
92
+ const derivedMarginLeft = CHART_OUTER_PADDING + yTickWidth + CHART_GUIDE_GAP + yAxisTitleWidth;
93
+ const maximumMarginLeft = Math.max(CHART_OUTER_PADDING, Math.floor(width * 0.4));
94
+ const endpointLeftMargin = Math.max(CHART_OUTER_PADDING, Math.ceil(firstXTickWidth / 2) + CHART_GUIDE_GAP);
95
+ const endpointRightMargin = Math.max(CHART_OUTER_PADDING, Math.ceil(lastXTickWidth / 2) + CHART_GUIDE_GAP);
96
+ const marginLeft = Math.min(maximumMarginLeft, Math.max(derivedMarginLeft, options.marginLeft ?? 0, endpointLeftMargin));
97
+ const marginTop = options.xTickPosition === "top" ? Math.min(Math.max(CHART_OUTER_PADDING, Math.floor(height * 0.45)), CHART_OUTER_PADDING + xTickHeight + CHART_GUIDE_GAP + xAxisTitleHeight) : CHART_OUTER_PADDING;
98
+ const marginRight = endpointRightMargin;
99
+ const marginBottom = options.xTickPosition === "top" ? CHART_OUTER_PADDING : Math.min(Math.max(CHART_OUTER_PADDING, Math.floor(height * 0.45)), CHART_OUTER_PADDING + xTickHeight + CHART_GUIDE_GAP + xAxisTitleHeight);
100
+ return {
101
+ plotWidth: Math.max(1, width - marginLeft - marginRight),
102
+ plotHeight: Math.max(1, height - marginTop - marginBottom),
103
+ marginTop,
104
+ marginRight,
105
+ marginBottom,
106
+ marginLeft
107
+ };
108
+ }
109
+ function createHorizontalCategoryLabelLayout(labels, chartWidth, options = {}) {
110
+ const measurementContext = createChartTextMeasurementContext(options.measureText ?? false, options.measurementElement, options.measurementVersion ?? 0);
111
+ const textMeasurements = measureChartTexts([...labels.map((label) => ({ label, rotation: 0 })), { label: "…", rotation: 0 }], measurementContext);
112
+ const measurementFor = (label) => textMeasurements.get(chartTextMeasurementKey(label, 0, measurementContext.cacheKey)) ?? fallbackChartTextMeasurement(label, 0);
113
+ const maximumMarginLeft = Math.max(CHART_OUTER_PADDING, Math.floor(chartWidth * MAXIMUM_HORIZONTAL_CATEGORY_LABEL_FRACTION));
114
+ let longestLabelWidth = 0;
115
+ for (const label of labels) {
116
+ longestLabelWidth = Math.max(longestLabelWidth, measurementFor(label).width);
117
+ }
118
+ const requestedMarginLeft = longestLabelWidth + HORIZONTAL_CATEGORY_LABEL_GAP + HORIZONTAL_CATEGORY_LABEL_OUTER_PADDING;
119
+ const marginLeft = Math.min(maximumMarginLeft, Math.max(CHART_OUTER_PADDING, requestedMarginLeft));
120
+ const availableLabelWidth = Math.max(0, marginLeft - HORIZONTAL_CATEGORY_LABEL_GAP - HORIZONTAL_CATEGORY_LABEL_OUTER_PADDING);
121
+ return {
122
+ marginLeft,
123
+ labels: labels.map((label) => truncateHorizontalCategoryLabel(label, availableLabelWidth, measurementFor))
124
+ };
125
+ }
126
+ function observeChartFontLoading(onFontsChanged) {
127
+ if (typeof document === "undefined" || !document.fonts)
128
+ return () => {};
129
+ let active = true;
130
+ const handleFontsChanged = () => {
131
+ if (active)
132
+ onFontsChanged();
133
+ };
134
+ document.fonts.addEventListener("loadingdone", handleFontsChanged);
135
+ document.fonts.ready.then(handleFontsChanged);
136
+ return () => {
137
+ active = false;
138
+ document.fonts.removeEventListener("loadingdone", handleFontsChanged);
139
+ };
140
+ }
141
+ function truncateHorizontalCategoryLabel(label, availableWidth, measurementFor) {
142
+ const measuredWidth = measurementFor(label).width;
143
+ if (measuredWidth <= availableWidth)
144
+ return label;
145
+ const fallbackWidth = fallbackChartTextMeasurement(label, 0).width;
146
+ const measurementScale = fallbackWidth > 0 ? measuredWidth / fallbackWidth : 1;
147
+ const estimatedWidth = (candidate) => candidate === "…" ? measurementFor("…").width : fallbackChartTextMeasurement(candidate, 0).width * measurementScale;
148
+ const characters = Array.from(label);
149
+ while (characters.length > 0) {
150
+ const truncated = `${characters.join("")}…`;
151
+ if (estimatedWidth(truncated) <= availableWidth)
152
+ return truncated;
153
+ characters.pop();
154
+ }
155
+ return availableWidth >= estimatedWidth("…") ? "…" : "";
156
+ }
157
+ function maximumMeasurement(labels, select) {
158
+ let maximum = 0;
159
+ for (const label of labels)
160
+ maximum = Math.max(maximum, select(label));
161
+ return maximum;
162
+ }
163
+ var chartTextMeasurementCache = new Map;
164
+ function measureChartTexts(entries, context) {
165
+ if (!context.container || typeof document === "undefined") {
166
+ return new Map(entries.map(({ label, rotation }) => [
167
+ chartTextMeasurementKey(label, rotation, context.cacheKey),
168
+ fallbackChartTextMeasurement(label, rotation)
169
+ ]));
170
+ }
171
+ const uniqueEntries = [
172
+ ...new Map(entries.map((entry) => [
173
+ chartTextMeasurementKey(entry.label, entry.rotation, context.cacheKey),
174
+ entry
175
+ ])).values()
176
+ ];
177
+ const missing = uniqueEntries.filter(({ label, rotation }) => !chartTextMeasurementCache.has(chartTextMeasurementKey(label, rotation, context.cacheKey)));
178
+ if (missing.length > 0) {
179
+ const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
180
+ svg.setAttribute("style", "position:absolute;visibility:hidden;pointer-events:none;inline-size:0;block-size:0");
181
+ const texts = missing.map((entry) => {
182
+ const text = document.createElementNS("http://www.w3.org/2000/svg", "text");
183
+ if (context.textStyle)
184
+ text.setAttribute("style", context.textStyle);
185
+ text.textContent = entry.label;
186
+ svg.append(text);
187
+ return { ...entry, text };
188
+ });
189
+ context.container.append(svg);
190
+ for (const { label, rotation, text } of texts) {
191
+ let measurement;
192
+ try {
193
+ const bounds = text.getBBox();
194
+ if (bounds.width > 0 && bounds.height > 0) {
195
+ measurement = { width: bounds.width, height: bounds.height };
196
+ }
197
+ } catch {}
198
+ if (measurement) {
199
+ cacheChartTextMeasurement(chartTextMeasurementKey(label, rotation, context.cacheKey), rotateChartTextMeasurement(measurement, rotation));
200
+ }
201
+ }
202
+ svg.remove();
203
+ }
204
+ return new Map(entries.map(({ label, rotation }) => [
205
+ chartTextMeasurementKey(label, rotation, context.cacheKey),
206
+ chartTextMeasurementCache.get(chartTextMeasurementKey(label, rotation, context.cacheKey)) ?? fallbackChartTextMeasurement(label, rotation)
207
+ ]));
208
+ }
209
+ function cacheChartTextMeasurement(key, measurement) {
210
+ if (!chartTextMeasurementCache.has(key)) {
211
+ while (chartTextMeasurementCache.size >= MAXIMUM_CHART_TEXT_MEASUREMENTS) {
212
+ const oldestKey = chartTextMeasurementCache.keys().next().value;
213
+ if (oldestKey === undefined)
214
+ break;
215
+ chartTextMeasurementCache.delete(oldestKey);
216
+ }
217
+ }
218
+ chartTextMeasurementCache.set(key, measurement);
219
+ }
220
+ function chartTextMeasurementKey(label, rotation, measurementContext) {
221
+ return `${label}\x00${rotation}\x00${measurementContext}`;
222
+ }
223
+ function createChartTextMeasurementContext(allowBrowserMeasurement, measurementElement, measurementVersion) {
224
+ if (!allowBrowserMeasurement || !measurementElement || typeof window === "undefined" || !measurementElement.isConnected) {
225
+ return { cacheKey: "fallback" };
226
+ }
227
+ const style = window.getComputedStyle(measurementElement);
228
+ const fontSize = style.getPropertyValue("--cinder-text-xs").trim() || style.fontSize;
229
+ const textStyle = [
230
+ `font-family:${style.fontFamily}`,
231
+ `font-size:${fontSize}`,
232
+ `font-style:${style.fontStyle}`,
233
+ `font-weight:${style.fontWeight}`,
234
+ `font-stretch:${style.fontStretch}`,
235
+ `font-variant:${style.fontVariant}`,
236
+ `font-feature-settings:${style.fontFeatureSettings}`,
237
+ `font-kerning:${style.fontKerning}`,
238
+ `letter-spacing:${style.letterSpacing}`,
239
+ `text-transform:${style.textTransform}`
240
+ ].join(";");
241
+ return {
242
+ cacheKey: `browser\x00${measurementVersion}\x00${textStyle}`,
243
+ container: measurementElement,
244
+ textStyle
245
+ };
246
+ }
247
+ function fallbackChartTextMeasurement(label, rotation) {
248
+ return rotateChartTextMeasurement({ width: Array.from(label).length * 7, height: 12 }, rotation);
249
+ }
250
+ function rotateChartTextMeasurement(measurement, rotation) {
251
+ if (rotation === 0)
252
+ return measurement;
253
+ const radians = Math.abs(rotation) * Math.PI / 180;
254
+ return {
255
+ width: Math.abs(measurement.width * Math.cos(radians)) + Math.abs(measurement.height * Math.sin(radians)),
256
+ height: Math.abs(measurement.width * Math.sin(radians)) + Math.abs(measurement.height * Math.cos(radians))
257
+ };
258
+ }
60
259
 
61
- // src/_internal/chart/chart-utilities.ts
260
+ // src/_internal/chart/chart-model-utilities.ts
62
261
  var chartPalette = [
63
262
  "var(--cinder-chart-series-1)",
64
263
  "var(--cinder-chart-series-2)",
@@ -69,8 +268,26 @@ var chartPalette = [
69
268
  "var(--cinder-chart-series-7)",
70
269
  "var(--cinder-chart-series-8)"
71
270
  ];
72
- function chartPaletteColor(index) {
73
- return chartPalette[index % chartPalette.length] ?? "var(--cinder-chart-series-1)";
271
+ function chartPaletteColor(index, palette = chartPalette) {
272
+ const resolvedPalette = palette.length > 0 ? palette : chartPalette;
273
+ if (index < 0)
274
+ return resolvedPalette[0] ?? chartPalette[0];
275
+ return resolvedPalette[index % resolvedPalette.length] ?? chartPalette[0];
276
+ }
277
+ function resolveChartTheme(theme = undefined) {
278
+ return {
279
+ foreground: theme?.foreground ?? "currentColor",
280
+ muted: theme?.muted ?? "currentColor",
281
+ grid: theme?.grid ?? "currentColor",
282
+ background: theme?.background ?? "transparent",
283
+ palette: theme?.palette?.length ? [...theme.palette] : [...chartPalette]
284
+ };
285
+ }
286
+ function chartResourceSegment(segment) {
287
+ return encodeURIComponent(segment).replace(/[!'()*]/g, (character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`).replaceAll("_", "_u").replaceAll("-", "_d").replaceAll("%", "_x");
288
+ }
289
+ function chartResourceId(idPrefix, resource, seriesId) {
290
+ return [idPrefix, resource, seriesId].map(chartResourceSegment).join("-");
74
291
  }
75
292
  function assertValidChartNumber(componentId, rule, value, label) {
76
293
  if (!Number.isFinite(value) || value <= 0) {
@@ -92,6 +309,9 @@ function assertValidTickCount(componentId, axis) {
92
309
  function dataTableClass(visibility) {
93
310
  return visibility === "screen-reader-only" ? "cinder-sr-only" : undefined;
94
311
  }
312
+ function formatDataTableCaption(caption, displayedRowCount, totalRowCount) {
313
+ return totalRowCount > displayedRowCount ? `${caption} (showing ${displayedRowCount} of ${totalRowCount} data points)` : caption;
314
+ }
95
315
  function formatXValue(value, axis, context) {
96
316
  return axis?.format ? axis.format(value.raw, context) : value.label;
97
317
  }
@@ -136,194 +356,462 @@ function assertUniqueSeriesIds(componentId, series) {
136
356
  function toggleSeriesId(hiddenSeriesIds, seriesId) {
137
357
  return hiddenSeriesIds.includes(seriesId) ? hiddenSeriesIds.filter((id) => id !== seriesId) : [...hiddenSeriesIds, seriesId];
138
358
  }
139
- function createCartesianModel(options) {
140
- const {
141
- componentId,
142
- series,
143
- hiddenSeriesIds,
144
- width,
145
- height,
146
- xAxis,
147
- yAxis,
148
- stackedArea = false
149
- } = options;
150
- assertUniqueSeriesIds(componentId, series);
151
- assertValidChartNumber(componentId, "invalid-height", height, "height");
152
- assertValidTickCount(componentId, xAxis);
153
- assertValidTickCount(componentId, yAxis);
154
- const geometry = createGeometry(width, height);
155
- const allKinds = new Set;
156
- const xValuesByKey = new Map;
157
- const normalizedSeries = series.map((item, seriesIndex) => {
158
- const seenX = new Set;
159
- const color = item.color ?? chartPaletteColor(seriesIndex);
160
- const points = item.data.map((point, pointIndex) => {
161
- const x = normalizeXValue(point.x);
162
- allKinds.add(x.kind);
163
- if (seenX.has(x.key)) {
164
- throw new Error(`[cinder/${componentId}] rule=duplicate-x series="${item.id}" x="${x.label}": duplicate x values are not supported.`);
359
+ function nearestTarget(targets, x, y, axis = "x") {
360
+ if (targets.length === 0)
361
+ return;
362
+ if (targets.length === 1)
363
+ return targets[0];
364
+ const pointerKey = axis === "x" ? x : y;
365
+ let low = 0;
366
+ let high = targets.length - 1;
367
+ while (low < high) {
368
+ const mid = low + high >> 1;
369
+ const midKey = axis === "x" ? targets[mid]?.x ?? 0 : targets[mid]?.y ?? 0;
370
+ if (midKey < pointerKey)
371
+ low = mid + 1;
372
+ else
373
+ high = mid;
374
+ }
375
+ const candidates = [];
376
+ function addBucket(start) {
377
+ const target = targets[start];
378
+ if (!target)
379
+ return;
380
+ const bucketKey = axis === "x" ? target.x : target.y;
381
+ for (let index = start;index >= 0; index--) {
382
+ const candidate = targets[index];
383
+ if (!candidate)
384
+ continue;
385
+ const candidateKey = axis === "x" ? candidate.x : candidate.y;
386
+ if (candidateKey !== bucketKey)
387
+ break;
388
+ candidates.push(candidate);
389
+ }
390
+ for (let index = start + 1;index < targets.length; index++) {
391
+ const candidate = targets[index];
392
+ if (!candidate)
393
+ continue;
394
+ const candidateKey = axis === "x" ? candidate.x : candidate.y;
395
+ if (candidateKey !== bucketKey)
396
+ break;
397
+ candidates.push(candidate);
398
+ }
399
+ }
400
+ addBucket(low);
401
+ if (low > 0) {
402
+ addBucket(low - 1);
403
+ }
404
+ let nearest;
405
+ let nearestDistance = Number.POSITIVE_INFINITY;
406
+ for (const target of candidates) {
407
+ const targetDistance = Math.hypot(target.x - x, target.y - y);
408
+ if (targetDistance >= nearestDistance)
409
+ continue;
410
+ nearest = target;
411
+ nearestDistance = targetDistance;
412
+ }
413
+ return nearest;
414
+ }
415
+ function legendVisible(legendPosition, seriesCount) {
416
+ return legendPosition !== "none" && seriesCount > 0;
417
+ }
418
+
419
+ // src/_internal/chart/chart-scale.ts
420
+ var MAXIMUM_RENDERED_SERIES_POINTS = 2000;
421
+ function evenlySample(values, count) {
422
+ if (values.length <= count)
423
+ return [...values];
424
+ if (count <= 1)
425
+ return values[0] === undefined ? [] : [values[0]];
426
+ return Array.from({ length: count }, (_, index) => {
427
+ const sourceIndex = Math.round(index * (values.length - 1) / (count - 1));
428
+ return values[sourceIndex];
429
+ });
430
+ }
431
+ function boundedGapHeavyIndices(points, limit) {
432
+ const finiteRuns = [];
433
+ let index = 0;
434
+ while (index < points.length) {
435
+ while (index < points.length && points[index]?.y === null)
436
+ index += 1;
437
+ if (index >= points.length)
438
+ break;
439
+ let representative = index;
440
+ let maximumMagnitude = Math.abs(points[index]?.y ?? 0);
441
+ while (index + 1 < points.length && points[index + 1]?.y !== null) {
442
+ index += 1;
443
+ const magnitude = Math.abs(points[index]?.y ?? 0);
444
+ if (magnitude > maximumMagnitude) {
445
+ maximumMagnitude = magnitude;
446
+ representative = index;
165
447
  }
166
- seenX.add(x.key);
167
- xValuesByKey.set(x.key, x);
168
- const y = normalizeNumericValue(componentId, item.id, x.label, point.y);
169
- return {
170
- seriesId: item.id,
171
- seriesLabel: item.label,
172
- color,
173
- x,
174
- y,
175
- originalY: point.y,
176
- index: pointIndex
177
- };
178
- });
179
- return { id: item.id, label: item.label, color, points };
448
+ }
449
+ finiteRuns.push({ end: index, representative });
450
+ index += 1;
451
+ }
452
+ const maximumFiniteRuns = Math.max(1, Math.floor((limit + 1) / 2));
453
+ const sampledRuns = evenlySample(finiteRuns, maximumFiniteRuns);
454
+ const selected = [];
455
+ sampledRuns.forEach((run, runIndex) => {
456
+ const previousRun = sampledRuns[runIndex - 1];
457
+ if (previousRun)
458
+ selected.push(previousRun.end + 1);
459
+ selected.push(run.representative);
180
460
  });
181
- if (allKinds.size > 1) {
182
- throw new Error(`[cinder/${componentId}] rule=mixed-x-domain-kind: all x values must share one domain kind.`);
183
- }
184
- if (stackedArea) {
185
- for (const item of normalizedSeries) {
186
- for (const point of item.points) {
187
- if ((point.y ?? 0) < 0) {
188
- throw new Error(`[cinder/${componentId}] rule=negative-stacked-area series="${item.id}" x="${point.x.label}": stacked areas do not support negative values.`);
189
- }
461
+ return selected.sort((a, b) => a - b);
462
+ }
463
+ function layerExtremaIndices(layers, startIndex, endIndex) {
464
+ const extrema = new Set;
465
+ for (const layer of layers) {
466
+ let minimumIndex;
467
+ let maximumIndex;
468
+ let minimumValue = Number.POSITIVE_INFINITY;
469
+ let maximumValue = Number.NEGATIVE_INFINITY;
470
+ for (let index = startIndex;index < endIndex; index++) {
471
+ const value = layer[index];
472
+ if (value == null)
473
+ continue;
474
+ if (value < minimumValue) {
475
+ minimumValue = value;
476
+ minimumIndex = index;
477
+ }
478
+ if (value > maximumValue) {
479
+ maximumValue = value;
480
+ maximumIndex = index;
190
481
  }
191
482
  }
483
+ if (minimumIndex !== undefined)
484
+ extrema.add(minimumIndex);
485
+ if (maximumIndex !== undefined)
486
+ extrema.add(maximumIndex);
192
487
  }
193
- const sortedXValues = sortXValues([...xValuesByKey.values()]);
194
- const orderByKey = new Map(sortedXValues.map((value, index) => [value.key, index]));
195
- const visibleNumericValues = [];
196
- for (const item of normalizedSeries) {
197
- if (hiddenSeriesIds.includes(item.id))
198
- continue;
199
- for (const point of item.points) {
200
- if (point.y !== null)
201
- visibleNumericValues.push(point.y);
488
+ return [...extrema];
489
+ }
490
+ function boundedGapHeavyLayerSelections(layers, pointCount, limit) {
491
+ const finiteIndices = [];
492
+ for (let index = 0;index < pointCount; index++) {
493
+ if (layers.some((layer) => layer[index] != null))
494
+ finiteIndices.push(index);
495
+ }
496
+ const maximumFiniteSamples = Math.max(1, Math.floor((limit + 1) / 2));
497
+ const retainedIndices = new Set;
498
+ const priorityIndices = [
499
+ finiteIndices[0],
500
+ finiteIndices.at(-1),
501
+ ...layerExtremaIndices(layers, 0, pointCount)
502
+ ];
503
+ for (const index of priorityIndices) {
504
+ if (index !== undefined && retainedIndices.size < maximumFiniteSamples) {
505
+ retainedIndices.add(index);
202
506
  }
203
507
  }
204
- const stackedTotalsByKey = new Map(sortedXValues.map((value) => [value.key, 0]));
205
- if (stackedArea) {
206
- for (const item of normalizedSeries) {
207
- if (hiddenSeriesIds.includes(item.id))
208
- continue;
209
- for (const point of item.points) {
210
- if (point.y === null)
211
- continue;
212
- stackedTotalsByKey.set(point.x.key, (stackedTotalsByKey.get(point.x.key) ?? 0) + point.y);
508
+ const extremaPerBucket = Math.max(1, layers.length * 2);
509
+ const bucketCount = Math.floor((maximumFiniteSamples - retainedIndices.size) / extremaPerBucket);
510
+ for (let bucketIndex = 0;bucketIndex < bucketCount; bucketIndex++) {
511
+ const startIndex = Math.floor(bucketIndex * pointCount / bucketCount);
512
+ const endIndex = Math.floor((bucketIndex + 1) * pointCount / bucketCount);
513
+ for (const index of layerExtremaIndices(layers, startIndex, endIndex)) {
514
+ if (retainedIndices.size < maximumFiniteSamples)
515
+ retainedIndices.add(index);
516
+ }
517
+ }
518
+ const remainingCapacity = maximumFiniteSamples - retainedIndices.size;
519
+ if (remainingCapacity > 0) {
520
+ const coverageCandidates = finiteIndices.filter((index) => !retainedIndices.has(index));
521
+ for (const index of evenlySample(coverageCandidates, remainingCapacity)) {
522
+ retainedIndices.add(index);
523
+ }
524
+ }
525
+ const sampledIndices = [...retainedIndices].sort((a, b) => a - b);
526
+ const selectedSourceIndices = [];
527
+ sampledIndices.forEach((sourceIndex, selectionIndex) => {
528
+ const previousSourceIndex = sampledIndices[selectionIndex - 1];
529
+ if (previousSourceIndex !== undefined && sourceIndex > previousSourceIndex + 1) {
530
+ if (layers.some((layer) => layerHasOmittedGap(layer, previousSourceIndex, sourceIndex))) {
531
+ selectedSourceIndices.push(previousSourceIndex + Math.floor((sourceIndex - previousSourceIndex) / 2));
213
532
  }
214
533
  }
534
+ selectedSourceIndices.push(sourceIndex);
535
+ });
536
+ return selectedSourceIndices.map((sourceIndex, selectionIndex) => {
537
+ const previousSourceIndex = selectedSourceIndices[selectionIndex - 1];
538
+ const forceGapLayerIndices = [];
539
+ if (previousSourceIndex !== undefined && sourceIndex > previousSourceIndex + 1) {
540
+ layers.forEach((layer, layerIndex) => {
541
+ if (layerHasOmittedGap(layer, previousSourceIndex, sourceIndex)) {
542
+ forceGapLayerIndices.push(layerIndex);
543
+ }
544
+ });
545
+ }
546
+ return { sourceIndex, forceGapLayerIndices };
547
+ });
548
+ }
549
+ function layerHasOmittedGap(layer, startIndex, endIndex) {
550
+ if (layer[startIndex] == null || layer[endIndex] == null)
551
+ return false;
552
+ for (let gapIndex = startIndex + 1;gapIndex < endIndex; gapIndex++) {
553
+ if (layer[gapIndex] == null)
554
+ return true;
555
+ }
556
+ return false;
557
+ }
558
+ function addGapBoundaryIndices(selected, pointCount, valueAt) {
559
+ for (let index = 1;index < pointCount; index++) {
560
+ const previousIsNull = valueAt(index - 1) == null;
561
+ const currentIsNull = valueAt(index) == null;
562
+ if (previousIsNull === currentIsNull)
563
+ continue;
564
+ selected.add(index - 1);
565
+ selected.add(index);
215
566
  }
216
- const domainValues = stackedArea ? [0, ...stackedTotalsByKey.values()] : visibleNumericValues;
217
- const [yMinimum, yMaximum] = createPaddedDomain(domainValues);
218
- const xStringScale = sortedXValues[0]?.kind === "string" ? createPointScale(sortedXValues.map((value) => value.key), [0, geometry.plotWidth], 0.5) : undefined;
219
- const xNumericScale = sortedXValues[0] && sortedXValues[0].kind !== "string" ? createLinearScale(createNumericDomain(sortedXValues), [0, geometry.plotWidth]) : undefined;
220
- const yScale = createLinearScale([yMinimum, yMaximum], [geometry.plotHeight, 0]);
221
- function scaleX(value) {
222
- if (value.kind === "string")
223
- return xStringScale?.(value.key) ?? 0;
224
- return xNumericScale?.(Number(value.comparable)) ?? 0;
567
+ }
568
+ function decimationIndices(points, maximumPoints = MAXIMUM_RENDERED_SERIES_POINTS) {
569
+ if (points.length <= maximumPoints || maximumPoints < 2) {
570
+ return points.map((_, index) => index);
571
+ }
572
+ const limit = Math.max(2, Math.floor(maximumPoints));
573
+ const interiorLength = points.length - 2;
574
+ const selected = new Set([0, points.length - 1]);
575
+ addGapBoundaryIndices(selected, points.length, (index) => points[index]?.y);
576
+ const remainingExtremaBudget = limit - selected.size;
577
+ const bucketCount = Math.floor(remainingExtremaBudget / 2);
578
+ if (bucketCount < 1)
579
+ return boundedGapHeavyIndices(points, limit);
580
+ for (let bucketIndex = 0;bucketIndex < bucketCount; bucketIndex++) {
581
+ const start = 1 + Math.floor(bucketIndex * interiorLength / bucketCount);
582
+ const end = 1 + Math.floor((bucketIndex + 1) * interiorLength / bucketCount);
583
+ if (end <= start)
584
+ continue;
585
+ let minimumIndex;
586
+ let maximumIndex;
587
+ let minimumValue = Number.POSITIVE_INFINITY;
588
+ let maximumValue = Number.NEGATIVE_INFINITY;
589
+ for (let index = start;index < end; index++) {
590
+ const point = points[index];
591
+ if (!point)
592
+ continue;
593
+ if (point.y === null)
594
+ continue;
595
+ if (point.y < minimumValue) {
596
+ minimumValue = point.y;
597
+ minimumIndex = index;
598
+ }
599
+ if (point.y > maximumValue) {
600
+ maximumValue = point.y;
601
+ maximumIndex = index;
602
+ }
603
+ }
604
+ if (minimumIndex !== undefined)
605
+ selected.add(minimumIndex);
606
+ if (maximumIndex !== undefined)
607
+ selected.add(maximumIndex);
225
608
  }
226
- const tickCount = xAxis?.tickCount ?? sortedXValues.length;
227
- const xTicks = buildXAxisTicks(sortedXValues, tickCount, xAxis, scaleX);
228
- const targets = [];
229
- const tableRows = [];
230
- const stackedOffsetsByKey = new Map(sortedXValues.map((value) => [value.key, 0]));
231
- const renderedSeries = normalizedSeries.map((item) => {
232
- const hidden = hiddenSeriesIds.includes(item.id);
233
- const points = item.points.filter((point) => point.y !== null).toSorted((a, b) => (orderByKey.get(a.x.key) ?? 0) - (orderByKey.get(b.x.key) ?? 0));
234
- const placedPoints = points.map((point) => {
235
- const lowerValue = stackedArea ? stackedOffsetsByKey.get(point.x.key) ?? 0 : 0;
236
- const upperValue = lowerValue + (point.y ?? 0);
237
- return {
238
- ...point,
239
- pixelX: scaleX(point.x),
240
- pixelY: yScale(stackedArea ? upperValue : point.y ?? 0)
241
- };
242
- });
243
- const coordinates = placedPoints.map((placed) => ({
244
- x: placed.pixelX,
245
- y: placed.pixelY,
246
- y0: yScale(stackedArea ? stackedOffsetsByKey.get(placed.x.key) ?? 0 : 0)
609
+ return [...selected].sort((a, b) => a - b);
610
+ }
611
+ function decimationIndicesForLayers(layers, maximumPoints = MAXIMUM_RENDERED_SERIES_POINTS) {
612
+ const pointCount = layers[0]?.length ?? 0;
613
+ if (pointCount <= maximumPoints || maximumPoints < 2) {
614
+ return Array.from({ length: pointCount }, (_, sourceIndex) => ({
615
+ sourceIndex,
616
+ forceGapLayerIndices: []
247
617
  }));
248
- if (!hidden) {
249
- for (const placed of placedPoints) {
250
- const xLabel = formatXValue(placed.x, xAxis, {
251
- seriesId: item.id,
252
- seriesLabel: item.label,
253
- index: placed.index
254
- });
255
- const valueLabel = formatNumericValue(placed.y ?? 0, yAxis, series.find((entry) => entry.id === item.id)?.valueFormatter, { seriesId: item.id, seriesLabel: item.label, index: placed.index });
256
- targets.push({
257
- id: `${item.id}-${placed.x.key}`,
258
- seriesId: item.id,
259
- seriesLabel: item.label,
260
- xLabel,
261
- valueLabel,
262
- x: placed.pixelX,
263
- y: placed.pixelY,
264
- color: item.color
265
- });
266
- tableRows.push({
267
- id: `${item.id}-${placed.x.key}`,
268
- seriesLabel: item.label,
269
- xLabel,
270
- valueLabel
271
- });
272
- }
273
- if (stackedArea) {
274
- for (const placed of placedPoints) {
275
- stackedOffsetsByKey.set(placed.x.key, (stackedOffsetsByKey.get(placed.x.key) ?? 0) + (placed.y ?? 0));
618
+ }
619
+ const limit = Math.max(2, Math.floor(maximumPoints));
620
+ const interiorLength = pointCount - 2;
621
+ const selected = new Set([0, pointCount - 1]);
622
+ for (const layer of layers) {
623
+ addGapBoundaryIndices(selected, pointCount, (index) => layer[index]);
624
+ }
625
+ const candidatesPerBucket = Math.max(1, layers.length * 2);
626
+ const bucketCount = Math.floor((limit - selected.size) / candidatesPerBucket);
627
+ if (bucketCount < 1)
628
+ return boundedGapHeavyLayerSelections(layers, pointCount, limit);
629
+ for (let bucketIndex = 0;bucketIndex < bucketCount; bucketIndex++) {
630
+ const start = 1 + Math.floor(bucketIndex * interiorLength / bucketCount);
631
+ const end = 1 + Math.floor((bucketIndex + 1) * interiorLength / bucketCount);
632
+ if (end <= start)
633
+ continue;
634
+ for (const layer of layers) {
635
+ let minimumIndex;
636
+ let maximumIndex;
637
+ let minimumValue = Number.POSITIVE_INFINITY;
638
+ let maximumValue = Number.NEGATIVE_INFINITY;
639
+ for (let index = start;index < end; index++) {
640
+ const value = layer[index];
641
+ if (value === null || value === undefined)
642
+ continue;
643
+ if (value < minimumValue) {
644
+ minimumValue = value;
645
+ minimumIndex = index;
646
+ }
647
+ if (value > maximumValue) {
648
+ maximumValue = value;
649
+ maximumIndex = index;
276
650
  }
277
651
  }
652
+ if (minimumIndex !== undefined)
653
+ selected.add(minimumIndex);
654
+ if (maximumIndex !== undefined)
655
+ selected.add(maximumIndex);
278
656
  }
279
- return {
280
- ...item,
281
- hidden,
282
- points: hidden ? [] : placedPoints,
283
- path: hidden ? "" : createLinePath(coordinates),
284
- areaPath: hidden ? "" : createAreaPath(coordinates, stackedArea ? undefined : geometry.plotHeight)
285
- };
657
+ }
658
+ return [...selected].sort((a, b) => a - b).map((sourceIndex) => ({ sourceIndex, forceGapLayerIndices: [] }));
659
+ }
660
+ function decimatePlacedPoints(points, maximumPoints = MAXIMUM_RENDERED_SERIES_POINTS) {
661
+ return decimationIndices(points, maximumPoints).map((index) => points[index]);
662
+ }
663
+ function normalizeNumericValue(componentId, seriesId, xLabel, value) {
664
+ if (value === null || value === undefined)
665
+ return null;
666
+ if (!Number.isFinite(value)) {
667
+ throw new Error(`[cinder/${componentId}] rule=non-finite-y series="${seriesId}" x="${xLabel}": y values must be finite numbers.`);
668
+ }
669
+ return value;
670
+ }
671
+ function sortXValues(values) {
672
+ if (values[0]?.kind === "string")
673
+ return values;
674
+ return values.slice().sort((a, b) => Number(a.comparable) - Number(b.comparable));
675
+ }
676
+ function createPaddedDomain(values) {
677
+ if (values.length === 0)
678
+ return [-1, 1];
679
+ let minimum = values[0];
680
+ let maximum = values[0];
681
+ for (let index = 1;index < values.length; index++) {
682
+ const value = values[index];
683
+ if (value < minimum)
684
+ minimum = value;
685
+ if (value > maximum)
686
+ maximum = value;
687
+ }
688
+ if (minimum === maximum)
689
+ return [minimum - 1, maximum + 1];
690
+ return [Math.min(0, minimum), Math.max(0, maximum)];
691
+ }
692
+ function createLinearScale(domain, range) {
693
+ const [domainMinimum, domainMaximum] = domain[0] === domain[1] ? [domain[0] - 1, domain[1] + 1] : domain;
694
+ const [rangeMinimum, rangeMaximum] = range;
695
+ const domainSpan = domainMaximum - domainMinimum;
696
+ const rangeSpan = rangeMaximum - rangeMinimum;
697
+ const scale = Object.assign((value) => rangeMinimum + (value - domainMinimum) / domainSpan * rangeSpan, {
698
+ ticks: (count) => createTicks([domainMinimum, domainMaximum], count)
286
699
  });
287
- targets.sort((a, b) => a.x - b.x);
288
- return {
289
- geometry,
290
- xTicks,
291
- yTicks: yScale.ticks(yAxis?.tickCount ?? 5),
292
- normalizedSeries: renderedSeries,
293
- tableRows,
294
- targets,
295
- empty: targets.length === 0,
296
- yDomain: [yMinimum, yMaximum]
297
- };
700
+ return scale;
298
701
  }
299
- function buildXAxisTicks(sortedXValues, tickCount, xAxis, scaleX) {
300
- if (sortedXValues.length === 0)
301
- return [];
302
- const safeTickCount = Math.max(1, Math.min(tickCount, sortedXValues.length));
303
- if (safeTickCount >= sortedXValues.length) {
304
- return sortedXValues.map((value, index) => ({
305
- label: formatXValue(value, xAxis, { index }),
306
- x: scaleX(value)
307
- }));
702
+ function createPointScale(domain, range, padding) {
703
+ const positions = new Map;
704
+ const [rangeMinimum, rangeMaximum] = range;
705
+ if (domain.length === 1) {
706
+ positions.set(domain[0] ?? "", rangeMinimum + (rangeMaximum - rangeMinimum) / 2);
707
+ } else {
708
+ const step = (rangeMaximum - rangeMinimum) / Math.max(1, domain.length - 1 + padding * 2);
709
+ const start = rangeMinimum + step * padding;
710
+ domain.forEach((value, index) => positions.set(value, start + step * index));
711
+ }
712
+ return (value) => positions.get(value);
713
+ }
714
+ function createBandScale(domain, range, padding) {
715
+ const positions = new Map;
716
+ const [rangeMinimum, rangeMaximum] = range;
717
+ const availableSize = Math.max(0, rangeMaximum - rangeMinimum);
718
+ const step = domain.length === 0 ? 0 : availableSize / Math.max(1, domain.length + padding * (domain.length - 1));
719
+ const bandWidth = Math.max(0, step * (1 - padding));
720
+ domain.forEach((value, index) => positions.set(value, rangeMinimum + step * index));
721
+ const scale = Object.assign((value) => positions.get(value), {
722
+ bandwidth: () => bandWidth
723
+ });
724
+ return scale;
725
+ }
726
+ function createNumericDomain(values) {
727
+ if (values.length === 0)
728
+ return [0, 1];
729
+ let minimum = Number(values[0].comparable);
730
+ let maximum = minimum;
731
+ for (let index = 1;index < values.length; index++) {
732
+ const numeric = Number(values[index].comparable);
733
+ if (numeric < minimum)
734
+ minimum = numeric;
735
+ if (numeric > maximum)
736
+ maximum = numeric;
308
737
  }
309
- if (safeTickCount === 1) {
310
- const value = sortedXValues[0];
311
- return value ? [{ label: formatXValue(value, xAxis, { index: 0 }), x: scaleX(value) }] : [];
738
+ return minimum === maximum ? [minimum - 1, maximum + 1] : [minimum, maximum];
739
+ }
740
+ function createTicks(domain, count) {
741
+ const safeCount = Math.max(1, Math.floor(count));
742
+ if (safeCount === 1)
743
+ return [domain[0]];
744
+ const step = (domain[1] - domain[0]) / (safeCount - 1);
745
+ return Array.from({ length: safeCount }, (_, index) => domain[0] + step * index);
746
+ }
747
+ function createLinePath(points) {
748
+ if (points.length === 0)
749
+ return "";
750
+ const commands = [];
751
+ for (const [index, point] of points.entries()) {
752
+ if (point.y === null)
753
+ continue;
754
+ const previous = points[index - 1];
755
+ commands.push(previous?.y === null || commands.length === 0 ? `M${formatPathNumber(point.x)},${formatPathNumber(point.y)}` : `L${formatPathNumber(point.x)},${formatPathNumber(point.y)}`);
312
756
  }
313
- const step = (sortedXValues.length - 1) / (safeTickCount - 1);
314
- const ticks = [];
315
- for (let i = 0;i < safeTickCount; i++) {
316
- const sourceIndex = Math.round(i * step);
317
- const value = sortedXValues[sourceIndex];
318
- if (!value)
757
+ return commands.join("");
758
+ }
759
+ function createAreaPath(points, baseline) {
760
+ const segments = [];
761
+ let segment = [];
762
+ for (const point of points) {
763
+ if (point.y === null) {
764
+ if (segment.length > 0)
765
+ segments.push(segment);
766
+ segment = [];
319
767
  continue;
320
- ticks.push({
321
- label: formatXValue(value, xAxis, { index: i }),
322
- x: scaleX(value)
323
- });
768
+ }
769
+ segment.push({ ...point, y: point.y });
770
+ }
771
+ if (segment.length > 0)
772
+ segments.push(segment);
773
+ return segments.map((visiblePoints) => {
774
+ const firstPoint = visiblePoints[0];
775
+ const lowerPoints = [];
776
+ for (let index = visiblePoints.length - 1;index >= 0; index--) {
777
+ const point = visiblePoints[index];
778
+ lowerPoints.push(`L${formatPathNumber(point.x)},${formatPathNumber(point.y0 ?? baseline ?? 0)}`);
779
+ }
780
+ return [
781
+ `M${formatPathNumber(firstPoint.x)},${formatPathNumber(firstPoint.y0 ?? baseline ?? 0)}`,
782
+ `L${formatPathNumber(firstPoint.x)},${formatPathNumber(firstPoint.y)}`,
783
+ ...visiblePoints.slice(1).map((point) => `L${formatPathNumber(point.x)},${formatPathNumber(point.y)}`),
784
+ ...lowerPoints,
785
+ "Z"
786
+ ].join("");
787
+ }).join("");
788
+ }
789
+ function createStackedBarDomainValues(datumByKey, categories, series) {
790
+ const values = [0];
791
+ for (const category of categories) {
792
+ const datum = datumByKey.get(category.key);
793
+ if (!datum)
794
+ continue;
795
+ let positiveTotal = 0;
796
+ let negativeTotal = 0;
797
+ for (const item of series) {
798
+ const value = datum[item.valueKey];
799
+ if (typeof value !== "number")
800
+ continue;
801
+ if (value >= 0)
802
+ positiveTotal += value;
803
+ else
804
+ negativeTotal += value;
805
+ }
806
+ values.push(positiveTotal, negativeTotal);
324
807
  }
325
- return ticks;
808
+ return values;
326
809
  }
810
+ function formatPathNumber(value) {
811
+ return Number(value.toFixed(3)).toString();
812
+ }
813
+
814
+ // src/_internal/chart/chart-bar-model.ts
327
815
  function createBarModel(options) {
328
816
  const {
329
817
  data,
@@ -335,12 +823,17 @@ function createBarModel(options) {
335
823
  orientation,
336
824
  mode,
337
825
  xAxis,
338
- yAxis
826
+ yAxis,
827
+ theme,
828
+ measureText = false,
829
+ measurementElement,
830
+ measurementVersion = 0
339
831
  } = options;
340
832
  assertUniqueSeriesIds("bar-chart", series);
341
833
  assertValidChartNumber("bar-chart", "invalid-height", height, "height");
342
834
  assertValidTickCount("bar-chart", xAxis);
343
835
  assertValidTickCount("bar-chart", yAxis);
836
+ const resolvedTheme = resolveChartTheme(theme);
344
837
  const categories = [];
345
838
  const seenCategories = new Set;
346
839
  const categoryKinds = new Set;
@@ -381,21 +874,37 @@ function createBarModel(options) {
381
874
  }
382
875
  const sortedCategories = sortXValues(categories);
383
876
  const categoryLabels = sortedCategories.map((category, index) => formatXValue(category, orientation === "vertical" ? xAxis : yAxis, { index }));
384
- const horizontalCategoryLabelLayout = orientation === "horizontal" ? createHorizontalCategoryLabelLayout(categoryLabels, width) : undefined;
385
- const geometry = createGeometry(width, height, horizontalCategoryLabelLayout?.marginLeft);
877
+ const horizontalCategoryLabelLayout = orientation === "horizontal" ? createHorizontalCategoryLabelLayout(categoryLabels, width, {
878
+ measureText,
879
+ measurementElement,
880
+ measurementVersion
881
+ }) : undefined;
386
882
  const valueDomain = createPaddedDomain(mode === "stacked" ? createStackedBarDomainValues(datumByKey, sortedCategories, visibleSeries) : visibleValues);
883
+ const valueTickAxis = orientation === "vertical" ? yAxis : xAxis;
884
+ const valueTicks = createTicks(valueDomain, valueTickAxis?.tickCount ?? 5);
885
+ const valueTickLabels = valueTicks.map((tick, index) => formatNumericValue(tick, valueTickAxis, undefined, { index }));
886
+ const geometry = createChartGeometry(width, height, {
887
+ xTickLabels: orientation === "vertical" ? categoryLabels : valueTickLabels,
888
+ yTickLabels: orientation === "vertical" ? valueTickLabels : categoryLabels,
889
+ xAxis,
890
+ yAxis,
891
+ measureText,
892
+ measurementElement,
893
+ measurementVersion,
894
+ marginLeft: horizontalCategoryLabelLayout?.marginLeft
895
+ });
387
896
  if (sortedCategories.length === 0) {
388
- const tickAxis = orientation === "vertical" ? yAxis : xAxis;
389
897
  return {
390
898
  geometry,
391
899
  categories: [],
392
- yTicks: createTicks(valueDomain, tickAxis?.tickCount ?? 5),
900
+ yTicks: valueTicks,
393
901
  categoryTicks: [],
394
902
  bars: [],
395
903
  tableRows: [],
396
904
  targets: [],
397
905
  empty: true,
398
- valueDomain
906
+ valueDomain,
907
+ theme: resolvedTheme
399
908
  };
400
909
  }
401
910
  const valueScale = createLinearScale(valueDomain, orientation === "vertical" ? [geometry.plotHeight, 0] : [0, geometry.plotWidth]);
@@ -427,7 +936,7 @@ function createBarModel(options) {
427
936
  return;
428
937
  const value = rawValue;
429
938
  const seriesColorIndex = Math.max(0, series.findIndex((entry) => entry.id === item.id));
430
- const color = item.color ?? chartPaletteColor(seriesColorIndex);
939
+ const color = item.color ?? chartPaletteColor(seriesColorIndex, resolvedTheme.palette);
431
940
  const categoryPosition = categoryScale(category.key) ?? 0;
432
941
  let x = 0;
433
942
  let y = 0;
@@ -503,253 +1012,328 @@ function createBarModel(options) {
503
1012
  return {
504
1013
  geometry,
505
1014
  categories: sortedCategories,
506
- yTicks: valueScale.ticks((orientation === "vertical" ? yAxis : xAxis)?.tickCount ?? 5),
1015
+ yTicks: valueTicks,
507
1016
  categoryTicks,
508
1017
  bars,
509
1018
  tableRows,
510
1019
  targets,
511
1020
  empty: targets.length === 0,
512
- valueDomain
1021
+ valueDomain,
1022
+ theme: resolvedTheme
513
1023
  };
514
1024
  }
515
- function nearestTarget(targets, x, y, axis = "x") {
516
- if (targets.length === 0)
517
- return;
518
- if (targets.length === 1)
519
- return targets[0];
520
- const pointerKey = axis === "x" ? x : y;
521
- let low = 0;
522
- let high = targets.length - 1;
523
- while (low < high) {
524
- const mid = low + high >> 1;
525
- const midKey = axis === "x" ? targets[mid]?.x ?? 0 : targets[mid]?.y ?? 0;
526
- if (midKey < pointerKey)
527
- low = mid + 1;
528
- else
529
- high = mid;
1025
+ // src/_internal/chart/chart-cartesian-model.ts
1026
+ var DEFAULT_MAXIMUM_X_TICK_COUNT = 8;
1027
+ function createCartesianModel(options) {
1028
+ const {
1029
+ componentId,
1030
+ series,
1031
+ hiddenSeriesIds,
1032
+ width,
1033
+ height,
1034
+ xAxis,
1035
+ yAxis,
1036
+ stackedArea = false,
1037
+ theme,
1038
+ measureText = false,
1039
+ measurementElement,
1040
+ measurementVersion = 0
1041
+ } = options;
1042
+ assertUniqueSeriesIds(componentId, series);
1043
+ assertValidChartNumber(componentId, "invalid-height", height, "height");
1044
+ assertValidTickCount(componentId, xAxis);
1045
+ assertValidTickCount(componentId, yAxis);
1046
+ const resolvedTheme = resolveChartTheme(theme);
1047
+ let geometry = createChartGeometry(width, height, {
1048
+ measureText,
1049
+ measurementElement,
1050
+ measurementVersion
1051
+ });
1052
+ const allKinds = new Set;
1053
+ const xValuesByKey = new Map;
1054
+ const normalizedSeries = series.map((item, seriesIndex) => {
1055
+ const seenX = new Set;
1056
+ const color = item.color ?? chartPaletteColor(seriesIndex, resolvedTheme.palette);
1057
+ const points = item.data.map((point, pointIndex) => {
1058
+ const x = normalizeXValue(point.x);
1059
+ allKinds.add(x.kind);
1060
+ if (seenX.has(x.key)) {
1061
+ throw new Error(`[cinder/${componentId}] rule=duplicate-x series="${item.id}" x="${x.label}": duplicate x values are not supported.`);
1062
+ }
1063
+ seenX.add(x.key);
1064
+ xValuesByKey.set(x.key, x);
1065
+ const y = normalizeNumericValue(componentId, item.id, x.label, point.y);
1066
+ return {
1067
+ seriesId: item.id,
1068
+ seriesLabel: item.label,
1069
+ color,
1070
+ x,
1071
+ y,
1072
+ originalY: point.y,
1073
+ index: pointIndex
1074
+ };
1075
+ });
1076
+ return { id: item.id, label: item.label, color, points };
1077
+ });
1078
+ if (allKinds.size > 1) {
1079
+ throw new Error(`[cinder/${componentId}] rule=mixed-x-domain-kind: all x values must share one domain kind.`);
530
1080
  }
531
- const candidates = [];
532
- function addBucket(start) {
533
- const target = targets[start];
534
- if (!target)
535
- return;
536
- const bucketKey = axis === "x" ? target.x : target.y;
537
- for (let index = start;index >= 0; index--) {
538
- const candidate = targets[index];
539
- if (!candidate)
540
- continue;
541
- const candidateKey = axis === "x" ? candidate.x : candidate.y;
542
- if (candidateKey !== bucketKey)
543
- break;
544
- candidates.push(candidate);
545
- }
546
- for (let index = start + 1;index < targets.length; index++) {
547
- const candidate = targets[index];
548
- if (!candidate)
549
- continue;
550
- const candidateKey = axis === "x" ? candidate.x : candidate.y;
551
- if (candidateKey !== bucketKey)
552
- break;
553
- candidates.push(candidate);
1081
+ if (stackedArea) {
1082
+ for (const item of normalizedSeries) {
1083
+ for (const point of item.points) {
1084
+ if ((point.y ?? 0) < 0) {
1085
+ throw new Error(`[cinder/${componentId}] rule=negative-stacked-area series="${item.id}" x="${point.x.label}": stacked areas do not support negative values.`);
1086
+ }
1087
+ }
554
1088
  }
555
1089
  }
556
- addBucket(low);
557
- if (low > 0) {
558
- addBucket(low - 1);
559
- }
560
- let nearest;
561
- let nearestDistance = Number.POSITIVE_INFINITY;
562
- for (const target of candidates) {
563
- const targetDistance = Math.hypot(target.x - x, target.y - y);
564
- if (targetDistance >= nearestDistance)
1090
+ const sortedXValues = sortXValues([...xValuesByKey.values()]);
1091
+ const orderByKey = new Map(sortedXValues.map((value, index) => [value.key, index]));
1092
+ const visibleNumericValues = [];
1093
+ for (const item of normalizedSeries) {
1094
+ if (hiddenSeriesIds.includes(item.id))
565
1095
  continue;
566
- nearest = target;
567
- nearestDistance = targetDistance;
1096
+ for (const point of item.points) {
1097
+ if (point.y !== null)
1098
+ visibleNumericValues.push(point.y);
1099
+ }
568
1100
  }
569
- return nearest;
570
- }
571
- function legendVisible(legendPosition, seriesCount) {
572
- return legendPosition !== "none" && seriesCount > 0;
573
- }
574
- var DEFAULT_CHART_MARGIN_LEFT = 48;
575
- var HORIZONTAL_CATEGORY_LABEL_CHARACTER_WIDTH = 12;
576
- var HORIZONTAL_CATEGORY_LABEL_GAP = 8;
577
- var HORIZONTAL_CATEGORY_LABEL_OUTER_PADDING = 8;
578
- var MAXIMUM_HORIZONTAL_CATEGORY_LABEL_FRACTION = 0.4;
579
- function createGeometry(width, height, marginLeft = DEFAULT_CHART_MARGIN_LEFT) {
580
- const marginTop = 16;
581
- const marginRight = 16;
582
- const marginBottom = 36;
583
- return {
584
- plotWidth: Math.max(1, width - marginLeft - marginRight),
585
- plotHeight: Math.max(1, height - marginTop - marginBottom),
586
- marginTop,
587
- marginRight,
588
- marginBottom,
589
- marginLeft
590
- };
591
- }
592
- function createHorizontalCategoryLabelLayout(labels, chartWidth) {
593
- const maximumMarginLeft = Math.max(DEFAULT_CHART_MARGIN_LEFT, Math.floor(chartWidth * MAXIMUM_HORIZONTAL_CATEGORY_LABEL_FRACTION));
594
- let longestLabelWidth = 0;
595
- for (const label of labels) {
596
- longestLabelWidth = Math.max(longestLabelWidth, estimateHorizontalCategoryLabelWidth(label));
1101
+ const stackedTotalsByKey = new Map(sortedXValues.map((value) => [value.key, 0]));
1102
+ if (stackedArea) {
1103
+ for (const item of normalizedSeries) {
1104
+ if (hiddenSeriesIds.includes(item.id))
1105
+ continue;
1106
+ for (const point of item.points) {
1107
+ if (point.y === null)
1108
+ continue;
1109
+ stackedTotalsByKey.set(point.x.key, (stackedTotalsByKey.get(point.x.key) ?? 0) + point.y);
1110
+ }
1111
+ }
597
1112
  }
598
- const requestedMarginLeft = longestLabelWidth + HORIZONTAL_CATEGORY_LABEL_GAP + HORIZONTAL_CATEGORY_LABEL_OUTER_PADDING;
599
- const marginLeft = Math.min(maximumMarginLeft, Math.max(DEFAULT_CHART_MARGIN_LEFT, requestedMarginLeft));
600
- const availableLabelWidth = Math.max(0, marginLeft - HORIZONTAL_CATEGORY_LABEL_GAP - HORIZONTAL_CATEGORY_LABEL_OUTER_PADDING);
1113
+ const domainValues = stackedArea || componentId === "area-chart" ? [0, ...stackedArea ? stackedTotalsByKey.values() : visibleNumericValues] : visibleNumericValues;
1114
+ const [yMinimum, yMaximum] = createPaddedDomain(domainValues);
1115
+ const tickCount = xAxis?.tickCount ?? Math.min(sortedXValues.length, DEFAULT_MAXIMUM_X_TICK_COUNT);
1116
+ const preliminaryXTicks = buildXAxisTicks(sortedXValues, tickCount, xAxis, () => 0);
1117
+ const yTicks = createTicks([yMinimum, yMaximum], yAxis?.tickCount ?? 5);
1118
+ geometry = createChartGeometry(width, height, {
1119
+ xTickLabels: preliminaryXTicks.map((tick) => tick.label),
1120
+ yTickLabels: yTicks.map((tick, index) => formatNumericValue(tick, yAxis, undefined, { index })),
1121
+ xAxis,
1122
+ yAxis,
1123
+ measureText,
1124
+ measurementElement,
1125
+ measurementVersion
1126
+ });
1127
+ const xStringScale = sortedXValues[0]?.kind === "string" ? createPointScale(sortedXValues.map((value) => value.key), [0, geometry.plotWidth], 0.5) : undefined;
1128
+ const xNumericScale = sortedXValues[0] && sortedXValues[0].kind !== "string" ? createLinearScale(createNumericDomain(sortedXValues), [0, geometry.plotWidth]) : undefined;
1129
+ const yScale = createLinearScale([yMinimum, yMaximum], [geometry.plotHeight, 0]);
1130
+ function scaleX(value) {
1131
+ if (value.kind === "string")
1132
+ return xStringScale?.(value.key) ?? 0;
1133
+ return xNumericScale?.(Number(value.comparable)) ?? 0;
1134
+ }
1135
+ const xTicks = buildXAxisTicks(sortedXValues, tickCount, xAxis, scaleX);
1136
+ const targets = [];
1137
+ const tableRows = [];
1138
+ const stackedOffsetsByKey = new Map(sortedXValues.map((value) => [value.key, 0]));
1139
+ const normalizedPointsBySeriesId = stackedArea ? new Map(normalizedSeries.map((item) => [
1140
+ item.id,
1141
+ new Map(item.points.map((point) => [point.x.key, point]))
1142
+ ])) : undefined;
1143
+ const stackedRenderXValues = stackedArea ? sortedXValues.filter((value) => normalizedSeries.some((item) => !hiddenSeriesIds.includes(item.id) && normalizedPointsBySeriesId?.get(item.id)?.has(value.key))) : undefined;
1144
+ const stackedRenderDomain = stackedRenderXValues ?? [];
1145
+ const stackedVisibleSeries = stackedArea ? normalizedSeries.filter((item) => !hiddenSeriesIds.includes(item.id)) : [];
1146
+ const stackedLayerIndexBySeriesId = new Map(stackedVisibleSeries.map((item, layerIndex) => [item.id, layerIndex]));
1147
+ const stackedBoundaryLayers = stackedArea ? (() => {
1148
+ const cumulativeValuesByKey = new Map(stackedRenderDomain.map((value) => [value.key, 0]));
1149
+ return stackedVisibleSeries.map((item) => stackedRenderDomain.map((value) => {
1150
+ const point = normalizedPointsBySeriesId?.get(item.id)?.get(value.key);
1151
+ if (point?.y === null || point?.y === undefined)
1152
+ return null;
1153
+ const cumulativeValue = (cumulativeValuesByKey.get(value.key) ?? 0) + point.y;
1154
+ cumulativeValuesByKey.set(value.key, cumulativeValue);
1155
+ return cumulativeValue;
1156
+ }));
1157
+ })() : undefined;
1158
+ const stackedRenderSelections = stackedBoundaryLayers ? decimationIndicesForLayers(stackedBoundaryLayers) : undefined;
1159
+ const renderedSeries = normalizedSeries.map((item) => {
1160
+ const hidden = hiddenSeriesIds.includes(item.id);
1161
+ const points = item.points.slice().sort((a, b) => (orderByKey.get(a.x.key) ?? 0) - (orderByKey.get(b.x.key) ?? 0));
1162
+ const placedPoints = points.map((point) => {
1163
+ const lowerValue = stackedArea ? stackedOffsetsByKey.get(point.x.key) ?? 0 : 0;
1164
+ const upperValue = lowerValue + (point.y ?? 0);
1165
+ return {
1166
+ ...point,
1167
+ pixelX: scaleX(point.x),
1168
+ pixelY: yScale(stackedArea ? upperValue : point.y ?? 0),
1169
+ pixelY0: yScale(stackedArea ? lowerValue : 0)
1170
+ };
1171
+ });
1172
+ const placedPointsByKey = stackedRenderSelections ? new Map(placedPoints.map((point) => [point.x.key, point])) : undefined;
1173
+ const renderPoints = stackedRenderSelections ? stackedRenderSelections.map(({ sourceIndex, forceGapLayerIndices }) => {
1174
+ const x = stackedRenderDomain[sourceIndex];
1175
+ const layerIndex = stackedLayerIndexBySeriesId.get(item.id);
1176
+ const forceGap = layerIndex !== undefined && forceGapLayerIndices.includes(layerIndex);
1177
+ if (!forceGap) {
1178
+ const placedPoint = placedPointsByKey?.get(x.key);
1179
+ if (placedPoint)
1180
+ return placedPoint;
1181
+ }
1182
+ return {
1183
+ seriesId: item.id,
1184
+ seriesLabel: item.label,
1185
+ color: item.color,
1186
+ x,
1187
+ y: null,
1188
+ originalY: null,
1189
+ index: -1,
1190
+ pixelX: scaleX(x),
1191
+ pixelY: 0,
1192
+ pixelY0: stackedArea ? yScale(stackedOffsetsByKey.get(x.key) ?? 0) : yScale(0)
1193
+ };
1194
+ }) : decimatePlacedPoints(placedPoints);
1195
+ const coordinates = renderPoints.map((placed) => ({
1196
+ x: placed.pixelX,
1197
+ y: placed.y === null ? null : placed.pixelY,
1198
+ y0: placed.pixelY0
1199
+ }));
1200
+ if (!hidden) {
1201
+ for (const placed of placedPoints) {
1202
+ if (placed.y === null)
1203
+ continue;
1204
+ const xLabel = formatXValue(placed.x, xAxis, {
1205
+ seriesId: item.id,
1206
+ seriesLabel: item.label,
1207
+ index: placed.index
1208
+ });
1209
+ const valueLabel = formatNumericValue(placed.y ?? 0, yAxis, series.find((entry) => entry.id === item.id)?.valueFormatter, { seriesId: item.id, seriesLabel: item.label, index: placed.index });
1210
+ targets.push({
1211
+ id: `${item.id}-${placed.x.key}`,
1212
+ seriesId: item.id,
1213
+ seriesLabel: item.label,
1214
+ xLabel,
1215
+ valueLabel,
1216
+ x: placed.pixelX,
1217
+ y: placed.pixelY,
1218
+ color: item.color
1219
+ });
1220
+ tableRows.push({
1221
+ id: `${item.id}-${placed.x.key}`,
1222
+ seriesId: item.id,
1223
+ seriesLabel: item.label,
1224
+ xLabel,
1225
+ valueLabel
1226
+ });
1227
+ }
1228
+ if (stackedArea) {
1229
+ for (const placed of placedPoints) {
1230
+ stackedOffsetsByKey.set(placed.x.key, (stackedOffsetsByKey.get(placed.x.key) ?? 0) + (placed.y ?? 0));
1231
+ }
1232
+ }
1233
+ }
1234
+ return {
1235
+ ...item,
1236
+ hidden,
1237
+ points: hidden ? [] : renderPoints,
1238
+ path: hidden ? "" : createLinePath(coordinates),
1239
+ areaPath: hidden ? "" : createAreaPath(coordinates, stackedArea ? undefined : geometry.plotHeight)
1240
+ };
1241
+ });
1242
+ targets.sort((a, b) => a.x - b.x);
601
1243
  return {
602
- marginLeft,
603
- labels: labels.map((label) => truncateHorizontalCategoryLabel(label, availableLabelWidth))
1244
+ geometry,
1245
+ xTicks,
1246
+ yTicks,
1247
+ normalizedSeries: renderedSeries,
1248
+ tableRows: evenlySampleTableRows(tableRows, MAXIMUM_RENDERED_SERIES_POINTS),
1249
+ targets,
1250
+ empty: targets.length === 0,
1251
+ yDomain: [yMinimum, yMaximum],
1252
+ theme: resolvedTheme,
1253
+ marks: series.map((item) => ({
1254
+ seriesId: item.id,
1255
+ descriptors: componentId === "line-chart" ? [
1256
+ { type: "line", data: item.data },
1257
+ { type: "point", data: item.data }
1258
+ ] : [
1259
+ { type: "area", data: item.data },
1260
+ { type: "line", data: item.data }
1261
+ ]
1262
+ }))
604
1263
  };
605
1264
  }
606
- function estimateHorizontalCategoryLabelWidth(label) {
607
- return Array.from(label).length * HORIZONTAL_CATEGORY_LABEL_CHARACTER_WIDTH;
608
- }
609
- function truncateHorizontalCategoryLabel(label, availableWidth) {
610
- if (estimateHorizontalCategoryLabelWidth(label) <= availableWidth)
611
- return label;
612
- const availableCharacterCount = Math.floor(availableWidth / HORIZONTAL_CATEGORY_LABEL_CHARACTER_WIDTH);
613
- if (availableCharacterCount <= 0)
614
- return "";
615
- if (availableCharacterCount === 1)
616
- return "…";
617
- return `${Array.from(label).slice(0, availableCharacterCount - 1).join("")}…`;
618
- }
619
- function normalizeNumericValue(componentId, seriesId, xLabel, value) {
620
- if (value === null || value === undefined)
621
- return null;
622
- if (!Number.isFinite(value)) {
623
- throw new Error(`[cinder/${componentId}] rule=non-finite-y series="${seriesId}" x="${xLabel}": y values must be finite numbers.`);
624
- }
625
- return value;
626
- }
627
- function sortXValues(values) {
628
- if (values[0]?.kind === "string")
629
- return values;
630
- return [...values].toSorted((a, b) => Number(a.comparable) - Number(b.comparable));
631
- }
632
- function createPaddedDomain(values) {
633
- if (values.length === 0)
634
- return [-1, 1];
635
- let minimum = values[0];
636
- let maximum = values[0];
637
- for (let index = 1;index < values.length; index++) {
638
- const value = values[index];
639
- if (value < minimum)
640
- minimum = value;
641
- if (value > maximum)
642
- maximum = value;
1265
+ function evenlySampleTableRows(rows, maximumRows) {
1266
+ if (rows.length <= maximumRows)
1267
+ return rows;
1268
+ if (maximumRows <= 0)
1269
+ return [];
1270
+ const rowsBySeriesId = new Map;
1271
+ for (const row of rows) {
1272
+ const seriesRows = rowsBySeriesId.get(row.seriesId);
1273
+ if (seriesRows)
1274
+ seriesRows.push(row);
1275
+ else
1276
+ rowsBySeriesId.set(row.seriesId, [row]);
1277
+ }
1278
+ const seriesGroups = [...rowsBySeriesId.values()];
1279
+ if (seriesGroups.length >= maximumRows) {
1280
+ return seriesGroups.slice(0, maximumRows).map((group) => group[0]);
1281
+ }
1282
+ const remainingRows = maximumRows - seriesGroups.length;
1283
+ const capacities = seriesGroups.map((group) => group.length - 1);
1284
+ const totalCapacity = capacities.reduce((total, capacity) => total + capacity, 0);
1285
+ const exactShares = capacities.map((capacity) => remainingRows * capacity / totalCapacity);
1286
+ const allocations = exactShares.map((share) => 1 + Math.floor(share));
1287
+ let undistributedRows = maximumRows - allocations.reduce((total, count) => total + count, 0);
1288
+ const allocationOrder = exactShares.map((share, index) => ({ index, remainder: share - Math.floor(share) })).sort((a, b) => b.remainder - a.remainder || a.index - b.index);
1289
+ for (const { index } of allocationOrder) {
1290
+ if (undistributedRows === 0)
1291
+ break;
1292
+ if (allocations[index] >= seriesGroups[index].length)
1293
+ continue;
1294
+ allocations[index] += 1;
1295
+ undistributedRows -= 1;
643
1296
  }
644
- if (minimum === maximum)
645
- return [minimum - 1, maximum + 1];
646
- return [Math.min(0, minimum), Math.max(0, maximum)];
1297
+ return seriesGroups.flatMap((group, index) => evenlySampleRows(group, allocations[index]));
647
1298
  }
648
- function createLinearScale(domain, range) {
649
- const [domainMinimum, domainMaximum] = domain[0] === domain[1] ? [domain[0] - 1, domain[1] + 1] : domain;
650
- const [rangeMinimum, rangeMaximum] = range;
651
- const domainSpan = domainMaximum - domainMinimum;
652
- const rangeSpan = rangeMaximum - rangeMinimum;
653
- const scale = Object.assign((value) => rangeMinimum + (value - domainMinimum) / domainSpan * rangeSpan, {
654
- ticks: (count) => createTicks([domainMinimum, domainMaximum], count)
1299
+ function evenlySampleRows(rows, requestedRows) {
1300
+ if (rows.length <= requestedRows)
1301
+ return rows;
1302
+ if (requestedRows <= 1)
1303
+ return rows[0] === undefined ? [] : [rows[0]];
1304
+ return Array.from({ length: requestedRows }, (_, index) => {
1305
+ const sourceIndex = Math.round(index * (rows.length - 1) / (requestedRows - 1));
1306
+ return rows[sourceIndex];
655
1307
  });
656
- return scale;
657
1308
  }
658
- function createPointScale(domain, range, padding) {
659
- const positions = new Map;
660
- const [rangeMinimum, rangeMaximum] = range;
661
- if (domain.length === 1) {
662
- positions.set(domain[0] ?? "", rangeMinimum + (rangeMaximum - rangeMinimum) / 2);
663
- } else {
664
- const step = (rangeMaximum - rangeMinimum) / Math.max(1, domain.length - 1 + padding * 2);
665
- const start = rangeMinimum + step * padding;
666
- domain.forEach((value, index) => positions.set(value, start + step * index));
1309
+ function buildXAxisTicks(sortedXValues, tickCount, xAxis, scaleX) {
1310
+ if (sortedXValues.length === 0)
1311
+ return [];
1312
+ const safeTickCount = Math.max(1, Math.min(tickCount, sortedXValues.length));
1313
+ if (safeTickCount >= sortedXValues.length) {
1314
+ return sortedXValues.map((value, index) => ({
1315
+ label: formatXValue(value, xAxis, { index }),
1316
+ x: scaleX(value)
1317
+ }));
667
1318
  }
668
- return (value) => positions.get(value);
669
- }
670
- function createBandScale(domain, range, padding) {
671
- const positions = new Map;
672
- const [rangeMinimum, rangeMaximum] = range;
673
- const availableSize = Math.max(0, rangeMaximum - rangeMinimum);
674
- const step = domain.length === 0 ? 0 : availableSize / Math.max(1, domain.length + padding * (domain.length - 1));
675
- const bandWidth = Math.max(0, step * (1 - padding));
676
- domain.forEach((value, index) => positions.set(value, rangeMinimum + step * index));
677
- const scale = Object.assign((value) => positions.get(value), {
678
- bandwidth: () => bandWidth
679
- });
680
- return scale;
681
- }
682
- function createNumericDomain(values) {
683
- if (values.length === 0)
684
- return [0, 1];
685
- let minimum = Number(values[0].comparable);
686
- let maximum = minimum;
687
- for (let index = 1;index < values.length; index++) {
688
- const numeric = Number(values[index].comparable);
689
- if (numeric < minimum)
690
- minimum = numeric;
691
- if (numeric > maximum)
692
- maximum = numeric;
1319
+ if (safeTickCount === 1) {
1320
+ const value = sortedXValues[0];
1321
+ return value ? [{ label: formatXValue(value, xAxis, { index: 0 }), x: scaleX(value) }] : [];
693
1322
  }
694
- return minimum === maximum ? [minimum - 1, maximum + 1] : [minimum, maximum];
695
- }
696
- function createTicks(domain, count) {
697
- const safeCount = Math.max(1, Math.floor(count));
698
- if (safeCount === 1)
699
- return [domain[0]];
700
- const step = (domain[1] - domain[0]) / (safeCount - 1);
701
- return Array.from({ length: safeCount }, (_, index) => domain[0] + step * index);
702
- }
703
- function createLinePath(points) {
704
- if (points.length === 0)
705
- return "";
706
- const [firstPoint, ...remainingPoints] = points;
707
- return [
708
- `M${formatPathNumber(firstPoint?.x ?? 0)},${formatPathNumber(firstPoint?.y ?? 0)}`,
709
- ...remainingPoints.map((point) => `L${formatPathNumber(point.x)},${formatPathNumber(point.y)}`)
710
- ].join("");
711
- }
712
- function createAreaPath(points, baseline) {
713
- if (points.length === 0)
714
- return "";
715
- const firstPoint = points[0];
716
- const lastPoint = points.at(-1);
717
- if (!firstPoint || !lastPoint)
718
- return "";
719
- const lowerPoints = points.toReversed().map((point) => `L${formatPathNumber(point.x)},${formatPathNumber(point.y0 ?? baseline ?? 0)}`);
720
- return [
721
- `M${formatPathNumber(firstPoint.x)},${formatPathNumber(firstPoint.y0 ?? baseline ?? 0)}`,
722
- `L${formatPathNumber(firstPoint.x)},${formatPathNumber(firstPoint.y)}`,
723
- ...points.slice(1).map((point) => `L${formatPathNumber(point.x)},${formatPathNumber(point.y)}`),
724
- ...lowerPoints,
725
- "Z"
726
- ].join("");
727
- }
728
- function createStackedBarDomainValues(datumByKey, categories, series) {
729
- const values = [0];
730
- for (const category of categories) {
731
- const datum = datumByKey.get(category.key);
732
- if (!datum)
1323
+ const step = (sortedXValues.length - 1) / (safeTickCount - 1);
1324
+ const ticks = [];
1325
+ for (let i = 0;i < safeTickCount; i++) {
1326
+ const sourceIndex = Math.round(i * step);
1327
+ const value = sortedXValues[sourceIndex];
1328
+ if (!value)
733
1329
  continue;
734
- let positiveTotal = 0;
735
- let negativeTotal = 0;
736
- for (const item of series) {
737
- const value = datum[item.valueKey];
738
- if (typeof value !== "number")
739
- continue;
740
- if (value >= 0)
741
- positiveTotal += value;
742
- else
743
- negativeTotal += value;
744
- }
745
- values.push(positiveTotal, negativeTotal);
1330
+ ticks.push({
1331
+ label: formatXValue(value, xAxis, { index: sourceIndex }),
1332
+ x: scaleX(value)
1333
+ });
746
1334
  }
747
- return values;
748
- }
749
- function formatPathNumber(value) {
750
- return Number(value.toFixed(3)).toString();
1335
+ return ticks;
751
1336
  }
752
-
753
1337
  // src/_internal/chart/chart-focus-ring.ts
754
1338
  var DEFAULT_CHART_FOCUS_RING_STROKE_PADDING = 8;
755
1339
  var DEFAULT_POINT_FOCUS_RING_RADIUS = 10;
@@ -922,13 +1506,20 @@ class ChartInteraction {
922
1506
  this.focusedTarget = undefined;
923
1507
  return;
924
1508
  }
925
- if (!this.#includesTarget(this.pointerTarget, targets))
926
- this.pointerTarget = undefined;
927
- if (!this.#includesTarget(this.focusedTarget, targets))
928
- this.focusedTarget = undefined;
929
- }
930
- #includesTarget(candidate, targets) {
931
- return Boolean(candidate && targets.some((target) => target.id === candidate.id));
1509
+ const refreshedPointerTarget = this.#refreshTarget(this.pointerTarget, targets);
1510
+ const refreshedFocusedTarget = this.#refreshTarget(this.focusedTarget, targets);
1511
+ if (refreshedPointerTarget !== this.pointerTarget)
1512
+ this.pointerTarget = refreshedPointerTarget;
1513
+ if (refreshedFocusedTarget !== this.focusedTarget)
1514
+ this.focusedTarget = refreshedFocusedTarget;
1515
+ }
1516
+ #refreshTarget(candidate, targets) {
1517
+ if (!candidate)
1518
+ return;
1519
+ const latest = targets.find((target) => target.id === candidate.id);
1520
+ if (!latest)
1521
+ return;
1522
+ return chartTargetsEqual(candidate, latest) ? candidate : latest;
932
1523
  }
933
1524
  activateByPointer(event, targets) {
934
1525
  if (!(event.currentTarget instanceof SVGRectElement))
@@ -975,6 +1566,9 @@ class ChartInteraction {
975
1566
  return toggleSeriesId(hiddenSeriesIds, seriesId);
976
1567
  }
977
1568
  }
1569
+ function chartTargetsEqual(left, right) {
1570
+ return left.id === right.id && left.seriesId === right.seriesId && left.seriesLabel === right.seriesLabel && left.xLabel === right.xLabel && left.valueLabel === right.valueLabel && left.x === right.x && left.y === right.y && left.width === right.width && left.height === right.height && left.color === right.color;
1571
+ }
978
1572
 
979
1573
  // src/components/_internal/chart-data-table.svelte
980
1574
  import"svelte/internal/disclose-version";
@@ -1850,6 +2444,104 @@ function Chart_data_table($$anchor, $$props) {
1850
2444
  $9.pop();
1851
2445
  }
1852
2446
 
2447
+ // src/components/_internal/chart-tooltip.svelte
2448
+ import"svelte/internal/disclose-version";
2449
+ import * as $10 from "svelte/internal/client";
2450
+ import Popover from "@lostgradient/cinder/popover";
2451
+ var root7 = $10.from_html(`<strong> </strong> <span> </span>`, 1);
2452
+ var root_14 = $10.from_html(`<div role="tooltip" class="cinder-chart-tooltip"><!></div>`);
2453
+ var root_23 = $10.from_html(`<span class="cinder-chart-tooltip-anchor" aria-hidden="true"></span> <!>`, 1);
2454
+ function Chart_tooltip($$anchor, $$props) {
2455
+ $10.push($$props, true);
2456
+ let anchorElement = $10.state(null);
2457
+ const outsideClickIgnoreRefs = [() => $10.get(anchorElement)?.ownerDocument.body ?? null];
2458
+ const customContent = $10.derived(() => typeof $$props.content === "function" ? $$props.content : undefined);
2459
+ const open = $10.derived(() => Boolean($10.get(anchorElement) && $$props.target && $$props.content));
2460
+ var fragment = root_23();
2461
+ var span = $10.first_child(fragment);
2462
+ let styles;
2463
+ $10.bind_this(span, ($$value) => $10.set(anchorElement, $$value), () => $10.get(anchorElement));
2464
+ var node = $10.sibling(span, 2);
2465
+ {
2466
+ const children = ($$anchor2) => {
2467
+ var fragment_1 = $10.comment();
2468
+ var node_1 = $10.first_child(fragment_1);
2469
+ {
2470
+ var consequent_1 = ($$anchor3) => {
2471
+ var div = root_14();
2472
+ var node_2 = $10.child(div);
2473
+ {
2474
+ var consequent = ($$anchor4) => {
2475
+ var fragment_2 = $10.comment();
2476
+ var node_3 = $10.first_child(fragment_2);
2477
+ $10.snippet(node_3, () => $10.get(customContent), () => $$props.target);
2478
+ $10.append($$anchor4, fragment_2);
2479
+ };
2480
+ var alternate = ($$anchor4) => {
2481
+ var fragment_3 = root7();
2482
+ var strong = $10.first_child(fragment_3);
2483
+ var text2 = $10.child(strong, true);
2484
+ $10.reset(strong);
2485
+ var span_1 = $10.sibling(strong, 2);
2486
+ var text_1 = $10.child(span_1);
2487
+ $10.reset(span_1);
2488
+ $10.template_effect(() => {
2489
+ $10.set_text(text2, $$props.target.seriesLabel);
2490
+ $10.set_text(text_1, `${$$props.target.xLabel ?? ""}: ${$$props.target.valueLabel ?? ""}`);
2491
+ });
2492
+ $10.append($$anchor4, fragment_3);
2493
+ };
2494
+ $10.if(node_2, ($$render) => {
2495
+ if ($10.get(customContent))
2496
+ $$render(consequent);
2497
+ else
2498
+ $$render(alternate, -1);
2499
+ });
2500
+ }
2501
+ $10.reset(div);
2502
+ $10.template_effect(() => $10.set_attribute(div, "id", $$props.id));
2503
+ $10.append($$anchor3, div);
2504
+ };
2505
+ $10.if(node_1, ($$render) => {
2506
+ if ($$props.target)
2507
+ $$render(consequent_1);
2508
+ });
2509
+ }
2510
+ $10.append($$anchor2, fragment_1);
2511
+ };
2512
+ let $0 = $10.derived(() => `${$$props.id}-popover`);
2513
+ Popover(node, {
2514
+ get id() {
2515
+ return $10.get($0);
2516
+ },
2517
+ get open() {
2518
+ return $10.get(open);
2519
+ },
2520
+ get triggerRef() {
2521
+ return $10.get(anchorElement);
2522
+ },
2523
+ placement: "right",
2524
+ arrowVisible: true,
2525
+ role: "group",
2526
+ focusManagement: "preserve",
2527
+ get outsideClickIgnoreRefs() {
2528
+ return outsideClickIgnoreRefs;
2529
+ },
2530
+ wireTriggerAria: false,
2531
+ closeOnEscape: false,
2532
+ widthMode: "content",
2533
+ children,
2534
+ $$slots: { default: true }
2535
+ });
2536
+ }
2537
+ $10.template_effect(() => styles = $10.set_style(span, "", styles, {
2538
+ left: `${$$props.geometry.marginLeft + ($$props.target?.x ?? 0)}px`,
2539
+ top: `${$$props.geometry.marginTop + ($$props.target?.y ?? 0)}px`
2540
+ }));
2541
+ $10.append($$anchor, fragment);
2542
+ $10.pop();
2543
+ }
2544
+
1853
2545
  // src/components/line-chart/line-chart.svelte
1854
2546
  var rest_excludes7 = new Set([
1855
2547
  "$$slots",
@@ -1867,572 +2559,682 @@ var rest_excludes7 = new Set([
1867
2559
  "dataTableCaption",
1868
2560
  "dataTableVisibility",
1869
2561
  "maximumInteractivePoints",
2562
+ "theme",
2563
+ "tooltip",
2564
+ "mark",
1870
2565
  "class",
1871
2566
  "empty",
1872
2567
  "loadingContent",
1873
2568
  "id"
1874
2569
  ]);
1875
- var root7 = $10.from_html(`<p class="cinder-line-chart__description"> </p>`);
1876
- var root_14 = $10.from_html(`<button type="button"><span></span> </button>`);
1877
- var root_23 = $10.from_html(`<div class="cinder-line-chart__legend" aria-label="Series"></div>`);
1878
- var root_32 = $10.from_html(`<div class="cinder-line-chart__state"><!></div>`);
1879
- var root_4 = $10.from_svg(`<line class="cinder-line-chart__gridline" x1="0" aria-hidden="true"></line><text class="cinder-line-chart__tick-label" x="-8" text-anchor="end" dominant-baseline="middle"> </text>`, 1);
1880
- var root_5 = $10.from_svg(`<text class="cinder-line-chart__tick-label" text-anchor="middle"> </text>`);
1881
- var root_6 = $10.from_svg(`<circle class="cinder-line-chart__point" r="3" aria-hidden="true"></circle>`);
1882
- var root_7 = $10.from_svg(`<path class="cinder-line-chart__line" aria-hidden="true"></path><!>`, 1);
1883
- var root_8 = $10.from_svg(`<line class="cinder-line-chart__crosshair" y1="0" aria-hidden="true"></line>`);
1884
- var root_9 = $10.from_svg(`<circle class="cinder-line-chart__focus-target" r="8" tabindex="0" role="button"></circle>`);
1885
- var root_10 = $10.from_svg(`<rect class="cinder-line-chart__hit-surface" role="presentation"></rect><!>`, 1);
1886
- var root_11 = $10.from_svg(`<path class="cinder-line-chart__focus-ring-connector cinder-line-chart__focus-ring-halo"></path><path class="cinder-line-chart__focus-ring-connector cinder-line-chart__focus-ring"></path><circle class="cinder-line-chart__focus-ring-dot cinder-line-chart__focus-ring-halo"></circle><circle class="cinder-line-chart__focus-ring-dot cinder-line-chart__focus-ring"></circle>`, 1);
1887
- var root_122 = $10.from_svg(`<circle class="cinder-line-chart__focus-ring-halo"></circle><circle class="cinder-line-chart__focus-ring"></circle><!>`, 1);
1888
- var root_132 = $10.from_svg(`<rect class="cinder-line-chart__focus-ring-halo"></rect><rect class="cinder-line-chart__focus-ring"></rect>`, 1);
1889
- var root_142 = $10.from_svg(`<g class="cinder-line-chart__focus-ring-layer" aria-hidden="true"><!></g>`);
1890
- var root_15 = $10.from_svg(`<title> </title><g><!><!><!><!><!><!></g>`, 1);
1891
- var root_16 = $10.from_html(`<div role="tooltip" class="cinder-line-chart__tooltip"><strong> </strong> <span> </span></div>`);
1892
- var root_17 = $10.from_html(`<p class="cinder-sr-only">Use the data table to inspect this chart with a keyboard.</p>`);
1893
- var root_18 = $10.from_html(`<figure><!> <!> <div class="cinder-line-chart__viewport"><!> <svg><!></svg> <!></div> <!> <!> <!></figure>`);
2570
+ var root8 = $11.from_html(`<p class="cinder-line-chart__description"> </p>`);
2571
+ var root_15 = $11.from_html(`<button type="button"><span></span> </button>`);
2572
+ var root_24 = $11.from_html(`<div class="cinder-line-chart__legend" aria-label="Series"></div>`);
2573
+ var root_32 = $11.from_html(`<div class="cinder-line-chart__state"><!></div>`);
2574
+ var root_4 = $11.from_svg(`<line class="cinder-line-chart__gridline" x1="0" aria-hidden="true"></line><text class="cinder-line-chart__tick-label" x="-8" text-anchor="end" dominant-baseline="middle"> </text>`, 1);
2575
+ var root_5 = $11.from_svg(`<text class="cinder-line-chart__axis-title" text-anchor="middle" transform="rotate(-90)"> </text>`);
2576
+ var root_6 = $11.from_svg(`<text class="cinder-line-chart__tick-label" text-anchor="middle"> </text>`);
2577
+ var root_7 = $11.from_svg(`<text class="cinder-line-chart__axis-title" text-anchor="middle"> </text>`);
2578
+ var root_8 = $11.from_svg(`<circle class="cinder-line-chart__point" r="3" aria-hidden="true"></circle>`);
2579
+ var root_9 = $11.from_svg(`<path class="cinder-line-chart__line" aria-hidden="true"></path><!>`, 1);
2580
+ var root_10 = $11.from_svg(`<line class="cinder-line-chart__crosshair" y1="0" aria-hidden="true"></line>`);
2581
+ var root_11 = $11.from_svg(`<circle class="cinder-line-chart__focus-target" r="8" tabindex="0" role="button"></circle>`);
2582
+ var root_122 = $11.from_svg(`<rect class="cinder-line-chart__hit-surface" role="presentation"></rect><!>`, 1);
2583
+ var root_132 = $11.from_svg(`<path class="cinder-line-chart__focus-ring-connector cinder-line-chart__focus-ring-halo"></path><path class="cinder-line-chart__focus-ring-connector cinder-line-chart__focus-ring"></path><circle class="cinder-line-chart__focus-ring-dot cinder-line-chart__focus-ring-halo"></circle><circle class="cinder-line-chart__focus-ring-dot cinder-line-chart__focus-ring"></circle>`, 1);
2584
+ var root_142 = $11.from_svg(`<circle class="cinder-line-chart__focus-ring-halo"></circle><circle class="cinder-line-chart__focus-ring"></circle><!>`, 1);
2585
+ var root_152 = $11.from_svg(`<rect class="cinder-line-chart__focus-ring-halo"></rect><rect class="cinder-line-chart__focus-ring"></rect>`, 1);
2586
+ var root_16 = $11.from_svg(`<g class="cinder-line-chart__focus-ring-layer" aria-hidden="true"><!></g>`);
2587
+ var root_17 = $11.from_svg(`<title> </title><g><!><!><!><!><!><!><!><!></g>`, 1);
2588
+ var root_18 = $11.from_html(`<p class="cinder-sr-only">Use the data table to inspect this chart with a keyboard.</p>`);
2589
+ var root_19 = $11.from_html(`<figure><!> <!> <div class="cinder-line-chart__viewport"><!> <svg><!></svg> <!></div> <!> <!> <!></figure>`);
1894
2590
  function Line_chart($$anchor, $$props) {
1895
- const generatedId = $10.props_id();
1896
- $10.push($$props, true);
1897
- let height = $10.prop($$props, "height", 3, 280), legendPosition = $10.prop($$props, "legendPosition", 3, "top"), hiddenSeriesIds = $10.prop($$props, "hiddenSeriesIds", 31, () => $10.proxy([])), loading = $10.prop($$props, "loading", 3, false), dataTableVisibility = $10.prop($$props, "dataTableVisibility", 3, "screen-reader-only"), maximumInteractivePoints = $10.prop($$props, "maximumInteractivePoints", 3, 500), rest = $10.rest_props($$props, rest_excludes7);
1898
- const rootId = $10.derived(() => $$props.id ?? generatedId);
1899
- const descriptionId = $10.derived(() => $$props.description ? `${$10.get(rootId)}-description` : undefined);
2591
+ const generatedId = $11.props_id();
2592
+ $11.push($$props, true);
2593
+ let height = $11.prop($$props, "height", 3, 280), legendPosition = $11.prop($$props, "legendPosition", 3, "top"), hiddenSeriesIds = $11.prop($$props, "hiddenSeriesIds", 31, () => $11.proxy([])), loading = $11.prop($$props, "loading", 3, false), dataTableVisibility = $11.prop($$props, "dataTableVisibility", 3, "screen-reader-only"), maximumInteractivePoints = $11.prop($$props, "maximumInteractivePoints", 3, 500), tooltip = $11.prop($$props, "tooltip", 3, false), rest = $11.rest_props($$props, rest_excludes7);
2594
+ const rootId = $11.derived(() => $$props.id ?? generatedId);
2595
+ const descriptionId = $11.derived(() => $$props.description ? `${$11.get(rootId)}-description` : undefined);
1900
2596
  const interaction = new ChartInteraction;
1901
- let rootElement = $10.state(undefined);
1902
- $10.user_effect(() => {
1903
- if (!$10.get(rootElement))
2597
+ let rootElement = $11.state(undefined);
2598
+ let measureText = $11.state(false);
2599
+ let measurementVersion = $11.state(0);
2600
+ onMount(() => {
2601
+ $11.set(measureText, true);
2602
+ return observeChartFontLoading(() => {
2603
+ $11.set(measurementVersion, $11.get(measurementVersion) + 1);
2604
+ });
2605
+ });
2606
+ $11.user_effect(() => {
2607
+ if (!$11.get(rootElement))
1904
2608
  return;
1905
- return interaction.observeResize($10.get(rootElement));
2609
+ return interaction.observeResize($11.get(rootElement));
1906
2610
  });
1907
- const model = $10.derived(() => createCartesianModel({
2611
+ const model = $11.derived(() => createCartesianModel({
1908
2612
  componentId: "line-chart",
1909
2613
  series: $$props.series,
1910
2614
  hiddenSeriesIds: hiddenSeriesIds(),
1911
2615
  width: interaction.measuredWidth,
1912
2616
  height: height(),
1913
2617
  xAxis: $$props.xAxis,
1914
- yAxis: $$props.yAxis
2618
+ yAxis: $$props.yAxis,
2619
+ theme: $$props.theme,
2620
+ measureText: $11.get(measureText),
2621
+ measurementElement: $11.get(rootElement),
2622
+ measurementVersion: $11.get(measurementVersion)
1915
2623
  }));
1916
- const keyboardEnabled = $10.derived(() => $10.get(model).targets.length > 0 && $10.get(model).targets.length <= maximumInteractivePoints());
1917
- const hasDataTable = $10.derived(() => dataTableVisibility() !== "hidden");
1918
- const guidanceId = $10.derived(() => !$10.get(keyboardEnabled) && $10.get(hasDataTable) && $10.get(model).targets.length > 0 ? `${$10.get(rootId)}-table-guidance` : undefined);
1919
- const focusedTarget = $10.derived(() => {
2624
+ const keyboardEnabled = $11.derived(() => $11.get(model).targets.length > 0 && $11.get(model).targets.length <= maximumInteractivePoints());
2625
+ const hasDataTable = $11.derived(() => dataTableVisibility() !== "hidden");
2626
+ const guidanceId = $11.derived(() => !$11.get(keyboardEnabled) && $11.get(hasDataTable) && $11.get(model).targets.length > 0 ? `${$11.get(rootId)}-table-guidance` : undefined);
2627
+ const focusedTarget = $11.derived(() => {
1920
2628
  const currentTarget = interaction.focusedTarget;
1921
2629
  if (!currentTarget)
1922
2630
  return;
1923
- return $10.get(model).targets.find((target) => target.id === currentTarget.id);
2631
+ return $11.get(model).targets.find((target) => target.id === currentTarget.id);
1924
2632
  });
1925
- let keyboardFocusModality = $10.state(false);
1926
- let focusVisibleTargetId = $10.state(undefined);
1927
- const focusRingTarget = $10.derived(() => $10.get(keyboardFocusModality) && $10.get(focusedTarget) && $10.get(focusVisibleTargetId) === $10.get(focusedTarget).id ? $10.get(focusedTarget) : undefined);
1928
- const pointFocusRing = $10.derived(() => $10.get(focusRingTarget) ? createPointFocusRingGeometry({
1929
- target: $10.get(focusRingTarget),
1930
- plotWidth: $10.get(model).geometry.plotWidth,
1931
- plotHeight: $10.get(model).geometry.plotHeight,
2633
+ let keyboardFocusModality = $11.state(false);
2634
+ let focusVisibleTargetId = $11.state(undefined);
2635
+ const focusRingTarget = $11.derived(() => $11.get(keyboardFocusModality) && $11.get(focusedTarget) && $11.get(focusVisibleTargetId) === $11.get(focusedTarget).id ? $11.get(focusedTarget) : undefined);
2636
+ const pointFocusRing = $11.derived(() => $11.get(focusRingTarget) ? createPointFocusRingGeometry({
2637
+ target: $11.get(focusRingTarget),
2638
+ plotWidth: $11.get(model).geometry.plotWidth,
2639
+ plotHeight: $11.get(model).geometry.plotHeight,
1932
2640
  strokePadding: DEFAULT_CHART_FOCUS_RING_STROKE_PADDING
1933
2641
  }) : null);
1934
- $10.user_effect(() => {
2642
+ $11.user_effect(() => {
1935
2643
  assertValidNonNegativeInteger("line-chart", "invalid-maximum-interactive-points", maximumInteractivePoints(), "maximumInteractivePoints");
1936
2644
  });
1937
- $10.user_effect(() => {
1938
- interaction.clearStaleTargets(loading(), $10.get(model).empty, $10.get(model).targets);
2645
+ $11.user_effect(() => {
2646
+ interaction.clearStaleTargets(loading(), $11.get(model).empty, $11.get(model).targets);
1939
2647
  });
1940
2648
  function rememberKeyboardFocusModality(event2) {
1941
2649
  if (event2.key === "Tab" || event2.key === "Home" || event2.key === "End" || event2.key.startsWith("Arrow")) {
1942
- $10.set(keyboardFocusModality, true);
2650
+ $11.set(keyboardFocusModality, true);
1943
2651
  }
1944
2652
  }
1945
2653
  function clearKeyboardFocusModality() {
1946
- $10.set(keyboardFocusModality, false);
1947
- $10.set(focusVisibleTargetId, undefined);
2654
+ $11.set(keyboardFocusModality, false);
2655
+ $11.set(focusVisibleTargetId, undefined);
1948
2656
  }
1949
2657
  function handleTargetFocus(target) {
1950
2658
  interaction.focusedTarget = target;
1951
- $10.set(focusVisibleTargetId, $10.get(keyboardFocusModality) ? target.id : undefined, true);
2659
+ $11.set(focusVisibleTargetId, $11.get(keyboardFocusModality) ? target.id : undefined, true);
1952
2660
  }
1953
2661
  function handleTargetBlur() {
1954
2662
  interaction.focusedTarget = undefined;
1955
- $10.set(focusVisibleTargetId, undefined);
2663
+ $11.set(focusVisibleTargetId, undefined);
1956
2664
  }
1957
2665
  function handleTargetKeydown(event2) {
1958
2666
  rememberKeyboardFocusModality(event2);
1959
- interaction.activateByKeyboard(event2, $10.get(rootElement), $10.get(model).targets, $10.get(keyboardEnabled));
2667
+ interaction.activateByKeyboard(event2, $11.get(rootElement), $11.get(model).targets, $11.get(keyboardEnabled));
1960
2668
  }
1961
- var figure = root_18();
1962
- $10.event("keydown", $10.window, rememberKeyboardFocusModality);
1963
- $10.event("pointerdown", $10.window, clearKeyboardFocusModality);
1964
- $10.attribute_effect(figure, ($0) => ({
2669
+ var figure = root_19();
2670
+ $11.event("keydown", $11.window, rememberKeyboardFocusModality);
2671
+ $11.event("pointerdown", $11.window, clearKeyboardFocusModality);
2672
+ $11.attribute_effect(figure, ($0) => ({
1965
2673
  ...rest,
1966
- id: $10.get(rootId),
2674
+ id: $11.get(rootId),
1967
2675
  class: $0,
1968
2676
  "aria-label": $$props.label,
1969
- "aria-describedby": $10.get(descriptionId)
2677
+ "aria-describedby": $11.get(descriptionId),
2678
+ [$11.STYLE]: {
2679
+ "--_cinder-chart-foreground": $11.get(model).theme.foreground,
2680
+ "--_cinder-chart-muted": $11.get(model).theme.muted,
2681
+ "--_cinder-chart-grid": $11.get(model).theme.grid,
2682
+ "--_cinder-chart-background": $11.get(model).theme.background
2683
+ }
1970
2684
  }), [() => classNames("cinder-line-chart", $$props.class)]);
1971
- var node = $10.child(figure);
2685
+ var node = $11.child(figure);
1972
2686
  {
1973
2687
  var consequent = ($$anchor2) => {
1974
- var p = root7();
1975
- var text3 = $10.child(p, true);
1976
- $10.reset(p);
1977
- $10.template_effect(() => {
1978
- $10.set_attribute(p, "id", $10.get(descriptionId));
1979
- $10.set_text(text3, $$props.description);
2688
+ var p = root8();
2689
+ var text3 = $11.child(p, true);
2690
+ $11.reset(p);
2691
+ $11.template_effect(() => {
2692
+ $11.set_attribute(p, "id", $11.get(descriptionId));
2693
+ $11.set_text(text3, $$props.description);
1980
2694
  });
1981
- $10.append($$anchor2, p);
2695
+ $11.append($$anchor2, p);
1982
2696
  };
1983
- $10.if(node, ($$render) => {
2697
+ $11.if(node, ($$render) => {
1984
2698
  if ($$props.description)
1985
2699
  $$render(consequent);
1986
2700
  });
1987
2701
  }
1988
- var node_1 = $10.sibling(node, 2);
2702
+ var node_1 = $11.sibling(node, 2);
1989
2703
  {
1990
2704
  var consequent_1 = ($$anchor2) => {
1991
- var div = root_23();
1992
- $10.each(div, 23, () => $$props.series, (item) => item.id, ($$anchor3, item, index2) => {
1993
- var button = root_14();
1994
- var span = $10.child(button);
2705
+ var div = root_24();
2706
+ $11.each(div, 23, () => $$props.series, (item) => item.id, ($$anchor3, item, index2) => {
2707
+ var button = root_15();
2708
+ var span = $11.child(button);
1995
2709
  let styles;
1996
- var text_1 = $10.sibling(span, 1, true);
1997
- $10.reset(button);
1998
- $10.template_effect(($0, $1) => {
1999
- $10.set_attribute(button, "aria-pressed", $0);
2000
- styles = $10.set_style(span, "", styles, $1);
2001
- $10.set_text(text_1, $10.get(item).label);
2710
+ var text_1 = $11.sibling(span, 1, true);
2711
+ $11.reset(button);
2712
+ $11.template_effect(($0, $1) => {
2713
+ $11.set_attribute(button, "aria-pressed", $0);
2714
+ styles = $11.set_style(span, "", styles, $1);
2715
+ $11.set_text(text_1, $11.get(item).label);
2002
2716
  }, [
2003
- () => !hiddenSeriesIds().includes($10.get(item).id),
2717
+ () => !hiddenSeriesIds().includes($11.get(item).id),
2004
2718
  () => ({
2005
- background: $10.get(item).color ?? chartPaletteColor($10.get(index2))
2719
+ background: $11.get(item).color ?? chartPaletteColor($11.get(index2), $11.get(model).theme.palette)
2006
2720
  })
2007
2721
  ]);
2008
- $10.delegated("click", button, () => hiddenSeriesIds(interaction.toggleSeries(hiddenSeriesIds(), $10.get(item).id)));
2009
- $10.append($$anchor3, button);
2722
+ $11.delegated("click", button, () => hiddenSeriesIds(interaction.toggleSeries(hiddenSeriesIds(), $11.get(item).id)));
2723
+ $11.append($$anchor3, button);
2010
2724
  });
2011
- $10.reset(div);
2012
- $10.append($$anchor2, div);
2725
+ $11.reset(div);
2726
+ $11.append($$anchor2, div);
2013
2727
  };
2014
- var d = $10.derived(() => legendVisible(legendPosition(), $$props.series.length) && legendPosition() === "top");
2015
- $10.if(node_1, ($$render) => {
2016
- if ($10.get(d))
2728
+ var d = $11.derived(() => legendVisible(legendPosition(), $$props.series.length) && legendPosition() === "top");
2729
+ $11.if(node_1, ($$render) => {
2730
+ if ($11.get(d))
2017
2731
  $$render(consequent_1);
2018
2732
  });
2019
2733
  }
2020
- var div_1 = $10.sibling(node_1, 2);
2734
+ var div_1 = $11.sibling(node_1, 2);
2021
2735
  let styles_1;
2022
- var node_2 = $10.child(div_1);
2736
+ var node_2 = $11.child(div_1);
2023
2737
  {
2024
2738
  var consequent_3 = ($$anchor2) => {
2025
2739
  var div_2 = root_32();
2026
- var node_3 = $10.child(div_2);
2740
+ var node_3 = $11.child(div_2);
2027
2741
  {
2028
2742
  var consequent_2 = ($$anchor3) => {
2029
- var fragment = $10.comment();
2030
- var node_4 = $10.first_child(fragment);
2031
- $10.snippet(node_4, () => $$props.loadingContent);
2032
- $10.append($$anchor3, fragment);
2743
+ var fragment = $11.comment();
2744
+ var node_4 = $11.first_child(fragment);
2745
+ $11.snippet(node_4, () => $$props.loadingContent);
2746
+ $11.append($$anchor3, fragment);
2033
2747
  };
2034
2748
  var alternate = ($$anchor3) => {
2035
- var text_2 = $10.text("Loading chart…");
2036
- $10.append($$anchor3, text_2);
2749
+ var text_2 = $11.text("Loading chart…");
2750
+ $11.append($$anchor3, text_2);
2037
2751
  };
2038
- $10.if(node_3, ($$render) => {
2752
+ $11.if(node_3, ($$render) => {
2039
2753
  if ($$props.loadingContent)
2040
2754
  $$render(consequent_2);
2041
2755
  else
2042
2756
  $$render(alternate, -1);
2043
2757
  });
2044
2758
  }
2045
- $10.reset(div_2);
2046
- $10.append($$anchor2, div_2);
2759
+ $11.reset(div_2);
2760
+ $11.append($$anchor2, div_2);
2047
2761
  };
2048
2762
  var consequent_5 = ($$anchor2) => {
2049
2763
  var div_3 = root_32();
2050
- var node_5 = $10.child(div_3);
2764
+ var node_5 = $11.child(div_3);
2051
2765
  {
2052
2766
  var consequent_4 = ($$anchor3) => {
2053
- var fragment_1 = $10.comment();
2054
- var node_6 = $10.first_child(fragment_1);
2055
- $10.snippet(node_6, () => $$props.empty);
2056
- $10.append($$anchor3, fragment_1);
2767
+ var fragment_1 = $11.comment();
2768
+ var node_6 = $11.first_child(fragment_1);
2769
+ $11.snippet(node_6, () => $$props.empty);
2770
+ $11.append($$anchor3, fragment_1);
2057
2771
  };
2058
2772
  var alternate_1 = ($$anchor3) => {
2059
- var text_3 = $10.text("No chart data");
2060
- $10.append($$anchor3, text_3);
2773
+ var text_3 = $11.text("No chart data");
2774
+ $11.append($$anchor3, text_3);
2061
2775
  };
2062
- $10.if(node_5, ($$render) => {
2776
+ $11.if(node_5, ($$render) => {
2063
2777
  if ($$props.empty)
2064
2778
  $$render(consequent_4);
2065
2779
  else
2066
2780
  $$render(alternate_1, -1);
2067
2781
  });
2068
2782
  }
2069
- $10.reset(div_3);
2070
- $10.append($$anchor2, div_3);
2783
+ $11.reset(div_3);
2784
+ $11.append($$anchor2, div_3);
2071
2785
  };
2072
- $10.if(node_2, ($$render) => {
2786
+ $11.if(node_2, ($$render) => {
2073
2787
  if (loading())
2074
2788
  $$render(consequent_3);
2075
- else if ($10.get(model).empty)
2789
+ else if ($11.get(model).empty)
2076
2790
  $$render(consequent_5, 1);
2077
2791
  });
2078
2792
  }
2079
- var svg = $10.sibling(node_2, 2);
2080
- var node_7 = $10.child(svg);
2793
+ var svg = $11.sibling(node_2, 2);
2794
+ var node_7 = $11.child(svg);
2081
2795
  {
2082
- var consequent_14 = ($$anchor2) => {
2083
- var fragment_2 = root_15();
2084
- var title = $10.first_child(fragment_2);
2085
- var text_4 = $10.child(title, true);
2086
- $10.reset(title);
2087
- var g = $10.sibling(title);
2088
- var node_8 = $10.child(g);
2089
- $10.each(node_8, 18, () => $10.get(model).yTicks, (tick) => tick, ($$anchor3, tick, index2) => {
2090
- const tickY = $10.derived(() => $10.get(model).geometry.plotHeight - (tick - $10.get(model).yDomain[0]) / ($10.get(model).yDomain[1] - $10.get(model).yDomain[0]) * $10.get(model).geometry.plotHeight);
2796
+ var consequent_19 = ($$anchor2) => {
2797
+ var fragment_2 = root_17();
2798
+ var title = $11.first_child(fragment_2);
2799
+ var text_4 = $11.child(title, true);
2800
+ $11.reset(title);
2801
+ var g = $11.sibling(title);
2802
+ var node_8 = $11.child(g);
2803
+ $11.each(node_8, 18, () => $11.get(model).yTicks, (tick) => tick, ($$anchor3, tick, index2) => {
2804
+ const tickY = $11.derived(() => $11.get(model).geometry.plotHeight - (tick - $11.get(model).yDomain[0]) / ($11.get(model).yDomain[1] - $11.get(model).yDomain[0]) * $11.get(model).geometry.plotHeight);
2091
2805
  var fragment_3 = root_4();
2092
- var line = $10.first_child(fragment_3);
2093
- var text_5 = $10.sibling(line);
2094
- var text_6 = $10.child(text_5, true);
2095
- $10.reset(text_5);
2096
- $10.template_effect(($0) => {
2097
- $10.set_attribute(line, "x2", $10.get(model).geometry.plotWidth);
2098
- $10.set_attribute(line, "y1", $10.get(tickY));
2099
- $10.set_attribute(line, "y2", $10.get(tickY));
2100
- $10.set_attribute(text_5, "y", $10.get(tickY));
2101
- $10.set_text(text_6, $0);
2806
+ var line = $11.first_child(fragment_3);
2807
+ var text_5 = $11.sibling(line);
2808
+ var text_6 = $11.child(text_5, true);
2809
+ $11.reset(text_5);
2810
+ $11.template_effect(($0) => {
2811
+ $11.set_attribute(line, "x2", $11.get(model).geometry.plotWidth);
2812
+ $11.set_attribute(line, "y1", $11.get(tickY));
2813
+ $11.set_attribute(line, "y2", $11.get(tickY));
2814
+ $11.set_attribute(text_5, "y", $11.get(tickY));
2815
+ $11.set_text(text_6, $0);
2102
2816
  }, [
2103
- () => formatNumericValue(tick, $$props.yAxis, undefined, { index: $10.get(index2) })
2817
+ () => formatNumericValue(tick, $$props.yAxis, undefined, { index: $11.get(index2) })
2104
2818
  ]);
2105
- $10.append($$anchor3, fragment_3);
2819
+ $11.append($$anchor3, fragment_3);
2106
2820
  });
2107
- var node_9 = $10.sibling(node_8);
2108
- $10.each(node_9, 17, () => $10.get(model).xTicks, (tick) => tick.label, ($$anchor3, tick) => {
2109
- var text_7 = root_5();
2110
- var text_8 = $10.child(text_7, true);
2111
- $10.reset(text_7);
2112
- $10.template_effect(() => {
2113
- $10.set_attribute(text_7, "x", $10.get(tick).x);
2114
- $10.set_attribute(text_7, "y", $10.get(model).geometry.plotHeight + 20);
2115
- $10.set_text(text_8, $10.get(tick).label);
2821
+ var node_9 = $11.sibling(node_8);
2822
+ {
2823
+ var consequent_6 = ($$anchor3) => {
2824
+ var text_7 = root_5();
2825
+ var text_8 = $11.child(text_7, true);
2826
+ $11.reset(text_7);
2827
+ $11.template_effect(() => {
2828
+ $11.set_attribute(text_7, "x", -$11.get(model).geometry.plotHeight / 2);
2829
+ $11.set_attribute(text_7, "y", -$11.get(model).geometry.marginLeft + 12);
2830
+ $11.set_text(text_8, $$props.yAxis.label);
2831
+ });
2832
+ $11.append($$anchor3, text_7);
2833
+ };
2834
+ $11.if(node_9, ($$render) => {
2835
+ if ($$props.yAxis?.label)
2836
+ $$render(consequent_6);
2837
+ });
2838
+ }
2839
+ var node_10 = $11.sibling(node_9);
2840
+ $11.each(node_10, 17, () => $11.get(model).xTicks, (tick) => tick.label, ($$anchor3, tick) => {
2841
+ var text_9 = root_6();
2842
+ var text_10 = $11.child(text_9, true);
2843
+ $11.reset(text_9);
2844
+ $11.template_effect(() => {
2845
+ $11.set_attribute(text_9, "x", $11.get(tick).x);
2846
+ $11.set_attribute(text_9, "y", $11.get(model).geometry.plotHeight + 20);
2847
+ $11.set_attribute(text_9, "transform", $$props.xAxis?.tickLabelRotation ? `rotate(${$$props.xAxis.tickLabelRotation} ${$11.get(tick).x} ${$11.get(model).geometry.plotHeight + 20})` : undefined);
2848
+ $11.set_text(text_10, $11.get(tick).label);
2116
2849
  });
2117
- $10.append($$anchor3, text_7);
2850
+ $11.append($$anchor3, text_9);
2118
2851
  });
2119
- var node_10 = $10.sibling(node_9);
2120
- $10.each(node_10, 17, () => $10.get(model).normalizedSeries, (item) => item.id, ($$anchor3, item) => {
2121
- var fragment_4 = $10.comment();
2122
- var node_11 = $10.first_child(fragment_4);
2123
- {
2124
- var consequent_7 = ($$anchor4) => {
2125
- var fragment_5 = root_7();
2126
- var path = $10.first_child(fragment_5);
2127
- var node_12 = $10.sibling(path);
2128
- $10.each(node_12, 17, () => $10.get(item).points, (point) => point.x.key, ($$anchor5, point) => {
2129
- var fragment_6 = $10.comment();
2130
- var node_13 = $10.first_child(fragment_6);
2131
- {
2132
- var consequent_6 = ($$anchor6) => {
2133
- var circle = root_6();
2134
- $10.template_effect(() => {
2135
- $10.set_attribute(circle, "cx", $10.get(point).pixelX);
2136
- $10.set_attribute(circle, "cy", $10.get(point).pixelY);
2137
- $10.set_attribute(circle, "fill", $10.get(item).color);
2138
- $10.set_attribute(circle, "data-cinder-series", $10.get(item).id);
2852
+ var node_11 = $11.sibling(node_10);
2853
+ {
2854
+ var consequent_7 = ($$anchor3) => {
2855
+ var text_11 = root_7();
2856
+ var text_12 = $11.child(text_11, true);
2857
+ $11.reset(text_11);
2858
+ $11.template_effect(() => {
2859
+ $11.set_attribute(text_11, "x", $11.get(model).geometry.plotWidth / 2);
2860
+ $11.set_attribute(text_11, "y", $11.get(model).geometry.plotHeight + $11.get(model).geometry.marginBottom - 4);
2861
+ $11.set_text(text_12, $$props.xAxis.label);
2862
+ });
2863
+ $11.append($$anchor3, text_11);
2864
+ };
2865
+ $11.if(node_11, ($$render) => {
2866
+ if ($$props.xAxis?.label)
2867
+ $$render(consequent_7);
2868
+ });
2869
+ }
2870
+ var node_12 = $11.sibling(node_11);
2871
+ {
2872
+ var consequent_10 = ($$anchor3) => {
2873
+ var fragment_4 = $11.comment();
2874
+ var node_13 = $11.first_child(fragment_4);
2875
+ $11.each(node_13, 17, () => $11.get(model).normalizedSeries, (item) => item.id, ($$anchor4, item) => {
2876
+ var fragment_5 = $11.comment();
2877
+ var node_14 = $11.first_child(fragment_5);
2878
+ {
2879
+ var consequent_9 = ($$anchor5) => {
2880
+ const sourceSeries = $11.derived(() => $$props.series.find((candidate) => candidate.id === $11.get(item).id));
2881
+ var fragment_6 = $11.comment();
2882
+ var node_15 = $11.first_child(fragment_6);
2883
+ {
2884
+ var consequent_8 = ($$anchor6) => {
2885
+ var fragment_7 = $11.comment();
2886
+ var node_16 = $11.first_child(fragment_7);
2887
+ $11.snippet(node_16, () => $$props.mark, () => ({
2888
+ series: $11.get(sourceSeries),
2889
+ points: $11.get(item).points,
2890
+ geometry: $11.get(model).geometry
2891
+ }));
2892
+ $11.append($$anchor6, fragment_7);
2893
+ };
2894
+ $11.if(node_15, ($$render) => {
2895
+ if ($11.get(sourceSeries))
2896
+ $$render(consequent_8);
2139
2897
  });
2140
- $10.append($$anchor6, circle);
2141
- };
2142
- $10.if(node_13, ($$render) => {
2143
- if ($10.get(point).y !== null)
2144
- $$render(consequent_6);
2898
+ }
2899
+ $11.append($$anchor5, fragment_6);
2900
+ };
2901
+ var d_1 = $11.derived(() => !hiddenSeriesIds().includes($11.get(item).id));
2902
+ $11.if(node_14, ($$render) => {
2903
+ if ($11.get(d_1))
2904
+ $$render(consequent_9);
2905
+ });
2906
+ }
2907
+ $11.append($$anchor4, fragment_5);
2908
+ });
2909
+ $11.append($$anchor3, fragment_4);
2910
+ };
2911
+ var alternate_2 = ($$anchor3) => {
2912
+ var fragment_8 = $11.comment();
2913
+ var node_17 = $11.first_child(fragment_8);
2914
+ $11.each(node_17, 17, () => $11.get(model).normalizedSeries, (item) => item.id, ($$anchor4, item) => {
2915
+ var fragment_9 = $11.comment();
2916
+ var node_18 = $11.first_child(fragment_9);
2917
+ {
2918
+ var consequent_12 = ($$anchor5) => {
2919
+ var fragment_10 = root_9();
2920
+ var path = $11.first_child(fragment_10);
2921
+ var node_19 = $11.sibling(path);
2922
+ $11.each(node_19, 17, () => $11.get(item).points, (point) => point.x.key, ($$anchor6, point) => {
2923
+ var fragment_11 = $11.comment();
2924
+ var node_20 = $11.first_child(fragment_11);
2925
+ {
2926
+ var consequent_11 = ($$anchor7) => {
2927
+ var circle = root_8();
2928
+ $11.template_effect(() => {
2929
+ $11.set_attribute(circle, "cx", $11.get(point).pixelX);
2930
+ $11.set_attribute(circle, "cy", $11.get(point).pixelY);
2931
+ $11.set_attribute(circle, "fill", $11.get(item).color);
2932
+ $11.set_attribute(circle, "data-cinder-series", $11.get(item).id);
2933
+ });
2934
+ $11.append($$anchor7, circle);
2935
+ };
2936
+ $11.if(node_20, ($$render) => {
2937
+ if ($11.get(point).y !== null)
2938
+ $$render(consequent_11);
2939
+ });
2940
+ }
2941
+ $11.append($$anchor6, fragment_11);
2145
2942
  });
2146
- }
2147
- $10.append($$anchor5, fragment_6);
2148
- });
2149
- $10.template_effect(() => {
2150
- $10.set_attribute(path, "d", $10.get(item).path);
2151
- $10.set_attribute(path, "stroke", $10.get(item).color);
2152
- $10.set_attribute(path, "data-cinder-series", $10.get(item).id);
2153
- });
2154
- $10.append($$anchor4, fragment_5);
2155
- };
2156
- $10.if(node_11, ($$render) => {
2157
- if (!$10.get(item).hidden && $10.get(item).path)
2158
- $$render(consequent_7);
2943
+ $11.template_effect(() => {
2944
+ $11.set_attribute(path, "d", $11.get(item).path);
2945
+ $11.set_attribute(path, "stroke", $11.get(item).color);
2946
+ $11.set_attribute(path, "data-cinder-series", $11.get(item).id);
2947
+ });
2948
+ $11.append($$anchor5, fragment_10);
2949
+ };
2950
+ var d_2 = $11.derived(() => !hiddenSeriesIds().includes($11.get(item).id) && $11.get(item).path);
2951
+ $11.if(node_18, ($$render) => {
2952
+ if ($11.get(d_2))
2953
+ $$render(consequent_12);
2954
+ });
2955
+ }
2956
+ $11.append($$anchor4, fragment_9);
2159
2957
  });
2160
- }
2161
- $10.append($$anchor3, fragment_4);
2162
- });
2163
- var node_14 = $10.sibling(node_10);
2958
+ $11.append($$anchor3, fragment_8);
2959
+ };
2960
+ $11.if(node_12, ($$render) => {
2961
+ if ($$props.mark)
2962
+ $$render(consequent_10);
2963
+ else
2964
+ $$render(alternate_2, -1);
2965
+ });
2966
+ }
2967
+ var node_21 = $11.sibling(node_12);
2164
2968
  {
2165
- var consequent_8 = ($$anchor3) => {
2166
- var line_1 = root_8();
2167
- $10.template_effect(() => {
2168
- $10.set_attribute(line_1, "x1", interaction.activeTarget.x);
2169
- $10.set_attribute(line_1, "x2", interaction.activeTarget.x);
2170
- $10.set_attribute(line_1, "y2", $10.get(model).geometry.plotHeight);
2969
+ var consequent_13 = ($$anchor3) => {
2970
+ var line_1 = root_10();
2971
+ $11.template_effect(() => {
2972
+ $11.set_attribute(line_1, "x1", interaction.activeTarget.x);
2973
+ $11.set_attribute(line_1, "x2", interaction.activeTarget.x);
2974
+ $11.set_attribute(line_1, "y2", $11.get(model).geometry.plotHeight);
2171
2975
  });
2172
- $10.append($$anchor3, line_1);
2976
+ $11.append($$anchor3, line_1);
2173
2977
  };
2174
- $10.if(node_14, ($$render) => {
2978
+ $11.if(node_21, ($$render) => {
2175
2979
  if (interaction.activeTarget)
2176
- $$render(consequent_8);
2980
+ $$render(consequent_13);
2177
2981
  });
2178
2982
  }
2179
- var node_15 = $10.sibling(node_14);
2983
+ var node_22 = $11.sibling(node_21);
2180
2984
  {
2181
- var consequent_10 = ($$anchor3) => {
2182
- var fragment_7 = root_10();
2183
- var rect = $10.first_child(fragment_7);
2184
- var node_16 = $10.sibling(rect);
2985
+ var consequent_15 = ($$anchor3) => {
2986
+ var fragment_12 = root_122();
2987
+ var rect = $11.first_child(fragment_12);
2988
+ var node_23 = $11.sibling(rect);
2185
2989
  {
2186
- var consequent_9 = ($$anchor4) => {
2187
- var fragment_8 = $10.comment();
2188
- var node_17 = $10.first_child(fragment_8);
2189
- $10.each(node_17, 17, () => $10.get(model).targets, (target) => target.id, ($$anchor5, target) => {
2190
- var circle_1 = root_9();
2191
- $10.template_effect(() => {
2192
- $10.set_attribute(circle_1, "cx", $10.get(target).x);
2193
- $10.set_attribute(circle_1, "cy", $10.get(target).y);
2194
- $10.set_attribute(circle_1, "data-cinder-target-id", $10.get(target).id);
2195
- $10.set_attribute(circle_1, "data-cinder-series-id", $10.get(target).seriesId);
2196
- $10.set_attribute(circle_1, "data-cinder-focus-ring-active", $10.get(pointFocusRing) && $10.get(focusRingTarget)?.id === $10.get(target).id ? "true" : undefined);
2197
- $10.set_attribute(circle_1, "aria-label", `${$10.get(target).seriesLabel}, ${$10.get(target).xLabel}, ${$10.get(target).valueLabel}`);
2198
- $10.set_attribute(circle_1, "aria-describedby", interaction.activeTarget?.id === $10.get(target).id ? `${$10.get(rootId)}-tooltip` : undefined);
2990
+ var consequent_14 = ($$anchor4) => {
2991
+ var fragment_13 = $11.comment();
2992
+ var node_24 = $11.first_child(fragment_13);
2993
+ $11.each(node_24, 17, () => $11.get(model).targets, (target) => target.id, ($$anchor5, target) => {
2994
+ var circle_1 = root_11();
2995
+ $11.template_effect(() => {
2996
+ $11.set_attribute(circle_1, "cx", $11.get(target).x);
2997
+ $11.set_attribute(circle_1, "cy", $11.get(target).y);
2998
+ $11.set_attribute(circle_1, "data-cinder-target-id", $11.get(target).id);
2999
+ $11.set_attribute(circle_1, "data-cinder-series-id", $11.get(target).seriesId);
3000
+ $11.set_attribute(circle_1, "data-cinder-focus-ring-active", $11.get(pointFocusRing) && $11.get(focusRingTarget)?.id === $11.get(target).id ? "true" : undefined);
3001
+ $11.set_attribute(circle_1, "aria-label", `${$11.get(target).seriesLabel}, ${$11.get(target).xLabel}, ${$11.get(target).valueLabel}`);
3002
+ $11.set_attribute(circle_1, "aria-describedby", tooltip() && interaction.activeTarget?.id === $11.get(target).id ? `${$11.get(rootId)}-tooltip` : undefined);
2199
3003
  });
2200
- $10.event("focus", circle_1, () => handleTargetFocus($10.get(target)));
2201
- $10.event("blur", circle_1, handleTargetBlur);
2202
- $10.delegated("keydown", circle_1, handleTargetKeydown);
2203
- $10.append($$anchor5, circle_1);
3004
+ $11.event("focus", circle_1, () => handleTargetFocus($11.get(target)));
3005
+ $11.event("blur", circle_1, handleTargetBlur);
3006
+ $11.delegated("keydown", circle_1, handleTargetKeydown);
3007
+ $11.append($$anchor5, circle_1);
2204
3008
  });
2205
- $10.append($$anchor4, fragment_8);
3009
+ $11.append($$anchor4, fragment_13);
2206
3010
  };
2207
- $10.if(node_16, ($$render) => {
2208
- if ($10.get(keyboardEnabled))
2209
- $$render(consequent_9);
3011
+ $11.if(node_23, ($$render) => {
3012
+ if ($11.get(keyboardEnabled))
3013
+ $$render(consequent_14);
2210
3014
  });
2211
3015
  }
2212
- $10.template_effect(() => {
2213
- $10.set_attribute(rect, "width", $10.get(model).geometry.plotWidth);
2214
- $10.set_attribute(rect, "height", $10.get(model).geometry.plotHeight);
3016
+ $11.template_effect(() => {
3017
+ $11.set_attribute(rect, "width", $11.get(model).geometry.plotWidth);
3018
+ $11.set_attribute(rect, "height", $11.get(model).geometry.plotHeight);
2215
3019
  });
2216
- $10.delegated("pointermove", rect, (event2) => interaction.activateByPointer(event2, $10.get(model).targets));
2217
- $10.event("pointerleave", rect, () => interaction.clearPointerTarget());
2218
- $10.append($$anchor3, fragment_7);
3020
+ $11.delegated("pointermove", rect, (event2) => interaction.activateByPointer(event2, $11.get(model).targets));
3021
+ $11.event("pointerleave", rect, () => interaction.clearPointerTarget());
3022
+ $11.append($$anchor3, fragment_12);
2219
3023
  };
2220
- $10.if(node_15, ($$render) => {
2221
- if ($10.get(model).targets.length > 0)
2222
- $$render(consequent_10);
3024
+ $11.if(node_22, ($$render) => {
3025
+ if ($11.get(model).targets.length > 0)
3026
+ $$render(consequent_15);
2223
3027
  });
2224
3028
  }
2225
- var node_18 = $10.sibling(node_15);
3029
+ var node_25 = $11.sibling(node_22);
2226
3030
  {
2227
- var consequent_13 = ($$anchor3) => {
2228
- var g_1 = root_142();
2229
- var node_19 = $10.child(g_1);
3031
+ var consequent_18 = ($$anchor3) => {
3032
+ var g_1 = root_16();
3033
+ var node_26 = $11.child(g_1);
2230
3034
  {
2231
- var consequent_12 = ($$anchor4) => {
2232
- var fragment_9 = root_122();
2233
- var circle_2 = $10.first_child(fragment_9);
2234
- var circle_3 = $10.sibling(circle_2);
2235
- var node_20 = $10.sibling(circle_3);
3035
+ var consequent_17 = ($$anchor4) => {
3036
+ var fragment_14 = root_142();
3037
+ var circle_2 = $11.first_child(fragment_14);
3038
+ var circle_3 = $11.sibling(circle_2);
3039
+ var node_27 = $11.sibling(circle_3);
2236
3040
  {
2237
- var consequent_11 = ($$anchor5) => {
2238
- var fragment_10 = root_11();
2239
- var path_1 = $10.first_child(fragment_10);
2240
- var path_2 = $10.sibling(path_1);
2241
- var circle_4 = $10.sibling(path_2);
2242
- var circle_5 = $10.sibling(circle_4);
2243
- $10.template_effect(() => {
2244
- $10.set_attribute(path_1, "d", `M ${$10.get(pointFocusRing).connector.x1} ${$10.get(pointFocusRing).connector.y1} L ${$10.get(pointFocusRing).connector.x2} ${$10.get(pointFocusRing).connector.y2}`);
2245
- $10.set_attribute(path_2, "d", `M ${$10.get(pointFocusRing).connector.x1} ${$10.get(pointFocusRing).connector.y1} L ${$10.get(pointFocusRing).connector.x2} ${$10.get(pointFocusRing).connector.y2}`);
2246
- $10.set_attribute(circle_4, "cx", $10.get(pointFocusRing).dot.cx);
2247
- $10.set_attribute(circle_4, "cy", $10.get(pointFocusRing).dot.cy);
2248
- $10.set_attribute(circle_4, "r", $10.get(pointFocusRing).dot.radius);
2249
- $10.set_attribute(circle_5, "cx", $10.get(pointFocusRing).dot.cx);
2250
- $10.set_attribute(circle_5, "cy", $10.get(pointFocusRing).dot.cy);
2251
- $10.set_attribute(circle_5, "r", $10.get(pointFocusRing).dot.radius);
3041
+ var consequent_16 = ($$anchor5) => {
3042
+ var fragment_15 = root_132();
3043
+ var path_1 = $11.first_child(fragment_15);
3044
+ var path_2 = $11.sibling(path_1);
3045
+ var circle_4 = $11.sibling(path_2);
3046
+ var circle_5 = $11.sibling(circle_4);
3047
+ $11.template_effect(() => {
3048
+ $11.set_attribute(path_1, "d", `M ${$11.get(pointFocusRing).connector.x1} ${$11.get(pointFocusRing).connector.y1} L ${$11.get(pointFocusRing).connector.x2} ${$11.get(pointFocusRing).connector.y2}`);
3049
+ $11.set_attribute(path_2, "d", `M ${$11.get(pointFocusRing).connector.x1} ${$11.get(pointFocusRing).connector.y1} L ${$11.get(pointFocusRing).connector.x2} ${$11.get(pointFocusRing).connector.y2}`);
3050
+ $11.set_attribute(circle_4, "cx", $11.get(pointFocusRing).dot.cx);
3051
+ $11.set_attribute(circle_4, "cy", $11.get(pointFocusRing).dot.cy);
3052
+ $11.set_attribute(circle_4, "r", $11.get(pointFocusRing).dot.radius);
3053
+ $11.set_attribute(circle_5, "cx", $11.get(pointFocusRing).dot.cx);
3054
+ $11.set_attribute(circle_5, "cy", $11.get(pointFocusRing).dot.cy);
3055
+ $11.set_attribute(circle_5, "r", $11.get(pointFocusRing).dot.radius);
2252
3056
  });
2253
- $10.append($$anchor5, fragment_10);
3057
+ $11.append($$anchor5, fragment_15);
2254
3058
  };
2255
- $10.if(node_20, ($$render) => {
2256
- if ($10.get(pointFocusRing).connector && $10.get(pointFocusRing).dot)
2257
- $$render(consequent_11);
3059
+ $11.if(node_27, ($$render) => {
3060
+ if ($11.get(pointFocusRing).connector && $11.get(pointFocusRing).dot)
3061
+ $$render(consequent_16);
2258
3062
  });
2259
3063
  }
2260
- $10.template_effect(() => {
2261
- $10.set_attribute(circle_2, "cx", $10.get(pointFocusRing).cx);
2262
- $10.set_attribute(circle_2, "cy", $10.get(pointFocusRing).cy);
2263
- $10.set_attribute(circle_2, "r", $10.get(pointFocusRing).radius);
2264
- $10.set_attribute(circle_3, "cx", $10.get(pointFocusRing).cx);
2265
- $10.set_attribute(circle_3, "cy", $10.get(pointFocusRing).cy);
2266
- $10.set_attribute(circle_3, "r", $10.get(pointFocusRing).radius);
3064
+ $11.template_effect(() => {
3065
+ $11.set_attribute(circle_2, "cx", $11.get(pointFocusRing).cx);
3066
+ $11.set_attribute(circle_2, "cy", $11.get(pointFocusRing).cy);
3067
+ $11.set_attribute(circle_2, "r", $11.get(pointFocusRing).radius);
3068
+ $11.set_attribute(circle_3, "cx", $11.get(pointFocusRing).cx);
3069
+ $11.set_attribute(circle_3, "cy", $11.get(pointFocusRing).cy);
3070
+ $11.set_attribute(circle_3, "r", $11.get(pointFocusRing).radius);
2267
3071
  });
2268
- $10.append($$anchor4, fragment_9);
3072
+ $11.append($$anchor4, fragment_14);
2269
3073
  };
2270
- var alternate_2 = ($$anchor4) => {
2271
- var fragment_11 = root_132();
2272
- var rect_1 = $10.first_child(fragment_11);
2273
- var rect_2 = $10.sibling(rect_1);
2274
- $10.template_effect(() => {
2275
- $10.set_attribute(rect_1, "x", $10.get(pointFocusRing).x);
2276
- $10.set_attribute(rect_1, "y", $10.get(pointFocusRing).y);
2277
- $10.set_attribute(rect_1, "width", $10.get(pointFocusRing).width);
2278
- $10.set_attribute(rect_1, "height", $10.get(pointFocusRing).height);
2279
- $10.set_attribute(rect_1, "rx", $10.get(pointFocusRing).radius);
2280
- $10.set_attribute(rect_2, "x", $10.get(pointFocusRing).x);
2281
- $10.set_attribute(rect_2, "y", $10.get(pointFocusRing).y);
2282
- $10.set_attribute(rect_2, "width", $10.get(pointFocusRing).width);
2283
- $10.set_attribute(rect_2, "height", $10.get(pointFocusRing).height);
2284
- $10.set_attribute(rect_2, "rx", $10.get(pointFocusRing).radius);
3074
+ var alternate_3 = ($$anchor4) => {
3075
+ var fragment_16 = root_152();
3076
+ var rect_1 = $11.first_child(fragment_16);
3077
+ var rect_2 = $11.sibling(rect_1);
3078
+ $11.template_effect(() => {
3079
+ $11.set_attribute(rect_1, "x", $11.get(pointFocusRing).x);
3080
+ $11.set_attribute(rect_1, "y", $11.get(pointFocusRing).y);
3081
+ $11.set_attribute(rect_1, "width", $11.get(pointFocusRing).width);
3082
+ $11.set_attribute(rect_1, "height", $11.get(pointFocusRing).height);
3083
+ $11.set_attribute(rect_1, "rx", $11.get(pointFocusRing).radius);
3084
+ $11.set_attribute(rect_2, "x", $11.get(pointFocusRing).x);
3085
+ $11.set_attribute(rect_2, "y", $11.get(pointFocusRing).y);
3086
+ $11.set_attribute(rect_2, "width", $11.get(pointFocusRing).width);
3087
+ $11.set_attribute(rect_2, "height", $11.get(pointFocusRing).height);
3088
+ $11.set_attribute(rect_2, "rx", $11.get(pointFocusRing).radius);
2285
3089
  });
2286
- $10.append($$anchor4, fragment_11);
3090
+ $11.append($$anchor4, fragment_16);
2287
3091
  };
2288
- $10.if(node_19, ($$render) => {
2289
- if ($10.get(pointFocusRing).kind === "point")
2290
- $$render(consequent_12);
3092
+ $11.if(node_26, ($$render) => {
3093
+ if ($11.get(pointFocusRing).kind === "point")
3094
+ $$render(consequent_17);
2291
3095
  else
2292
- $$render(alternate_2, -1);
3096
+ $$render(alternate_3, -1);
2293
3097
  });
2294
3098
  }
2295
- $10.reset(g_1);
2296
- $10.append($$anchor3, g_1);
3099
+ $11.reset(g_1);
3100
+ $11.append($$anchor3, g_1);
2297
3101
  };
2298
- $10.if(node_18, ($$render) => {
2299
- if ($10.get(pointFocusRing))
2300
- $$render(consequent_13);
3102
+ $11.if(node_25, ($$render) => {
3103
+ if ($11.get(pointFocusRing))
3104
+ $$render(consequent_18);
2301
3105
  });
2302
3106
  }
2303
- $10.reset(g);
2304
- $10.template_effect(() => {
2305
- $10.set_attribute(title, "id", `${$10.get(rootId) ?? ""}-svg-title`);
2306
- $10.set_text(text_4, $$props.label);
2307
- $10.set_attribute(g, "transform", `translate(${$10.get(model).geometry.marginLeft}, ${$10.get(model).geometry.marginTop})`);
3107
+ $11.reset(g);
3108
+ $11.template_effect(() => {
3109
+ $11.set_attribute(title, "id", `${$11.get(rootId) ?? ""}-svg-title`);
3110
+ $11.set_text(text_4, $$props.label);
3111
+ $11.set_attribute(g, "transform", `translate(${$11.get(model).geometry.marginLeft}, ${$11.get(model).geometry.marginTop})`);
2308
3112
  });
2309
- $10.append($$anchor2, fragment_2);
3113
+ $11.append($$anchor2, fragment_2);
2310
3114
  };
2311
- $10.if(node_7, ($$render) => {
2312
- if (!loading() && !$10.get(model).empty)
2313
- $$render(consequent_14);
3115
+ $11.if(node_7, ($$render) => {
3116
+ if (!loading() && !$11.get(model).empty)
3117
+ $$render(consequent_19);
2314
3118
  });
2315
3119
  }
2316
- $10.reset(svg);
2317
- var node_21 = $10.sibling(svg, 2);
3120
+ $11.reset(svg);
3121
+ var node_28 = $11.sibling(svg, 2);
2318
3122
  {
2319
- var consequent_15 = ($$anchor2) => {
2320
- var div_4 = root_16();
2321
- let styles_2;
2322
- var strong = $10.child(div_4);
2323
- var text_9 = $10.child(strong, true);
2324
- $10.reset(strong);
2325
- var span_1 = $10.sibling(strong, 2);
2326
- var text_10 = $10.child(span_1);
2327
- $10.reset(span_1);
2328
- $10.reset(div_4);
2329
- $10.template_effect(() => {
2330
- $10.set_attribute(div_4, "id", `${$10.get(rootId) ?? ""}-tooltip`);
2331
- styles_2 = $10.set_style(div_4, "", styles_2, {
2332
- left: `${$10.get(model).geometry.marginLeft + interaction.activeTarget.x}px`,
2333
- top: `${$10.get(model).geometry.marginTop + interaction.activeTarget.y}px`
3123
+ var consequent_20 = ($$anchor2) => {
3124
+ {
3125
+ let $0 = $11.derived(() => `${$11.get(rootId)}-tooltip`);
3126
+ Chart_tooltip($$anchor2, {
3127
+ get id() {
3128
+ return $11.get($0);
3129
+ },
3130
+ get target() {
3131
+ return interaction.activeTarget;
3132
+ },
3133
+ get geometry() {
3134
+ return $11.get(model).geometry;
3135
+ },
3136
+ get content() {
3137
+ return tooltip();
3138
+ }
2334
3139
  });
2335
- $10.set_text(text_9, interaction.activeTarget.seriesLabel);
2336
- $10.set_text(text_10, `${interaction.activeTarget.xLabel ?? ""}: ${interaction.activeTarget.valueLabel ?? ""}`);
2337
- });
2338
- $10.append($$anchor2, div_4);
3140
+ }
2339
3141
  };
2340
- $10.if(node_21, ($$render) => {
2341
- if (interaction.activeTarget)
2342
- $$render(consequent_15);
3142
+ $11.if(node_28, ($$render) => {
3143
+ if (tooltip())
3144
+ $$render(consequent_20);
2343
3145
  });
2344
3146
  }
2345
- $10.reset(div_1);
2346
- var node_22 = $10.sibling(div_1, 2);
3147
+ $11.reset(div_1);
3148
+ var node_29 = $11.sibling(div_1, 2);
2347
3149
  {
2348
- var consequent_16 = ($$anchor2) => {
2349
- var p_1 = root_17();
2350
- $10.template_effect(() => $10.set_attribute(p_1, "id", $10.get(guidanceId)));
2351
- $10.append($$anchor2, p_1);
3150
+ var consequent_21 = ($$anchor2) => {
3151
+ var p_1 = root_18();
3152
+ $11.template_effect(() => $11.set_attribute(p_1, "id", $11.get(guidanceId)));
3153
+ $11.append($$anchor2, p_1);
2352
3154
  };
2353
- $10.if(node_22, ($$render) => {
2354
- if ($10.get(guidanceId))
2355
- $$render(consequent_16);
3155
+ $11.if(node_29, ($$render) => {
3156
+ if ($11.get(guidanceId))
3157
+ $$render(consequent_21);
2356
3158
  });
2357
3159
  }
2358
- var node_23 = $10.sibling(node_22, 2);
3160
+ var node_30 = $11.sibling(node_29, 2);
2359
3161
  {
2360
- var consequent_17 = ($$anchor2) => {
3162
+ var consequent_22 = ($$anchor2) => {
2361
3163
  {
2362
- let $0 = $10.derived(() => $$props.dataTableCaption ?? $$props.label);
2363
- let $1 = $10.derived(() => $10.get(model).tableRows.map((row) => ({
3164
+ let $0 = $11.derived(() => formatDataTableCaption($$props.dataTableCaption ?? $$props.label, $11.get(model).tableRows.length, $11.get(model).targets.length));
3165
+ let $1 = $11.derived(() => $11.get(model).tableRows.map((row) => ({
2364
3166
  id: row.id,
2365
3167
  header: row.seriesLabel,
2366
3168
  cells: [row.xLabel, row.valueLabel]
2367
3169
  })));
2368
- let $22 = $10.derived(() => dataTableClass(dataTableVisibility()));
3170
+ let $22 = $11.derived(() => dataTableClass(dataTableVisibility()));
2369
3171
  Chart_data_table($$anchor2, {
2370
3172
  get caption() {
2371
- return $10.get($0);
3173
+ return $11.get($0);
2372
3174
  },
2373
3175
  headers: ["Series", "X", "Value"],
2374
3176
  get rows() {
2375
- return $10.get($1);
3177
+ return $11.get($1);
2376
3178
  },
2377
3179
  get visibilityClass() {
2378
- return $10.get($22);
3180
+ return $11.get($22);
2379
3181
  },
2380
3182
  get describedBy() {
2381
- return $10.get(guidanceId);
3183
+ return $11.get(guidanceId);
2382
3184
  }
2383
3185
  });
2384
3186
  }
2385
3187
  };
2386
- $10.if(node_23, ($$render) => {
2387
- if ($10.get(hasDataTable))
2388
- $$render(consequent_17);
3188
+ $11.if(node_30, ($$render) => {
3189
+ if ($11.get(hasDataTable))
3190
+ $$render(consequent_22);
2389
3191
  });
2390
3192
  }
2391
- var node_24 = $10.sibling(node_23, 2);
3193
+ var node_31 = $11.sibling(node_30, 2);
2392
3194
  {
2393
- var consequent_18 = ($$anchor2) => {
2394
- var div_5 = root_23();
2395
- $10.each(div_5, 23, () => $$props.series, (item) => item.id, ($$anchor3, item, index2) => {
2396
- var button_1 = root_14();
2397
- var span_2 = $10.child(button_1);
2398
- let styles_3;
2399
- var text_11 = $10.sibling(span_2, 1, true);
2400
- $10.reset(button_1);
2401
- $10.template_effect(($0, $1) => {
2402
- $10.set_attribute(button_1, "aria-pressed", $0);
2403
- styles_3 = $10.set_style(span_2, "", styles_3, $1);
2404
- $10.set_text(text_11, $10.get(item).label);
3195
+ var consequent_23 = ($$anchor2) => {
3196
+ var div_4 = root_24();
3197
+ $11.each(div_4, 23, () => $$props.series, (item) => item.id, ($$anchor3, item, index2) => {
3198
+ var button_1 = root_15();
3199
+ var span_1 = $11.child(button_1);
3200
+ let styles_2;
3201
+ var text_13 = $11.sibling(span_1, 1, true);
3202
+ $11.reset(button_1);
3203
+ $11.template_effect(($0, $1) => {
3204
+ $11.set_attribute(button_1, "aria-pressed", $0);
3205
+ styles_2 = $11.set_style(span_1, "", styles_2, $1);
3206
+ $11.set_text(text_13, $11.get(item).label);
2405
3207
  }, [
2406
- () => !hiddenSeriesIds().includes($10.get(item).id),
3208
+ () => !hiddenSeriesIds().includes($11.get(item).id),
2407
3209
  () => ({
2408
- background: $10.get(item).color ?? chartPaletteColor($10.get(index2))
3210
+ background: $11.get(item).color ?? chartPaletteColor($11.get(index2), $11.get(model).theme.palette)
2409
3211
  })
2410
3212
  ]);
2411
- $10.delegated("click", button_1, () => hiddenSeriesIds(interaction.toggleSeries(hiddenSeriesIds(), $10.get(item).id)));
2412
- $10.append($$anchor3, button_1);
3213
+ $11.delegated("click", button_1, () => hiddenSeriesIds(interaction.toggleSeries(hiddenSeriesIds(), $11.get(item).id)));
3214
+ $11.append($$anchor3, button_1);
2413
3215
  });
2414
- $10.reset(div_5);
2415
- $10.append($$anchor2, div_5);
3216
+ $11.reset(div_4);
3217
+ $11.append($$anchor2, div_4);
2416
3218
  };
2417
- var d_1 = $10.derived(() => legendVisible(legendPosition(), $$props.series.length) && legendPosition() === "bottom");
2418
- $10.if(node_24, ($$render) => {
2419
- if ($10.get(d_1))
2420
- $$render(consequent_18);
3219
+ var d_3 = $11.derived(() => legendVisible(legendPosition(), $$props.series.length) && legendPosition() === "bottom");
3220
+ $11.if(node_31, ($$render) => {
3221
+ if ($11.get(d_3))
3222
+ $$render(consequent_23);
2421
3223
  });
2422
3224
  }
2423
- $10.reset(figure);
2424
- $10.bind_this(figure, ($$value) => $10.set(rootElement, $$value), () => $10.get(rootElement));
2425
- $10.template_effect(() => {
2426
- $10.set_attribute(div_1, "data-cinder-loading", loading() || undefined);
2427
- styles_1 = $10.set_style(div_1, "", styles_1, { height: `${height() ?? ""}px` });
2428
- $10.set_attribute(svg, "viewBox", `0 0 ${interaction.measuredWidth} ${height()}`);
2429
- $10.set_attribute(svg, "aria-hidden", loading() || $10.get(model).empty ? "true" : undefined);
2430
- $10.set_attribute(svg, "aria-labelledby", !loading() && !$10.get(model).empty ? `${$10.get(rootId)}-svg-title` : undefined);
3225
+ $11.reset(figure);
3226
+ $11.bind_this(figure, ($$value) => $11.set(rootElement, $$value), () => $11.get(rootElement));
3227
+ $11.template_effect(() => {
3228
+ $11.set_attribute(div_1, "data-cinder-loading", loading() || undefined);
3229
+ styles_1 = $11.set_style(div_1, "", styles_1, { height: `${height() ?? ""}px` });
3230
+ $11.set_attribute(svg, "viewBox", `0 0 ${interaction.measuredWidth} ${height()}`);
3231
+ $11.set_attribute(svg, "aria-hidden", loading() || $11.get(model).empty ? "true" : undefined);
3232
+ $11.set_attribute(svg, "aria-labelledby", !loading() && !$11.get(model).empty ? `${$11.get(rootId)}-svg-title` : undefined);
2431
3233
  });
2432
- $10.append($$anchor, figure);
2433
- $10.pop();
3234
+ $11.append($$anchor, figure);
3235
+ $11.pop();
2434
3236
  }
2435
- $10.delegate(["click", "pointermove", "keydown"]);
3237
+ $11.delegate(["click", "pointermove", "keydown"]);
2436
3238
 
2437
3239
  // src/components/line-chart/index.ts
2438
3240
  var line_chart_default = Line_chart;
@@ -2441,4 +3243,4 @@ export {
2441
3243
  Line_chart as LineChart
2442
3244
  };
2443
3245
 
2444
- //# debugId=08679215651B6A3764756E2164756E21
3246
+ //# debugId=D99ED1C7DB25D03864756E2164756E21