@sybilion/uilib 1.8.0 → 1.8.2

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 (50) hide show
  1. package/dist/esm/src/components/ui/Chart/Chart.js +4 -1
  2. package/dist/esm/src/components/ui/Chart/components/BaseChartWrapper.js +30 -8
  3. package/dist/esm/src/components/ui/Chart/components/ChartAxes.js +12 -11
  4. package/dist/esm/src/components/ui/Chart/components/ChartPlacedTooltip.js +65 -0
  5. package/dist/esm/src/components/ui/Chart/components/ChartTooltipContent.js +2 -2
  6. package/dist/esm/src/components/ui/Chart/components/ChartTooltipItem.js +22 -6
  7. package/dist/esm/src/components/ui/Chart/components/QuantileBands.js +1 -1
  8. package/dist/esm/src/components/ui/ChartAreaInteractive/ChartLines.js +14 -8
  9. package/dist/esm/src/components/ui/StackedAreaChart/StackedAreaChart.tooltip.js +2 -3
  10. package/dist/esm/src/components/ui/TimeRangeControls/TimeRangeControls.js +18 -4
  11. package/dist/esm/src/components/widgets/DriverCard/DriverPerformanceChart.js +5 -25
  12. package/dist/esm/src/index.js +1 -0
  13. package/dist/esm/types/src/components/ui/Chart/Chart.d.ts +4 -2
  14. package/dist/esm/types/src/components/ui/Chart/Chart.types.d.ts +5 -0
  15. package/dist/esm/types/src/components/ui/Chart/chartForecastVisualization.types.d.ts +7 -0
  16. package/dist/esm/types/src/components/ui/Chart/components/BaseChartWrapper.d.ts +17 -0
  17. package/dist/esm/types/src/components/ui/Chart/components/BaseChartWrapper.test.d.ts +1 -0
  18. package/dist/esm/types/src/components/ui/Chart/components/ChartAxes.d.ts +8 -1
  19. package/dist/esm/types/src/components/ui/Chart/components/ChartAxes.test.d.ts +1 -0
  20. package/dist/esm/types/src/components/ui/Chart/components/ChartPlacedTooltip.d.ts +31 -0
  21. package/dist/esm/types/src/components/ui/Chart/components/ChartPlacedTooltip.test.d.ts +1 -0
  22. package/dist/esm/types/src/components/ui/Chart/components/ChartTooltipContent.d.ts +1 -1
  23. package/dist/esm/types/src/components/ui/Chart/components/ChartTooltipContent.test.d.ts +1 -0
  24. package/dist/esm/types/src/components/ui/Chart/components/ChartTooltipItem.d.ts +2 -1
  25. package/dist/esm/types/src/components/ui/ChartAreaInteractive/ChartLines.d.ts +12 -1
  26. package/dist/esm/types/src/components/ui/StackedAreaChart/StackedAreaChart.tooltip.d.ts +2 -3
  27. package/dist/esm/types/src/components/ui/TimeRangeControls/TimeRangeControls.d.ts +9 -3
  28. package/dist/esm/types/src/components/ui/TimeRangeControls/TimeRangeControls.test.d.ts +1 -0
  29. package/package.json +2 -2
  30. package/src/components/ui/Chart/AGENT.md +5 -0
  31. package/src/components/ui/Chart/Chart.tsx +7 -1
  32. package/src/components/ui/Chart/Chart.types.ts +5 -0
  33. package/src/components/ui/Chart/chartForecastVisualization.types.ts +7 -0
  34. package/src/components/ui/Chart/components/BaseChartWrapper.test.tsx +344 -0
  35. package/src/components/ui/Chart/components/BaseChartWrapper.tsx +78 -36
  36. package/src/components/ui/Chart/components/ChartAxes.test.tsx +60 -0
  37. package/src/components/ui/Chart/components/ChartAxes.tsx +42 -45
  38. package/src/components/ui/Chart/components/ChartPlacedTooltip.test.tsx +160 -0
  39. package/src/components/ui/Chart/components/ChartPlacedTooltip.tsx +93 -0
  40. package/src/components/ui/Chart/components/ChartTooltipContent.test.tsx +85 -0
  41. package/src/components/ui/Chart/components/ChartTooltipContent.tsx +2 -0
  42. package/src/components/ui/Chart/components/ChartTooltipItem.tsx +41 -10
  43. package/src/components/ui/Chart/components/QuantileBands.tsx +1 -1
  44. package/src/components/ui/ChartAreaInteractive/AGENT.md +2 -0
  45. package/src/components/ui/ChartAreaInteractive/ChartLines.tsx +75 -45
  46. package/src/components/ui/StackedAreaChart/StackedAreaChart.tooltip.tsx +2 -3
  47. package/src/components/ui/TimeRangeControls/AGENT.md +1 -1
  48. package/src/components/ui/TimeRangeControls/TimeRangeControls.test.tsx +40 -0
  49. package/src/components/ui/TimeRangeControls/TimeRangeControls.tsx +46 -35
  50. package/src/components/widgets/DriverCard/DriverPerformanceChart.tsx +2 -2
@@ -1,2 +1,2 @@
1
1
  import { ChartTooltipContentProps } from '#uilib/components/ui/Chart/Chart.types';
2
- export declare function ChartTooltipContent({ active, className, indicator, hideLabel, hideIndicator, label, labelFormatter, labelClassName, payload, formatter, color, nameKey, labelKey, }: ChartTooltipContentProps): import("react/jsx-runtime").JSX.Element;
2
+ export declare function ChartTooltipContent({ active, className, indicator, hideLabel, hideIndicator, label, labelFormatter, labelClassName, payload, formatter, valueFormatter, color, nameKey, labelKey, }: ChartTooltipContentProps): import("react/jsx-runtime").JSX.Element;
@@ -12,6 +12,7 @@ type ChartTooltipItemProps = {
12
12
  color?: string;
13
13
  nameKey?: string;
14
14
  formatter?: (value: unknown, name: string, props: unknown, index: number, payload: unknown) => ReactNode;
15
+ valueFormatter?: (value: number) => string;
15
16
  };
16
- export declare function ChartTooltipItem({ item, index, config, indicator, hideIndicator, nestLabel, tooltipLabel, color, nameKey, formatter, }: ChartTooltipItemProps): import("react/jsx-runtime").JSX.Element;
17
+ export declare function ChartTooltipItem({ item, index, config, indicator, hideIndicator, nestLabel, tooltipLabel, color, nameKey, formatter, valueFormatter, }: ChartTooltipItemProps): import("react/jsx-runtime").JSX.Element;
17
18
  export {};
@@ -50,7 +50,7 @@ export declare function getHistoryColor(index: number): string;
50
50
  export declare function resolveHistoryLines(histories?: HistoryItemData[]): HistoryLine[];
51
51
  /** Same tint logic as intervals/threshold overlays: band fill follows forecast line hex when known. */
52
52
  export declare function resolveQuantileBandFillForForecastLine(lineColor: string, forecastIndex: number): string;
53
- export declare const ChartLines: import("react").MemoExoticComponent<({ chartData, forecastData, historyData, hiddenSeries, isDarkTheme, shouldAnimate, historicalLineColor, showLegend, forecastLineStyle, disableAnimation, disableHistoricalAnimation, }: {
53
+ export declare const ChartLines: import("react").MemoExoticComponent<({ chartData, forecastData, historyData, hiddenSeries, isDarkTheme, shouldAnimate, historicalLineColor, showLegend, forecastLineStyle, disableAnimation, disableHistoricalAnimation, connectHistoryNulls, connectForecastNulls, historyOnTop, showEndDots, }: {
54
54
  chartData: ChartDataPoint[];
55
55
  forecastData?: ForecastItemData[];
56
56
  /** Several history lines (one per product). Omit for the single `historical` line. */
@@ -63,4 +63,15 @@ export declare const ChartLines: import("react").MemoExoticComponent<({ chartDat
63
63
  forecastLineStyle?: "dashed" | "solid";
64
64
  disableAnimation?: boolean;
65
65
  disableHistoricalAnimation?: boolean;
66
+ /** Draw each history line across months it has no value for. */
67
+ connectHistoryNulls?: boolean;
68
+ /** Draw each forecast line across months it has no value for. */
69
+ connectForecastNulls?: boolean;
70
+ /**
71
+ * Draw the history lines after the forecast lines, over them (for many
72
+ * faint forecasts that would otherwise cover the history).
73
+ */
74
+ historyOnTop?: boolean;
75
+ /** Mark each line's last point with a dot (default: on). */
76
+ showEndDots?: boolean;
66
77
  }) => import("react/jsx-runtime").JSX.Element>;
@@ -6,9 +6,8 @@ export type TooltipRow = {
6
6
  color?: string;
7
7
  };
8
8
  /**
9
- * Tooltip rows in series order, showing real zeros (ChartTooltipContent hides
10
- * them) and colouring each row from the chart config (an area's own colour
11
- * is its white stack stroke).
9
+ * Tooltip rows in series order, showing real zeros, and colouring each row
10
+ * from the chart config (an area's own colour is its white stack stroke).
12
11
  */
13
12
  export declare function StackedTooltip({ active, payload, label, config, valueFormatter, labelFormatter, }: {
14
13
  active?: boolean;
@@ -3,7 +3,13 @@ export type TimeRangeControlsProps = {
3
3
  onTimeRangeChange: (range: string) => void;
4
4
  loading?: boolean;
5
5
  };
6
+ /**
7
+ * The preset ranges as a select. A range that is not a preset (one dragged on
8
+ * the chart) shows "Custom" rather than a preset it is not.
9
+ */
10
+ export declare const TimeRangeSelect: import("react").MemoExoticComponent<({ timeRange, onTimeRangeChange, loading }: TimeRangeControlsProps) => import("react/jsx-runtime").JSX.Element>;
11
+ /**
12
+ * The preset ranges as a toggle row from 768px up, and as a select below it
13
+ * (CSS shows one of the two), so the control stays on a phone.
14
+ */
6
15
  export declare const TimeRangeControls: import("react").MemoExoticComponent<({ timeRange, onTimeRangeChange, loading }: TimeRangeControlsProps) => import("react/jsx-runtime").JSX.Element>;
7
- export declare const TimeRangeSelect: import("react").MemoExoticComponent<({ timeRange, onTimeRangeChange, loading, }: TimeRangeControlsProps & {
8
- loading: boolean;
9
- }) => import("react/jsx-runtime").JSX.Element>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sybilion/uilib",
3
- "version": "1.8.0",
3
+ "version": "1.8.2",
4
4
  "description": "Sybilion Design System — React UI components (Vite + Stylus)",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -137,7 +137,7 @@
137
137
  "lightweight-charts": "^5.0.9",
138
138
  "lucide-react": "^0.546.0",
139
139
  "motion": "^12.23.12",
140
- "recharts": "^3.2.1",
140
+ "recharts": "^3.7.0",
141
141
  "style-inject": "^0.3.0",
142
142
  "topojson-client": "^3.1.0",
143
143
  "vaul": "^1.1.2",
@@ -12,6 +12,11 @@ ChartContainer wraps Recharts charts with the library’s theming, mapping a Cha
12
12
  ## Do
13
13
 
14
14
  - Define every series in the ChartConfig so labels and colours stay consistent across tooltips and legends.
15
+ - With BaseChartWrapper or ChartAreaInteractive, pass `formatTooltipValue` so tooltip numbers match the axis format, and `connectHistoryNulls` / `connectForecastNulls` (or a band's `connectNulls: false`) to choose whether a line or range bridges a month with no value.
16
+ - `historyOnTop` draws the history lines over the forecast lines, for many faint forecasts that would otherwise cover them.
17
+ - `showAxes={false}` draws no axes but keeps a hidden x-axis, so the tooltip still names the row's date; fixed `yMin`/`yMax` (with `autoScaleYAxis={false}`) still set the y range.
18
+ - `showEndDots={false}` drops the dot on each line's last point (for many lines drawn as one bundle).
19
+ - Use ChartTooltip (not Recharts' Tooltip directly) so a chart narrower than 500px (`NARROW_CHART_PX`) opens its tooltip under the chart instead of over the lines, starting right under the x-axis labels (over any legend below). BaseChartWrapper, ChartAreaInteractive, BarChart, DonutChart, StackedAreaChart and the driver card chart already do. A parent that hides overflow (a chat bubble, a card) can clip it there. Pass `position` to place it yourself.
15
20
 
16
21
  ## Example
17
22
 
@@ -6,9 +6,14 @@ import {
6
6
  } from './components/BaseChartWrapper';
7
7
  import { ChartContainer, ChartStyle } from './components/ChartContainer';
8
8
  import { ChartLegendContent } from './components/ChartLegendContent';
9
+ import {
10
+ ChartPlacedTooltip,
11
+ NARROW_CHART_PX,
12
+ } from './components/ChartPlacedTooltip';
9
13
  import { ChartTooltipContent } from './components/ChartTooltipContent';
10
14
 
11
- const ChartTooltip = RechartsPrimitive.Tooltip;
15
+ /** recharts' Tooltip, opening under any chart narrower than {@link NARROW_CHART_PX}. */
16
+ const ChartTooltip = ChartPlacedTooltip;
12
17
  const ChartLegend = RechartsPrimitive.Legend;
13
18
 
14
19
  export * from './Chart.types';
@@ -19,6 +24,7 @@ export {
19
24
  ChartContainer,
20
25
  ChartTooltip,
21
26
  ChartTooltipContent,
27
+ NARROW_CHART_PX,
22
28
  ChartLegend,
23
29
  ChartLegendContent,
24
30
  ChartStyle,
@@ -42,5 +42,10 @@ export type ChartTooltipContentProps = ComponentProps<'div'> & {
42
42
  index: number,
43
43
  payload: unknown,
44
44
  ) => ReactNode;
45
+ /**
46
+ * Formats each row's number (both ends of a range row). Without it the
47
+ * value prints as is.
48
+ */
49
+ valueFormatter?: (value: number) => string;
45
50
  color?: string;
46
51
  };
@@ -96,4 +96,11 @@ export interface QuantileBandConfig {
96
96
  | 'basis'
97
97
  | 'natural';
98
98
  fillPattern?: 'solid' | 'dots' | 'lines';
99
+ /**
100
+ * Fill across months with no range (default true). Read by the Recharts
101
+ * charts' bands (BaseChartWrapper, ChartAreaInteractive's default mode),
102
+ * not by LightweightForecastChart or the intervals and thresholds overlays,
103
+ * which build their own bands.
104
+ */
105
+ connectNulls?: boolean;
99
106
  }
@@ -0,0 +1,344 @@
1
+ import { act, fireEvent, render, waitFor } from '@testing-library/react';
2
+
3
+ import {
4
+ BaseChartWrapper,
5
+ type BaseChartWrapperProps,
6
+ } from './BaseChartWrapper';
7
+ import { NARROW_TOOLTIP_GAP_PX } from './ChartPlacedTooltip';
8
+
9
+ // BaseChartWrapper also moves the tooltip itself, a frame after recharts,
10
+ // keeping it inside the plot. A chart narrower than 500px must keep its
11
+ // tooltip under the chart instead (ChartPlacedTooltip), with no slide. Also:
12
+ // the tooltip's number format, and lines drawn across months with no value.
13
+
14
+ // jsdom lays nothing out, so ResponsiveContainer would measure 0×0 and draw
15
+ // no chart. Give every element the chart's size and report it on resize.
16
+ const H = 120;
17
+ let width = 300;
18
+
19
+ beforeAll(() => {
20
+ for (const [prop, get] of [
21
+ ['clientWidth', () => width],
22
+ ['offsetWidth', () => width],
23
+ ['clientHeight', () => H],
24
+ ['offsetHeight', () => H],
25
+ ] as const) {
26
+ Object.defineProperty(HTMLElement.prototype, prop, {
27
+ configurable: true,
28
+ get,
29
+ });
30
+ }
31
+ HTMLElement.prototype.getBoundingClientRect = () =>
32
+ ({
33
+ x: 0,
34
+ y: 0,
35
+ top: 0,
36
+ left: 0,
37
+ right: width,
38
+ bottom: H,
39
+ width,
40
+ height: H,
41
+ toJSON() {},
42
+ }) as DOMRect;
43
+ (globalThis as Record<string, unknown>).ResizeObserver = class {
44
+ private watched = new Set<Element>();
45
+ constructor(private cb: ResizeObserverCallback) {}
46
+ observe(target: Element) {
47
+ this.watched.add(target);
48
+ setTimeout(() => {
49
+ if (!this.watched.has(target)) return;
50
+ this.cb(
51
+ [{ target, contentRect: { width, height: H } } as never],
52
+ this as never,
53
+ );
54
+ });
55
+ }
56
+ unobserve(target: Element) {
57
+ this.watched.delete(target);
58
+ }
59
+ disconnect() {
60
+ this.watched.clear();
61
+ }
62
+ };
63
+ });
64
+
65
+ const chartData = [
66
+ { date: '2026-01-01', historical: 1 },
67
+ { date: '2026-02-01', historical: 2 },
68
+ { date: '2026-03-01', historical: 3 },
69
+ ];
70
+
71
+ const nextFrame = () =>
72
+ act(() => new Promise<void>(r => requestAnimationFrame(() => r())));
73
+
74
+ async function renderChart(
75
+ w: number,
76
+ props: Partial<BaseChartWrapperProps> = {},
77
+ ) {
78
+ width = w;
79
+ const { container } = render(
80
+ <BaseChartWrapper
81
+ chartData={chartData}
82
+ hasCombinedData
83
+ loading={false}
84
+ isDarkTheme={false}
85
+ height={H}
86
+ showLegend={false}
87
+ margin={{ top: 0, right: 0, bottom: 0, left: 0 }}
88
+ {...props}
89
+ />,
90
+ );
91
+ await waitFor(() =>
92
+ expect(container.querySelector('.recharts-line')).toBeTruthy(),
93
+ );
94
+ return container;
95
+ }
96
+
97
+ async function hoverAndRead(
98
+ w: number,
99
+ props: Partial<BaseChartWrapperProps> = {},
100
+ ) {
101
+ const container = await renderChart(w, props);
102
+ const chart = container.querySelectorAll('.recharts-wrapper');
103
+ await act(async () => {
104
+ fireEvent.mouseMove(chart[chart.length - 1], {
105
+ clientX: w - 20,
106
+ clientY: H / 2,
107
+ });
108
+ });
109
+ const wrapper = () =>
110
+ container.querySelector<HTMLElement>('.recharts-tooltip-wrapper');
111
+ await waitFor(() => expect(wrapper()?.style.transform).toMatch(/translate/));
112
+ // Let the wrapper's own placement run.
113
+ await nextFrame();
114
+ await nextFrame();
115
+ const style = wrapper()!.style;
116
+ const y = Number(
117
+ /translate\([-\d.]+px,\s*([-\d.]+)px\)/.exec(style.transform)?.[1],
118
+ );
119
+ return { y, transition: style.transition, container };
120
+ }
121
+
122
+ describe('BaseChartWrapper tooltip placement', () => {
123
+ it('keeps a narrow chart’s tooltip under the chart', async () => {
124
+ const { y, transition } = await hoverAndRead(300);
125
+ expect(y).toBe(H + NARROW_TOOLTIP_GAP_PX);
126
+ expect(transition).toBe('none');
127
+ });
128
+
129
+ it('keeps a wide chart’s tooltip inside the chart, sliding', async () => {
130
+ const { y, transition } = await hoverAndRead(640);
131
+ expect(y).toBeLessThan(H);
132
+ expect(transition).toMatch(/transform/);
133
+ });
134
+ });
135
+
136
+ describe('BaseChartWrapper tooltip values', () => {
137
+ it('formats them with formatTooltipValue', async () => {
138
+ const { container } = await hoverAndRead(640, {
139
+ formatTooltipValue: v => `${v.toFixed(2)} t`,
140
+ });
141
+ await waitFor(() => expect(container.textContent).toContain('3.00 t'));
142
+ });
143
+ });
144
+
145
+ describe('BaseChartWrapper without axes', () => {
146
+ it('draws no axis but the tooltip still names the row’s date', async () => {
147
+ const { container } = await hoverAndRead(640, {
148
+ showAxes: false,
149
+ labelFormatter: (v: unknown) => `month ${String(v)}`,
150
+ });
151
+ await waitFor(() =>
152
+ expect(container.textContent).toContain('month 2026-03-01'),
153
+ );
154
+ expect(
155
+ container.querySelectorAll('.recharts-cartesian-axis-tick'),
156
+ ).toHaveLength(0);
157
+ });
158
+ });
159
+
160
+ describe('BaseChartWrapper lines across missing months', () => {
161
+ const gappy = [
162
+ { date: '2026-01-01', historical: 1, forecast_1: 1 },
163
+ { date: '2026-02-01', historical: null, forecast_1: null },
164
+ { date: '2026-03-01', historical: 3, forecast_1: 3 },
165
+ ];
166
+ const forecastData = [{ id: 1, name: 'Forecast' }];
167
+ // A line broken by a gap is drawn as one path with two "M" moves.
168
+ const moves = (container: HTMLElement, i: number) =>
169
+ (
170
+ container
171
+ .querySelectorAll('.recharts-line-curve')
172
+ [i]?.getAttribute('d')
173
+ ?.match(/M/g) ?? []
174
+ ).length;
175
+ const lastLayer = (container: HTMLElement) => {
176
+ const layers = container.querySelectorAll('.recharts-wrapper');
177
+ return layers[layers.length - 1] as HTMLElement;
178
+ };
179
+
180
+ it('leaves a gap by default', async () => {
181
+ const container = await renderChart(640, {
182
+ chartData: gappy,
183
+ forecastData,
184
+ });
185
+ expect(moves(lastLayer(container), 0)).toBe(2);
186
+ expect(moves(lastLayer(container), 1)).toBe(2);
187
+ });
188
+
189
+ it('joins only history when asked', async () => {
190
+ const history = await renderChart(640, {
191
+ chartData: gappy,
192
+ forecastData,
193
+ connectHistoryNulls: true,
194
+ });
195
+ expect(moves(lastLayer(history), 0)).toBe(1);
196
+ expect(moves(lastLayer(history), 1)).toBe(2);
197
+ });
198
+
199
+ it('joins forecasts when asked', async () => {
200
+ const container = await renderChart(640, {
201
+ chartData: gappy,
202
+ forecastData,
203
+ connectForecastNulls: true,
204
+ });
205
+ expect(moves(lastLayer(container), 0)).toBe(2);
206
+ expect(moves(lastLayer(container), 1)).toBe(1);
207
+ });
208
+ });
209
+
210
+ describe('BaseChartWrapper line order', () => {
211
+ const strokes = (container: HTMLElement) => {
212
+ const layers = container.querySelectorAll('.recharts-wrapper');
213
+ return [
214
+ ...layers[layers.length - 1].querySelectorAll('.recharts-line-curve'),
215
+ ].map(e => e.getAttribute('stroke'));
216
+ };
217
+ const props: Partial<BaseChartWrapperProps> = {
218
+ chartData: [
219
+ { date: '2026-01-01', historical_a: 1, forecast_1: 2 },
220
+ { date: '2026-02-01', historical_a: 2, forecast_1: 3 },
221
+ ],
222
+ historyData: [{ id: 'a', name: 'A', color: 'black' }],
223
+ forecastData: [{ id: 1, name: 'F', color: 'cyan' }],
224
+ };
225
+
226
+ it('draws history first, under the forecasts, by default', async () => {
227
+ const container = await renderChart(640, props);
228
+ expect(strokes(container)).toEqual(['black', 'cyan']);
229
+ });
230
+
231
+ it('draws history last, over the forecasts, when asked', async () => {
232
+ const container = await renderChart(640, { ...props, historyOnTop: true });
233
+ // The history layer mounts a moment after the line layer.
234
+ await waitFor(() => expect(strokes(container)).toEqual(['cyan', 'black']));
235
+ });
236
+
237
+ it('keeps history on top after a forecast is hidden and shown again', async () => {
238
+ width = 640;
239
+ const chart = (hidden: Set<string>) => (
240
+ <BaseChartWrapper
241
+ {...(props as BaseChartWrapperProps)}
242
+ hasCombinedData
243
+ loading={false}
244
+ isDarkTheme={false}
245
+ height={H}
246
+ showLegend={false}
247
+ historyOnTop
248
+ hiddenSeries={hidden}
249
+ />
250
+ );
251
+ const { container, rerender } = render(chart(new Set()));
252
+ await waitFor(() => expect(strokes(container)).toHaveLength(2));
253
+ rerender(chart(new Set(['forecast_1'])));
254
+ await waitFor(() => expect(strokes(container)).toEqual(['black']));
255
+ rerender(chart(new Set()));
256
+ await waitFor(() => expect(strokes(container)).toHaveLength(2));
257
+ expect(strokes(container)).toEqual(['cyan', 'black']);
258
+ });
259
+ });
260
+
261
+ describe('BaseChartWrapper end dots', () => {
262
+ const dots = (container: HTMLElement) => {
263
+ const layers = container.querySelectorAll('.recharts-wrapper');
264
+ return layers[layers.length - 1].querySelectorAll('circle').length;
265
+ };
266
+
267
+ it('marks each line’s last point by default', async () => {
268
+ const container = await renderChart(640);
269
+ await waitFor(() => expect(dots(container)).toBe(1));
270
+ });
271
+
272
+ it('leaves them off when asked', async () => {
273
+ const container = await renderChart(640, { showEndDots: false });
274
+ await nextFrame();
275
+ expect(dots(container)).toBe(0);
276
+ });
277
+ });
278
+
279
+ describe('BaseChartWrapper without axes, fixed y range', () => {
280
+ it('keeps yMin/yMax as the hidden y-axis range', async () => {
281
+ // One value of 0.5 on a fixed 0–1 range sits in the middle of the plot;
282
+ // with recharts' default range it would sit at the top.
283
+ const container = await renderChart(640, {
284
+ chartData: [
285
+ { date: '2026-01-01', historical: 0.5 },
286
+ { date: '2026-02-01', historical: 0.5 },
287
+ ],
288
+ showAxes: false,
289
+ yMin: 0,
290
+ yMax: 1,
291
+ autoScaleYAxis: false,
292
+ });
293
+ const d = container
294
+ .querySelectorAll('.recharts-wrapper')
295
+ [
296
+ container.querySelectorAll('.recharts-wrapper').length - 1
297
+ ].querySelector('.recharts-line-curve')!
298
+ .getAttribute('d')!;
299
+ const y = Number(/^M[-\d.]+,([-\d.]+)/.exec(d)?.[1]);
300
+ expect(y).toBeCloseTo(H / 2, 0);
301
+ });
302
+ });
303
+
304
+ describe('BaseChartWrapper range bands across missing months', () => {
305
+ const rows = [
306
+ { date: '2026-01-01', historical: 1, band: [0, 2] },
307
+ { date: '2026-02-01', historical: 2, band: null },
308
+ { date: '2026-03-01', historical: 3, band: [2, 4] },
309
+ ];
310
+ const band = {
311
+ key: 'band',
312
+ name: 'Range',
313
+ quantiles: ['0.1', '0.9'] as [string, string],
314
+ opacity: 0.12,
315
+ };
316
+ const areaMoves = async (connectNulls?: boolean) => {
317
+ width = 640;
318
+ const { container } = render(
319
+ <BaseChartWrapper
320
+ chartData={rows as never}
321
+ hasCombinedData
322
+ loading={false}
323
+ isDarkTheme={false}
324
+ height={H}
325
+ showLegend={false}
326
+ quantileBands={[{ ...band, connectNulls }]}
327
+ />,
328
+ );
329
+ await waitFor(() =>
330
+ expect(container.querySelector('.recharts-area-area')).toBeTruthy(),
331
+ );
332
+ const areas = container.querySelectorAll('.recharts-area-area');
333
+ return (areas[areas.length - 1].getAttribute('d')?.match(/M/g) ?? [])
334
+ .length;
335
+ };
336
+
337
+ it('fills across them by default', async () => {
338
+ expect(await areaMoves()).toBe(1);
339
+ });
340
+
341
+ it('leaves a gap when the band says so', async () => {
342
+ expect(await areaMoves(false)).toBe(2);
343
+ });
344
+ });