@sybilion/uilib 1.7.1 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-glossary/content-prompt.generated.ts +2 -0
- package/dist/agent-glossary/content.generated.ts +2 -0
- package/dist/agent-glossary/content.md +2 -0
- package/dist/agent-glossary/content.prompt.md +2 -0
- package/dist/agent-glossary/workspace.generated.ts +1 -0
- package/dist/agent-glossary/workspace.index.md +1 -0
- package/dist/agent-glossary/workspace.md +1 -0
- package/dist/esm/src/components/ui/AnalysesSelector/AnalysesSelector.js +37 -20
- package/dist/esm/src/components/ui/Chart/Chart.styl.js +2 -2
- package/dist/esm/src/components/ui/Chart/components/BaseChartWrapper.js +46 -51
- package/dist/esm/src/components/ui/Chart/components/ChartContainer.js +2 -2
- package/dist/esm/src/components/ui/Chart/components/ChartGrid.js +2 -2
- package/dist/esm/src/components/ui/Chart/components/ChartLegendContent.js +2 -2
- package/dist/esm/src/components/ui/Chart/components/ChartLegendItem.js +2 -2
- package/dist/esm/src/components/ui/Chart/components/ChartTooltipContent.js +2 -2
- package/dist/esm/src/components/ui/Chart/components/ChartTooltipItem.js +3 -3
- package/dist/esm/src/components/ui/Chart/components/CustomChartLegend/CustomChartLegend.js +8 -3
- package/dist/esm/src/components/ui/Chart/components/LegendSvg/LegendSvg.js +1 -1
- package/dist/esm/src/components/ui/ChartAreaInteractive/ChartAreaInteractive.helpers.js +17 -6
- package/dist/esm/src/components/ui/ChartAreaInteractive/ChartAreaInteractive.js +40 -10
- package/dist/esm/src/components/ui/ChartAreaInteractive/ChartLines.js +43 -13
- package/dist/esm/src/components/ui/ChartAreaInteractive/chartHistories.js +44 -0
- package/dist/esm/src/components/ui/ChartAreaInteractive/overlays/useChartYRange.js +32 -7
- package/dist/esm/src/components/ui/Page/PageTabs/PageTabs.styl.js +2 -2
- package/dist/esm/src/components/ui/Page/PageXScroll/PageXScroll.js +50 -15
- package/dist/esm/src/components/ui/StackedAreaChart/StackedAreaChart.helpers.js +212 -0
- package/dist/esm/src/components/ui/StackedAreaChart/StackedAreaChart.js +123 -0
- package/dist/esm/src/components/ui/StackedAreaChart/StackedAreaChart.styl.js +7 -0
- package/dist/esm/src/components/ui/StackedAreaChart/StackedAreaChart.tooltip.js +29 -0
- package/dist/esm/src/index.js +3 -1
- package/dist/esm/src/utils/chartConnectionPoint.js +31 -16
- package/dist/esm/types/src/components/ui/AnalysesSelector/AnalysesSelector.d.ts +1 -1
- package/dist/esm/types/src/components/ui/AnalysesSelector/AnalysesSelector.types.d.ts +12 -0
- package/dist/esm/types/src/components/ui/AnalysesSelector/index.d.ts +1 -1
- package/dist/esm/types/src/components/ui/Chart/components/BaseChartWrapper.d.ts +8 -0
- package/dist/esm/types/src/components/ui/Chart/components/CustomChartLegend/CustomChartLegend.d.ts +8 -1
- package/dist/esm/types/src/components/ui/Chart/components/LegendSvg/LegendSvg.d.ts +2 -0
- package/dist/esm/types/src/components/ui/ChartAreaInteractive/ChartAreaInteractive.d.ts +1 -1
- package/dist/esm/types/src/components/ui/ChartAreaInteractive/ChartAreaInteractive.helpers.d.ts +5 -0
- package/dist/esm/types/src/components/ui/ChartAreaInteractive/ChartLines.d.ts +19 -1
- package/dist/esm/types/src/components/ui/ChartAreaInteractive/chartHistories.d.ts +40 -0
- package/dist/esm/types/src/components/ui/ChartAreaInteractive/index.d.ts +1 -0
- package/dist/esm/types/src/components/ui/ChartAreaInteractive/overlays/useChartYRange.d.ts +6 -1
- package/dist/esm/types/src/components/ui/Page/PageXScroll/PageXScroll.d.ts +1 -1
- package/dist/esm/types/src/components/ui/StackedAreaChart/StackedAreaChart.d.ts +3 -0
- package/dist/esm/types/src/components/ui/StackedAreaChart/StackedAreaChart.helpers.d.ts +65 -0
- package/dist/esm/types/src/components/ui/StackedAreaChart/StackedAreaChart.tooltip.d.ts +20 -0
- package/dist/esm/types/src/components/ui/StackedAreaChart/StackedAreaChart.types.d.ts +85 -0
- package/dist/esm/types/src/components/ui/StackedAreaChart/index.d.ts +2 -0
- package/dist/esm/types/src/docs/pages/StackedAreaChartPage.d.ts +1 -0
- package/dist/esm/types/src/index.d.ts +1 -0
- package/dist/esm/types/src/utils/chartConnectionPoint.d.ts +11 -3
- package/dist/esm/types/tests/chartHistories.test.d.ts +1 -0
- package/dist/esm/types/tests/pageXScroll.test.d.ts +1 -0
- package/dist/esm/types/tests/stackedAreaChart.test.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/ui/AnalysesSelector/AnalysesSelector.tsx +50 -22
- package/src/components/ui/AnalysesSelector/AnalysesSelector.types.ts +13 -0
- package/src/components/ui/AnalysesSelector/index.ts +1 -0
- package/src/components/ui/Chart/components/BaseChartWrapper.tsx +71 -52
- package/src/components/ui/Chart/components/CustomChartLegend/CustomChartLegend.tsx +21 -1
- package/src/components/ui/Chart/components/LegendSvg/LegendSvg.tsx +3 -1
- package/src/components/ui/ChartAreaInteractive/AGENT.md +2 -0
- package/src/components/ui/ChartAreaInteractive/ChartAreaInteractive.helpers.ts +27 -5
- package/src/components/ui/ChartAreaInteractive/ChartAreaInteractive.tsx +64 -10
- package/src/components/ui/ChartAreaInteractive/ChartLines.tsx +86 -30
- package/src/components/ui/ChartAreaInteractive/chartHistories.ts +63 -0
- package/src/components/ui/ChartAreaInteractive/index.ts +1 -0
- package/src/components/ui/ChartAreaInteractive/overlays/useChartYRange.ts +52 -6
- package/src/components/ui/Page/AGENT.md +2 -0
- package/src/components/ui/Page/PageTabs/PageTabs.styl +8 -0
- package/src/components/ui/Page/PageXScroll/PageXScroll.tsx +57 -13
- package/src/components/ui/StackedAreaChart/AGENT.md +26 -0
- package/src/components/ui/StackedAreaChart/StackedAreaChart.helpers.ts +268 -0
- package/src/components/ui/StackedAreaChart/StackedAreaChart.styl +32 -0
- package/src/components/ui/StackedAreaChart/StackedAreaChart.styl.d.ts +13 -0
- package/src/components/ui/StackedAreaChart/StackedAreaChart.tooltip.tsx +82 -0
- package/src/components/ui/StackedAreaChart/StackedAreaChart.tsx +416 -0
- package/src/components/ui/StackedAreaChart/StackedAreaChart.types.ts +97 -0
- package/src/components/ui/StackedAreaChart/index.ts +2 -0
- package/src/docs/pages/ChartAreaInteractivePage.tsx +67 -0
- package/src/docs/pages/StackedAreaChartPage.tsx +141 -0
- package/src/docs/registry.ts +6 -0
- package/src/index.ts +1 -0
- package/src/utils/chartConnectionPoint.ts +41 -18
- package/src/components/ui/Chart/chart-types.csv +0 -33
|
@@ -222,6 +222,8 @@ Pass \`columns={[node1, node2, …]}\`. For 3–4 equal columns, omit \`fill\`;
|
|
|
222
222
|
|
|
223
223
|
Horizontal scroll strip; used inside \`PageTabs\` and anywhere a overflowing row needs page-aligned padding. Props: \`size\`, \`fullWidth\`, \`innerClassName\`, \`scrollbarClassName\`.
|
|
224
224
|
|
|
225
|
+
The inset before and after the row is \`--page-x-padding\`, as the cascade resolves it for the row: an app that needs another inset sets that variable on \`:root\` or on any ancestor of the row (for example \`0\` when a layout around the row already has its own gutter), and the spacers, the scrollbar and the fade all follow. The scrollbar and the fade read it when the row mounts and when the window is resized, so a value that changes in a media query follows too; one changed another way after mount (a class toggled on an ancestor) shows in the spacers at once and in the scrollbar and fade at the next resize. The row's tabs draw their keyboard focus ring inside themselves, since the scrolling row would clip a ring drawn outside.
|
|
226
|
+
|
|
225
227
|
### SectionHeader
|
|
226
228
|
|
|
227
229
|
In-section title block (\`title\`, \`description\`, \`actions\`). Use **inside** \`PageContentSection\`, not as a replacement for \`PageHeader\`.
|
|
@@ -222,6 +222,8 @@ Pass \`columns={[node1, node2, …]}\`. For 3–4 equal columns, omit \`fill\`;
|
|
|
222
222
|
|
|
223
223
|
Horizontal scroll strip; used inside \`PageTabs\` and anywhere a overflowing row needs page-aligned padding. Props: \`size\`, \`fullWidth\`, \`innerClassName\`, \`scrollbarClassName\`.
|
|
224
224
|
|
|
225
|
+
The inset before and after the row is \`--page-x-padding\`, as the cascade resolves it for the row: an app that needs another inset sets that variable on \`:root\` or on any ancestor of the row (for example \`0\` when a layout around the row already has its own gutter), and the spacers, the scrollbar and the fade all follow. The scrollbar and the fade read it when the row mounts and when the window is resized, so a value that changes in a media query follows too; one changed another way after mount (a class toggled on an ancestor) shows in the spacers at once and in the scrollbar and fade at the next resize. The row's tabs draw their keyboard focus ring inside themselves, since the scrolling row would clip a ring drawn outside.
|
|
226
|
+
|
|
225
227
|
### SectionHeader
|
|
226
228
|
|
|
227
229
|
In-section title block (\`title\`, \`description\`, \`actions\`). Use **inside** \`PageContentSection\`, not as a replacement for \`PageHeader\`.
|
|
@@ -221,6 +221,8 @@ Pass `columns={[node1, node2, …]}`. For 3–4 equal columns, omit `fill`; do n
|
|
|
221
221
|
|
|
222
222
|
Horizontal scroll strip; used inside `PageTabs` and anywhere a overflowing row needs page-aligned padding. Props: `size`, `fullWidth`, `innerClassName`, `scrollbarClassName`.
|
|
223
223
|
|
|
224
|
+
The inset before and after the row is `--page-x-padding`, as the cascade resolves it for the row: an app that needs another inset sets that variable on `:root` or on any ancestor of the row (for example `0` when a layout around the row already has its own gutter), and the spacers, the scrollbar and the fade all follow. The scrollbar and the fade read it when the row mounts and when the window is resized, so a value that changes in a media query follows too; one changed another way after mount (a class toggled on an ancestor) shows in the spacers at once and in the scrollbar and fade at the next resize. The row's tabs draw their keyboard focus ring inside themselves, since the scrolling row would clip a ring drawn outside.
|
|
225
|
+
|
|
224
226
|
### SectionHeader
|
|
225
227
|
|
|
226
228
|
In-section title block (`title`, `description`, `actions`). Use **inside** `PageContentSection`, not as a replacement for `PageHeader`.
|
|
@@ -221,6 +221,8 @@ Pass `columns={[node1, node2, …]}`. For 3–4 equal columns, omit `fill`; do n
|
|
|
221
221
|
|
|
222
222
|
Horizontal scroll strip; used inside `PageTabs` and anywhere a overflowing row needs page-aligned padding. Props: `size`, `fullWidth`, `innerClassName`, `scrollbarClassName`.
|
|
223
223
|
|
|
224
|
+
The inset before and after the row is `--page-x-padding`, as the cascade resolves it for the row: an app that needs another inset sets that variable on `:root` or on any ancestor of the row (for example `0` when a layout around the row already has its own gutter), and the spacers, the scrollbar and the fade all follow. The scrollbar and the fade read it when the row mounts and when the window is resized, so a value that changes in a media query follows too; one changed another way after mount (a class toggled on an ancestor) shows in the spacers at once and in the scrollbar and fade at the next resize. The row's tabs draw their keyboard focus ring inside themselves, since the scrolling row would clip a ring drawn outside.
|
|
225
|
+
|
|
224
226
|
### SectionHeader
|
|
225
227
|
|
|
226
228
|
In-section title block (`title`, `description`, `actions`). Use **inside** `PageContentSection`, not as a replacement for `PageHeader`.
|
|
@@ -68,6 +68,7 @@ Entry point for \`@sybilion/uilib\`. Open linked AGENT.md before using a compone
|
|
|
68
68
|
- [Slider](src/components/ui/Slider/AGENT.md) — Slider lets users select a numeric value from a continuous or stepped range by dragging a thumb along a track. Contro…
|
|
69
69
|
- [SmartTextTruncate](src/components/ui/SmartTextTruncate/AGENT.md) — SmartTextTruncate shortens a long string in the middle so it fits its container, keeping the end of the string visibl…
|
|
70
70
|
- [Sparkline](src/components/ui/Sparkline/AGENT.md) — Sparkline renders a compact line chart from an array of numbers, sized to fit inline alongside text or inside table c…
|
|
71
|
+
- [StackedAreaChart](src/components/ui/StackedAreaChart/AGENT.md) — StackedAreaChart shows how a total is built from parts over time: cost layers stacked bottom first, an optional margi…
|
|
71
72
|
- [SupplyChainMap](src/components/ui/SupplyChainMap/AGENT.md) — Interactive Natural Earth supply-chain map with clustering, disclosure, and optional OffscreenCanvas worker paint
|
|
72
73
|
- [Switch](src/components/ui/Switch/AGENT.md) — Switch is a binary control for turning a setting on or off. Unlike a checkbox, a switch implies the change takes effe…
|
|
73
74
|
- [Table](src/components/ui/Table/AGENT.md) — Table is a set of semantic primitives — Table, TableHeader, TableBody, TableRow, TableHead, and TableCell — for prese…
|
|
@@ -67,6 +67,7 @@ Entry point for `@sybilion/uilib`. Open linked AGENT.md before using a component
|
|
|
67
67
|
- [Slider](src/components/ui/Slider/AGENT.md) — Slider lets users select a numeric value from a continuous or stepped range by dragging a thumb along a track. Contro…
|
|
68
68
|
- [SmartTextTruncate](src/components/ui/SmartTextTruncate/AGENT.md) — SmartTextTruncate shortens a long string in the middle so it fits its container, keeping the end of the string visibl…
|
|
69
69
|
- [Sparkline](src/components/ui/Sparkline/AGENT.md) — Sparkline renders a compact line chart from an array of numbers, sized to fit inline alongside text or inside table c…
|
|
70
|
+
- [StackedAreaChart](src/components/ui/StackedAreaChart/AGENT.md) — StackedAreaChart shows how a total is built from parts over time: cost layers stacked bottom first, an optional margi…
|
|
70
71
|
- [SupplyChainMap](src/components/ui/SupplyChainMap/AGENT.md) — Interactive Natural Earth supply-chain map with clustering, disclosure, and optional OffscreenCanvas worker paint
|
|
71
72
|
- [Switch](src/components/ui/Switch/AGENT.md) — Switch is a binary control for turning a setting on or off. Unlike a checkbox, a switch implies the change takes effe…
|
|
72
73
|
- [Table](src/components/ui/Table/AGENT.md) — Table is a set of semantic primitives — Table, TableHeader, TableBody, TableRow, TableHead, and TableCell — for prese…
|
|
@@ -67,6 +67,7 @@ Entry point for `@sybilion/uilib`. Open linked AGENT.md before using a component
|
|
|
67
67
|
- [Slider](src/components/ui/Slider/AGENT.md) — Slider lets users select a numeric value from a continuous or stepped range by dragging a thumb along a track. Contro…
|
|
68
68
|
- [SmartTextTruncate](src/components/ui/SmartTextTruncate/AGENT.md) — SmartTextTruncate shortens a long string in the middle so it fits its container, keeping the end of the string visibl…
|
|
69
69
|
- [Sparkline](src/components/ui/Sparkline/AGENT.md) — Sparkline renders a compact line chart from an array of numbers, sized to fit inline alongside text or inside table c…
|
|
70
|
+
- [StackedAreaChart](src/components/ui/StackedAreaChart/AGENT.md) — StackedAreaChart shows how a total is built from parts over time: cost layers stacked bottom first, an optional margi…
|
|
70
71
|
- [SupplyChainMap](src/components/ui/SupplyChainMap/AGENT.md) — Interactive Natural Earth supply-chain map with clustering, disclosure, and optional OffscreenCanvas worker paint
|
|
71
72
|
- [Switch](src/components/ui/Switch/AGENT.md) — Switch is a binary control for turning a setting on or off. Unlike a checkbox, a switch implies the change takes effe…
|
|
72
73
|
- [Table](src/components/ui/Table/AGENT.md) — Table is a set of semantic primitives — Table, TableHeader, TableBody, TableRow, TableHead, and TableCell — for prese…
|
|
@@ -12,7 +12,8 @@ import S from './AnalysesSelector.styl.js';
|
|
|
12
12
|
import { SelectInlineRenamer } from './SelectInlineRenamer.js';
|
|
13
13
|
|
|
14
14
|
const isFailed = (item) => item.status?.toLowerCase() === 'fail';
|
|
15
|
-
const
|
|
15
|
+
const isHistoryItem = (item) => item.id === -1 || item.seriesKey !== undefined;
|
|
16
|
+
const isDashedIcon = (item) => !isHistoryItem(item);
|
|
16
17
|
const defaultIsAnalysisInProgress = (status) => ['pending', 'running', 'cancelling'].includes(status?.toLowerCase() ?? '');
|
|
17
18
|
const shouldBlockSelectKeydownWhileRenaming = (e) => {
|
|
18
19
|
if (!(e.target instanceof HTMLInputElement)) {
|
|
@@ -39,7 +40,7 @@ function renderIcon(icon) {
|
|
|
39
40
|
}
|
|
40
41
|
return (jsx("span", { "data-slot": "analysis-icon", className: cn(S.icon, S.iconWrapper), children: icon }));
|
|
41
42
|
}
|
|
42
|
-
function AnalysesSelector({ items, selectedIds, onItemToggle, inlineMode = false, placeholder, disabled, size = 'md', variant = 'default', darker = false, className, triggerProps, onFailedItemClick, showHistorical = true, enableToggleHidden = false, maxVisibleItems = 1, preventDeselection = false, hiddenSeries: hiddenSeriesProp = new Set(), onToggleSeries = () => { }, isAnalysisInProgress: isAnalysisInProgressProp = defaultIsAnalysisInProgress, rename, }) {
|
|
43
|
+
function AnalysesSelector({ items, selectedIds, onItemToggle, inlineMode = false, placeholder, disabled, size = 'md', variant = 'default', darker = false, className, triggerProps, onFailedItemClick, showHistorical = true, historicalItems, enableToggleHidden = false, maxVisibleItems = 1, preventDeselection = false, hiddenSeries: hiddenSeriesProp = new Set(), onToggleSeries = () => { }, isAnalysisInProgress: isAnalysisInProgressProp = defaultIsAnalysisInProgress, rename, }) {
|
|
43
44
|
const historicalAutoSelectedRef = useRef(false);
|
|
44
45
|
const hiddenSeries = hiddenSeriesProp;
|
|
45
46
|
const toggleSeries = (analysisId) => {
|
|
@@ -56,17 +57,33 @@ function AnalysesSelector({ items, selectedIds, onItemToggle, inlineMode = false
|
|
|
56
57
|
return new Set([selectedIds]);
|
|
57
58
|
return new Set(Array.isArray(selectedIds) ? selectedIds : Array.from(selectedIds));
|
|
58
59
|
}, [selectedIds]);
|
|
60
|
+
// The history entries: one per `historicalItems` line, or the single "Historical".
|
|
61
|
+
const historyEntries = useMemo(() => {
|
|
62
|
+
if (!showHistorical)
|
|
63
|
+
return [];
|
|
64
|
+
if (historicalItems?.length) {
|
|
65
|
+
return historicalItems.map((h, index) => ({
|
|
66
|
+
// Negative ids keep them apart from analyses in keys; the history
|
|
67
|
+
// is recognised by its seriesKey.
|
|
68
|
+
id: -(index + 1),
|
|
69
|
+
label: h.label,
|
|
70
|
+
color: h.color,
|
|
71
|
+
seriesKey: h.seriesKey,
|
|
72
|
+
dimmed: hiddenSeries.has(h.seriesKey),
|
|
73
|
+
}));
|
|
74
|
+
}
|
|
75
|
+
return [
|
|
76
|
+
{
|
|
77
|
+
id: -1,
|
|
78
|
+
label: 'Historical',
|
|
79
|
+
dimmed: hiddenSeries.has('historical'),
|
|
80
|
+
},
|
|
81
|
+
];
|
|
82
|
+
}, [showHistorical, historicalItems, hiddenSeries]);
|
|
59
83
|
// In inlineMode, show Historical + selected analyses (limited by maxVisibleItems)
|
|
60
84
|
const selectedItems = useMemo(() => {
|
|
61
85
|
if (inlineMode) {
|
|
62
|
-
const list = [];
|
|
63
|
-
if (showHistorical) {
|
|
64
|
-
list.push({
|
|
65
|
-
id: -1,
|
|
66
|
-
label: 'Historical',
|
|
67
|
-
dimmed: hiddenSeries.has('historical'),
|
|
68
|
-
});
|
|
69
|
-
}
|
|
86
|
+
const list = [...historyEntries];
|
|
70
87
|
// Filter by selectedIds, exclude failed items and user series
|
|
71
88
|
const analysesOnly = items.filter(item => selectedSet.has(item.id) &&
|
|
72
89
|
!isFailed(item) &&
|
|
@@ -81,18 +98,12 @@ function AnalysesSelector({ items, selectedIds, onItemToggle, inlineMode = false
|
|
|
81
98
|
return list.concat(limitedItems);
|
|
82
99
|
}
|
|
83
100
|
// Non-inlineMode: keep original behavior
|
|
84
|
-
const list = [];
|
|
85
|
-
if (showHistorical) {
|
|
86
|
-
list.push({
|
|
87
|
-
id: -1,
|
|
88
|
-
label: 'Historical',
|
|
89
|
-
});
|
|
90
|
-
}
|
|
101
|
+
const list = [...historyEntries];
|
|
91
102
|
return list.concat(items.filter(item => selectedSet.has(item.id)));
|
|
92
103
|
}, [
|
|
93
104
|
items,
|
|
94
105
|
selectedSet,
|
|
95
|
-
|
|
106
|
+
historyEntries,
|
|
96
107
|
inlineMode,
|
|
97
108
|
hiddenSeries,
|
|
98
109
|
maxVisibleItems,
|
|
@@ -163,6 +174,8 @@ function AnalysesSelector({ items, selectedIds, onItemToggle, inlineMode = false
|
|
|
163
174
|
handleItemClick(item);
|
|
164
175
|
};
|
|
165
176
|
const handleItemClick = (item) => {
|
|
177
|
+
if (item.seriesKey !== undefined)
|
|
178
|
+
return;
|
|
166
179
|
if (isFailed(item) && onFailedItemClick) {
|
|
167
180
|
onFailedItemClick(item.id);
|
|
168
181
|
}
|
|
@@ -183,10 +196,14 @@ function AnalysesSelector({ items, selectedIds, onItemToggle, inlineMode = false
|
|
|
183
196
|
return null;
|
|
184
197
|
return hiddenSeries.has(`forecast_${item.id}`) ? (jsx(EyeClosedIcon, {})) : (jsx(EyeIcon, {}));
|
|
185
198
|
};
|
|
186
|
-
const renderItemLabel = (item) => (jsx(LabelWithId
|
|
199
|
+
const renderItemLabel = (item) => (jsx(LabelWithId
|
|
200
|
+
// -1 shows no id badge: history lines have no analysis id.
|
|
201
|
+
, {
|
|
202
|
+
// -1 shows no id badge: history lines have no analysis id.
|
|
203
|
+
id: isHistoryItem(item) ? -1 : item.id, label: isAnalysisInProgressProp(item.status) ? (jsx(TextShimmer, { as: "span", children: item.label })) : (item.label), className: cn(S.label, S.itemLabelWithId) }));
|
|
187
204
|
const renderSelectItem = (item) => (jsxs("div", { className: S.selectItemContent, children: [renderItemContent(item), renderIcon(item.icon), renderItemLabel(item), renderEyeIcon(item)] }));
|
|
188
205
|
if (inlineMode) {
|
|
189
|
-
return (jsxs("div", { className: cn(S.root, S[`variant-${variant}`], selectedItems.length === 1 && S.single, className), children: [selectedItems.map(item => (jsxs("div", { className: cn(S.item, disabled && S.disabled, item
|
|
206
|
+
return (jsxs("div", { className: cn(S.root, S[`variant-${variant}`], selectedItems.length === 1 && S.single, className), children: [selectedItems.map(item => (jsxs("div", { className: cn(S.item, disabled && S.disabled, isHistoryItem(item) && S.historical, item.dimmed && S.dimmed), onClick: () => !disabled && handleItemClick(item), children: [renderIcon(item.icon), renderItemContent(item), renderItemLabel(item)] }, item.seriesKey ?? item.id))), unselectedItems.length > 0 && (jsxs(Select, { value: "", onValueChange: handleSelectValue, disabled: disabled, children: [jsx(SelectTrigger, { size: size, variant: variant, className: S.selectTrigger, darker: darker, style: {
|
|
190
207
|
minWidth: 'auto',
|
|
191
208
|
height: 'auto',
|
|
192
209
|
fontSize: 'var(--text-xs)',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import styleInject from 'style-inject';
|
|
2
2
|
|
|
3
3
|
var css_248z = "@media (max-width:768px){:root{--page-x-padding:var(--p-6);--page-y-padding:var(--p-6)}}.Chart_chartContainer__--q1l{aspect-ratio:16/9;display:flex;font-size:.75rem;justify-content:center;line-height:1rem;max-width:100%;touch-action:none;width:100%}.Chart_chartContainer__--q1l .recharts-cartesian-axis-tick text{fill:var(--muted-foreground)}.Chart_chartContainer__--q1l .recharts-cartesian-grid line[stroke=\"#ccc\"]{stroke:var(--border)}.dark .Chart_chartContainer__--q1l .recharts-cartesian-grid line[stroke=\"#ccc\"]{stroke:var(--sb-slate-900)}.Chart_chartContainer__--q1l .recharts-curve.recharts-tooltip-cursor,.Chart_chartContainer__--q1l .recharts-polar-grid [stroke=\"#ccc\"]{stroke:var(--border)}.Chart_chartContainer__--q1l .recharts-radial-bar-background-sector,.Chart_chartContainer__--q1l .recharts-rectangle.recharts-tooltip-cursor{fill:var(--muted)}.Chart_chartContainer__--q1l .recharts-reference-line [stroke=\"#ccc\"]{stroke:var(--border)}.Chart_chartContainer__--q1l .recharts-dot[stroke=\"#fff\"]{stroke:transparent}.Chart_chartContainer__--q1l .recharts-layer,.Chart_chartContainer__--q1l .recharts-sector{outline:none}.Chart_chartContainer__--q1l .recharts-sector[stroke=\"#fff\"]{stroke:transparent}.Chart_chartContainer__--q1l .recharts-surface{outline:none}.Chart_chartContainer__--q1l .recharts-wrapper{position:relative}.Chart_chartContainer__--q1l .recharts-surface{position:relative;z-index:1}.Chart_chartContainer__--q1l .recharts-tooltip-wrapper{box-sizing:border-box;max-width:90%;z-index:3!important}.Chart_chartContainer__--q1l .recharts-active-dot{z-index:3}.Chart_chartGrid__t52WF{stroke-width:.6}.Chart_tooltipContainer__6tc0q{align-items:start;box-sizing:border-box;display:grid;max-width:min(500px,90vw);min-width:0;overflow-wrap:break-word;width:100%;word-break:break-word;grid-gap:.375rem;backdrop-filter:blur(10px);background-color:color-mix(in srgb,var(--background) 70%,transparent);border:1px solid var(--border)/.5;border-radius:.5rem;box-shadow:0 10px 10px -5px rgba(0,0,0,.2),0 0 1px 0 var(--muted-foreground);font-size:.75rem;gap:.375rem;line-height:1rem;opacity:0;padding:.375rem .625rem;transition:opacity .5s ease-out}.dark .Chart_tooltipContainer__6tc0q{background-color:color-mix(in srgb,var(--background) 50%,transparent);box-shadow:0 0 1px 0 var(--sb-slate-700),0 10px 10px -5px rgba(0,0,0,.7)}.Chart_chartContainer__--q1l:hover .Chart_tooltipContainer__6tc0q{opacity:1;transition-duration:.5s}.Chart_tooltipContentGrid__3Q7ZC{display:flex;flex-direction:column;gap:var(--p-1)}.Chart_tooltipItem__j8I9T{align-items:stretch;display:flex;flex-wrap:wrap;gap:.5rem;width:100%}.Chart_tooltipItem__j8I9T>svg{color:var(--muted-foreground);height:.625rem;width:.625rem}.Chart_tooltipIndicator__Z-JWp{background-color:var(--color-bg);border-color:var(--color-border);border-radius:2px;border-width:1px;flex-shrink:0}.Chart_tooltipIndicator__Z-JWp.Chart_indicator-dot__MWcmW{height:.625rem;width:.625rem}.Chart_tooltipIndicator__Z-JWp.Chart_indicator-line__MO3ul{width:.25rem}.Chart_tooltipIndicator__Z-JWp.Chart_indicator-dashed__2LqIN{background-color:transparent;border-style:dashed;border-width:1.5px;width:0}.Chart_tooltipIndicator__Z-JWp.Chart_indicator-dashed__2LqIN.Chart_nested__7EWWk{margin-bottom:.125rem;margin-top:.125rem}.Chart_tooltipContent__M3R-W{align-items:flex-end;display:flex;flex:1 1 0%;justify-content:space-between;line-height:1;min-width:0}.Chart_tooltipLabel__zMpjZ{display:grid;min-width:0;grid-gap:.375rem;gap:.375rem}.Chart_tooltipLabelText__45osJ{display:-webkit-box;-webkit-line-clamp:3;max-width:100%;min-width:0;overflow:hidden;word-break:break-word;-webkit-box-orient:vertical}.Chart_tooltipValue__vTQxU{color:var(--foreground);font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:\"tnum\";font-variant-numeric:tabular-nums;font-weight:500;margin-left:var(--p-3);white-space:nowrap}.Chart_legendContainer__u1J3U{align-items:center;display:flex;gap:1rem;justify-content:center}.Chart_legendItem__0CSyC{align-items:center;display:flex;gap:.375rem}.Chart_legendItem__0CSyC>svg{color:var(--muted-foreground);height:.75rem;width:.75rem}.Chart_legendIndicator__erzzP{border-radius:2px;flex-shrink:0;height:.5rem;width:.5rem}.chart-line-blinking path{animation:chart-line-blink 1s ease-in-out infinite;animation-direction:alternate}@keyframes Chart_chart-line-blink__4EI-g{0%{opacity:.5}to{opacity:1}}";
|
|
4
|
-
var
|
|
4
|
+
var ChartS = {"chartContainer":"Chart_chartContainer__--q1l","chartGrid":"Chart_chartGrid__t52WF","tooltipContainer":"Chart_tooltipContainer__6tc0q","tooltipContentGrid":"Chart_tooltipContentGrid__3Q7ZC","tooltipItem":"Chart_tooltipItem__j8I9T","tooltipIndicator":"Chart_tooltipIndicator__Z-JWp","indicator-dot":"Chart_indicator-dot__MWcmW","indicator-line":"Chart_indicator-line__MO3ul","indicator-dashed":"Chart_indicator-dashed__2LqIN","nested":"Chart_nested__7EWWk","tooltipContent":"Chart_tooltipContent__M3R-W","tooltipLabel":"Chart_tooltipLabel__zMpjZ","tooltipLabelText":"Chart_tooltipLabelText__45osJ","tooltipValue":"Chart_tooltipValue__vTQxU","legendContainer":"Chart_legendContainer__u1J3U","legendItem":"Chart_legendItem__0CSyC","legendIndicator":"Chart_legendIndicator__erzzP","chart-line-blink":"Chart_chart-line-blink__4EI-g"};
|
|
5
5
|
styleInject(css_248z);
|
|
6
6
|
|
|
7
|
-
export {
|
|
7
|
+
export { ChartS as default };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import cn from 'classnames';
|
|
3
3
|
import { forwardRef, useState, useRef, useMemo, useEffect } from 'react';
|
|
4
|
-
import { getForecastColor, ChartLines } from '../../ChartAreaInteractive/ChartLines.js';
|
|
4
|
+
import { resolveHistoryLines, getForecastColor, ChartLines } from '../../ChartAreaInteractive/ChartLines.js';
|
|
5
|
+
import { isHistorySeriesKey, historySeriesKeys } from '../../ChartAreaInteractive/chartHistories.js';
|
|
5
6
|
import { Skeleton } from '../../Skeleton/Skeleton.js';
|
|
6
7
|
import { chartRenderQueue } from '../../../../utils/chartRenderQueue.js';
|
|
7
8
|
import { Tooltip, LineChart, ComposedChart } from 'recharts';
|
|
@@ -50,7 +51,7 @@ BaseChartWrapperLoading.displayName = 'BaseChartWrapperLoading';
|
|
|
50
51
|
* Separated to maintain hook order consistency
|
|
51
52
|
*/
|
|
52
53
|
const BaseChartWrapperContent = forwardRef((props, ref) => {
|
|
53
|
-
const { chartConfig = {}, chartData, historicalLineColor, forecastData = [], loading, hasCombinedData, renderId, isDarkTheme, height, className, loadingComponentClassName, footerClassName, chartClassName, xAxisClassName, yAxisClassName, legendClassName, footerActions, quantileBands, quantileBandKey, xMin, xMax, yMin, yMax, autoScaleYAxis = true, formatNumber, formatDate: formatDateFn = formatDate, labelFormatter, onLegendClick, margin, chartType = 'composed', disableAnimation = false, disableLineDrawAnimation = false, showGrid = true, showAxes = true, showTooltip = true, showLegend = true, showChartAxesLegend = true, xAxisLabel, yAxisLabel, showActiveDots = true, overlayElements, hiddenSeries, includeHiddenInYScale = false, excludeLegendIds, onAnalysisSelect, onFailedAnalysisClick, containerProps, error, loadingMessage, noDataHint, noDataMessage = 'No data available', noDataStatusTone = 'muted', suppressNoDataState = false, onGridHeightChange, forecastLineStyle = 'dashed', disableHistoricalAnimation = false, onShowAll: _onShowAll, onShowOnly: _onShowOnly, maxVisibleItems, preventDeselection, legendVariant = 'default', legendWidth = 1000, legendMarginLeft = 0, } = props;
|
|
54
|
+
const { chartConfig = {}, chartData, historicalLineColor, forecastData = [], historyData, loading, hasCombinedData, renderId, isDarkTheme, height, className, loadingComponentClassName, footerClassName, chartClassName, xAxisClassName, yAxisClassName, legendClassName, footerActions, quantileBands, quantileBandKey, xMin, xMax, yMin, yMax, autoScaleYAxis = true, formatNumber, formatDate: formatDateFn = formatDate, labelFormatter, onLegendClick, margin, chartType = 'composed', disableAnimation = false, disableLineDrawAnimation = false, showGrid = true, showAxes = true, showTooltip = true, showLegend = true, showChartAxesLegend = true, xAxisLabel, yAxisLabel, showActiveDots = true, overlayElements, hiddenSeries, includeHiddenInYScale = false, excludeLegendIds, onAnalysisSelect, onFailedAnalysisClick, containerProps, error, loadingMessage, noDataHint, noDataMessage = 'No data available', noDataStatusTone = 'muted', suppressNoDataState = false, onGridHeightChange, forecastLineStyle = 'dashed', disableHistoricalAnimation = false, onShowAll: _onShowAll, onShowOnly: _onShowOnly, maxVisibleItems, preventDeselection, legendVariant = 'default', legendWidth = 1000, legendMarginLeft = 0, } = props;
|
|
54
55
|
const [shouldAnimate, setShouldAnimate] = useState(false);
|
|
55
56
|
const lineDataInitializedRef = useRef(false);
|
|
56
57
|
const rootRef = useRef(null);
|
|
@@ -186,42 +187,28 @@ const BaseChartWrapperContent = forwardRef((props, ref) => {
|
|
|
186
187
|
}
|
|
187
188
|
return (jsx(ChartTooltipContent, { active: props.active, payload: filteredPayload, label: props.label, labelFormatter: labelFormatter || defaultLabelFormatter, indicator: "dot" }));
|
|
188
189
|
};
|
|
189
|
-
//
|
|
190
|
-
//
|
|
191
|
-
//
|
|
192
|
-
const
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
if (point
|
|
196
|
-
|
|
190
|
+
// Only the line data (history and forecast_* keys) triggers the draw
|
|
191
|
+
// animation, so a change to quantile band data alone does not re-animate.
|
|
192
|
+
// The string key keeps the array's reference stable while the values are.
|
|
193
|
+
const lineData = useMemo(() => chartData.map(point => {
|
|
194
|
+
const linePoint = { date: point.date };
|
|
195
|
+
Object.keys(point).forEach(key => {
|
|
196
|
+
if ((isHistorySeriesKey(key) && point[key] !== undefined) ||
|
|
197
|
+
key.startsWith('forecast_')) {
|
|
198
|
+
linePoint[key] = point[key];
|
|
197
199
|
}
|
|
198
|
-
// Include all forecast_* properties but exclude quantile band properties
|
|
199
|
-
Object.keys(point).forEach(key => {
|
|
200
|
-
if (key.startsWith('forecast_')) {
|
|
201
|
-
linePoint[key] = point[key];
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
return linePoint;
|
|
205
|
-
});
|
|
206
|
-
// Create a stable key based on actual line data values
|
|
207
|
-
return JSON.stringify(lineData);
|
|
208
|
-
}, [chartData]);
|
|
209
|
-
const lineDataForAnimation = useMemo(() => {
|
|
210
|
-
const lineData = chartData.map(point => {
|
|
211
|
-
const linePoint = { date: point.date };
|
|
212
|
-
if (point.historical !== undefined) {
|
|
213
|
-
linePoint.historical = point.historical;
|
|
214
|
-
}
|
|
215
|
-
// Include all forecast_* properties but exclude quantile band properties
|
|
216
|
-
Object.keys(point).forEach(key => {
|
|
217
|
-
if (key.startsWith('forecast_')) {
|
|
218
|
-
linePoint[key] = point[key];
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
return linePoint;
|
|
222
200
|
});
|
|
223
|
-
return
|
|
224
|
-
}, [
|
|
201
|
+
return linePoint;
|
|
202
|
+
}), [chartData]);
|
|
203
|
+
const lineDataKey = useMemo(() => JSON.stringify(lineData), [lineData]);
|
|
204
|
+
const lineDataForAnimation = useMemo(() => lineData, [lineDataKey]);
|
|
205
|
+
const historyLegend = useMemo(() => showLegend && historyData?.length
|
|
206
|
+
? resolveHistoryLines(historyData).map(h => ({
|
|
207
|
+
value: h.name,
|
|
208
|
+
color: h.color,
|
|
209
|
+
dataKey: h.dataKey,
|
|
210
|
+
}))
|
|
211
|
+
: undefined, [historyData, showLegend]);
|
|
225
212
|
const legendPayload = useMemo(() => {
|
|
226
213
|
if (!showLegend)
|
|
227
214
|
return [];
|
|
@@ -294,11 +281,10 @@ const BaseChartWrapperContent = forwardRef((props, ref) => {
|
|
|
294
281
|
let effectiveAutoScale = autoScaleYAxis;
|
|
295
282
|
if (autoScaleYAxis !== false && yMin !== undefined && yMax !== undefined) {
|
|
296
283
|
const dataKeys = chartData.length > 0 ? Object.keys(chartData[0]) : [];
|
|
297
|
-
const
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
.filter(v => v !== null && v !== undefined);
|
|
284
|
+
const visibleHistoryKeys = historySeriesKeys(historyData).filter(k => includeHiddenInYScale || !hiddenSeries?.has(k));
|
|
285
|
+
const historicalValues = chartData
|
|
286
|
+
.flatMap(p => visibleHistoryKeys.map(k => p[k]))
|
|
287
|
+
.filter(v => v !== null && v !== undefined);
|
|
302
288
|
const forecastKeys = dataKeys.filter(k => k.startsWith('forecast_'));
|
|
303
289
|
const visibleForecastKeys = !includeHiddenInYScale && hiddenSeries
|
|
304
290
|
? forecastKeys.filter(k => !hiddenSeries.has(k))
|
|
@@ -308,10 +294,16 @@ const BaseChartWrapperContent = forwardRef((props, ref) => {
|
|
|
308
294
|
.filter(v => v !== null && v !== undefined);
|
|
309
295
|
const allLineValues = [...historicalValues, ...forecastValues];
|
|
310
296
|
if (allLineValues.length > 0) {
|
|
311
|
-
//
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
297
|
+
// A loop, not Math.min(...values): one value per row and line can
|
|
298
|
+
// exceed the engine's argument limit.
|
|
299
|
+
let dataMin = Infinity;
|
|
300
|
+
let dataMax = -Infinity;
|
|
301
|
+
for (const v of allLineValues) {
|
|
302
|
+
if (v < dataMin)
|
|
303
|
+
dataMin = v;
|
|
304
|
+
if (v > dataMax)
|
|
305
|
+
dataMax = v;
|
|
306
|
+
}
|
|
315
307
|
const explicitRange = yMax - yMin;
|
|
316
308
|
const dataRange = dataMax - dataMin;
|
|
317
309
|
const wastedSpaceRatio = (explicitRange - dataRange) / dataRange;
|
|
@@ -323,12 +315,15 @@ const BaseChartWrapperContent = forwardRef((props, ref) => {
|
|
|
323
315
|
}
|
|
324
316
|
const ChartComponent = chartType === 'line' ? LineChart : ComposedChart;
|
|
325
317
|
const defaultLabelFormatter = (v) => formatDateFn(v, true);
|
|
326
|
-
return (jsxs("div", { className: cn(S.root, !showLegend && S.noLegend, !showChartAxesLegend && S.hideChartAxesLegend, disableLineDrawAnimation && S.noLineDrawAnimation, isLoaded && S.loaded, className), ref: setRefs, children: [loading && (jsx("div", { className: S.loadingOverlay, children: jsx(Skeleton, {}) })), showGrid && (jsx(ChartContainer, { config: chartConfig, className: cn(S.gridLayer, chartClassName), style: height ? { height: `${height}px` } : undefined, children: jsxs(ChartComponent, { data: chartData, margin: margin, children: [jsx(ChartGrid, {}), showAxes && (jsx(ChartAxes, { formatDate: formatDateFn, formatNumber: formatNumber, xAxisClassName: xAxisClassName, yAxisClassName: yAxisClassName, xAxisLabel: xAxisLabel, yAxisLabel: yAxisLabel, xMin: xMin, xMax: xMax, yMin: yMin, yMax: yMax, autoScaleYAxis: effectiveAutoScale }))] }) })), jsx(ChartContainer, { config: chartConfig, className: cn(S.chartLayer, chartClassName), style: height ? { height: `${height}px` } : undefined, ...containerProps, children: jsxs(ChartComponent, { data: chartData, margin: margin, children: [showAxes && (jsx(ChartAxes, { formatDate: formatDateFn, formatNumber: formatNumber, xAxisClassName: cn(xAxisClassName), yAxisClassName: cn(yAxisClassName), xAxisLabel: xAxisLabel, yAxisLabel: yAxisLabel, xMin: xMin, xMax: xMax, yMin: yMin, yMax: yMax, autoScaleYAxis: effectiveAutoScale })), quantileBands?.[0] && (jsx(QuantileBands, { hiddenBands: hiddenSeries, quantileBandKey: quantileBandKey, animate: true, animationDuration: 150, animationBegin: 0, customBands: quantileBands, showLegend: showLegend })), jsx(ChartLines, { historicalLineColor: historicalLineColor, chartData: chartData, forecastData: forecastData, hiddenSeries: hiddenSeries, isDarkTheme: isDarkTheme, shouldAnimate: shouldAnimate, disableAnimation: disableAnimation, disableHistoricalAnimation: disableHistoricalAnimation, showLegend: showLegend, forecastLineStyle: forecastLineStyle }), showTooltip && (jsx("div", { children: jsx(Tooltip, { cursor: false, offset: TOOLTIP_OFFSET, allowEscapeViewBox: { x: false, y: false }, content: renderTooltipContent }) }))] }) }), overlayElements, jsxs("div", { className: cn(S.footer, footerClassName), children: [showLegend &&
|
|
327
|
-
(legendVariant === 'svg' ? (jsx(LegendSvg, { payload:
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
318
|
+
return (jsxs("div", { className: cn(S.root, !showLegend && S.noLegend, !showChartAxesLegend && S.hideChartAxesLegend, disableLineDrawAnimation && S.noLineDrawAnimation, isLoaded && S.loaded, className), ref: setRefs, children: [loading && (jsx("div", { className: S.loadingOverlay, children: jsx(Skeleton, {}) })), showGrid && (jsx(ChartContainer, { config: chartConfig, className: cn(S.gridLayer, chartClassName), style: height ? { height: `${height}px` } : undefined, children: jsxs(ChartComponent, { data: chartData, margin: margin, children: [jsx(ChartGrid, {}), showAxes && (jsx(ChartAxes, { formatDate: formatDateFn, formatNumber: formatNumber, xAxisClassName: xAxisClassName, yAxisClassName: yAxisClassName, xAxisLabel: xAxisLabel, yAxisLabel: yAxisLabel, xMin: xMin, xMax: xMax, yMin: yMin, yMax: yMax, autoScaleYAxis: effectiveAutoScale }))] }) })), jsx(ChartContainer, { config: chartConfig, className: cn(S.chartLayer, chartClassName), style: height ? { height: `${height}px` } : undefined, ...containerProps, children: jsxs(ChartComponent, { data: chartData, margin: margin, children: [showAxes && (jsx(ChartAxes, { formatDate: formatDateFn, formatNumber: formatNumber, xAxisClassName: cn(xAxisClassName), yAxisClassName: cn(yAxisClassName), xAxisLabel: xAxisLabel, yAxisLabel: yAxisLabel, xMin: xMin, xMax: xMax, yMin: yMin, yMax: yMax, autoScaleYAxis: effectiveAutoScale })), quantileBands?.[0] && (jsx(QuantileBands, { hiddenBands: hiddenSeries, quantileBandKey: quantileBandKey, animate: true, animationDuration: 150, animationBegin: 0, customBands: quantileBands, showLegend: showLegend })), jsx(ChartLines, { historicalLineColor: historicalLineColor, chartData: chartData, forecastData: forecastData, historyData: historyData, hiddenSeries: hiddenSeries, isDarkTheme: isDarkTheme, shouldAnimate: shouldAnimate, disableAnimation: disableAnimation, disableHistoricalAnimation: disableHistoricalAnimation, showLegend: showLegend, forecastLineStyle: forecastLineStyle }), showTooltip && (jsx("div", { children: jsx(Tooltip, { cursor: false, offset: TOOLTIP_OFFSET, allowEscapeViewBox: { x: false, y: false }, content: renderTooltipContent }) }))] }) }), overlayElements, jsxs("div", { className: cn(S.footer, footerClassName), children: [showLegend &&
|
|
319
|
+
(legendVariant === 'svg' ? (jsx(LegendSvg, { payload: [
|
|
320
|
+
...(historyLegend ?? []).map(p => ({ ...p, solid: true })),
|
|
321
|
+
...legendPayload.map(p => ({
|
|
322
|
+
value: p.value,
|
|
323
|
+
color: p.color,
|
|
324
|
+
dataKey: p.dataKey,
|
|
325
|
+
})),
|
|
326
|
+
], width: legendWidth, marginLeft: legendMarginLeft })) : (jsx(CustomChartLegend, { className: legendClassName, payload: legendPayload, histories: historyLegend, onClick: onLegendClick, hiddenSeries: hiddenSeries, onAnalysisSelect: onAnalysisSelect, onFailedAnalysisClick: onFailedAnalysisClick, maxVisibleItems: maxVisibleItems, preventDeselection: preventDeselection }))), footerActions] })] }));
|
|
332
327
|
});
|
|
333
328
|
BaseChartWrapperContent.displayName = 'BaseChartWrapperContent';
|
|
334
329
|
/**
|
|
@@ -4,12 +4,12 @@ import { useId } from 'react';
|
|
|
4
4
|
import { ChartContext } from '../Chart.context.js';
|
|
5
5
|
import { THEMES } from '../Chart.types.js';
|
|
6
6
|
import * as RechartsPrimitive from 'recharts';
|
|
7
|
-
import
|
|
7
|
+
import ChartS from '../Chart.styl.js';
|
|
8
8
|
|
|
9
9
|
function ChartContainer({ id, className, children, config, ...props }) {
|
|
10
10
|
const uniqueId = useId();
|
|
11
11
|
const chartId = `chart-${id || uniqueId.replace(/:/g, '')}`;
|
|
12
|
-
return (jsx(ChartContext.Provider, { value: { config }, children: jsxs("div", { "data-slot": "chart", "data-chart": chartId, className: cn(
|
|
12
|
+
return (jsx(ChartContext.Provider, { value: { config }, children: jsxs("div", { "data-slot": "chart", "data-chart": chartId, className: cn(ChartS.chartContainer, className), ...props, children: [jsx(ChartStyle, { id: chartId, config: config }), jsx(RechartsPrimitive.ResponsiveContainer, { children: children })] }) }));
|
|
13
13
|
}
|
|
14
14
|
const ChartStyle = ({ id, config, }) => {
|
|
15
15
|
const colorConfig = Object.entries(config).filter(([, config]) => config.theme || config.color);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { CartesianGrid } from 'recharts';
|
|
3
|
-
import
|
|
3
|
+
import ChartS from '../Chart.styl.js';
|
|
4
4
|
|
|
5
5
|
function ChartGrid() {
|
|
6
|
-
return jsx(CartesianGrid, { className:
|
|
6
|
+
return jsx(CartesianGrid, { className: ChartS.chartGrid, strokeWidth: 0.6 });
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export { ChartGrid };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import cn from 'classnames';
|
|
3
3
|
import { useChart } from '../Chart.context.js';
|
|
4
|
-
import
|
|
4
|
+
import ChartS from '../Chart.styl.js';
|
|
5
5
|
import { ChartLegendItem } from './ChartLegendItem.js';
|
|
6
6
|
|
|
7
7
|
function ChartLegendContent({ className, hideIcon = false, payload, verticalAlign = 'bottom', nameKey, }) {
|
|
@@ -9,7 +9,7 @@ function ChartLegendContent({ className, hideIcon = false, payload, verticalAlig
|
|
|
9
9
|
if (!payload?.length) {
|
|
10
10
|
return null;
|
|
11
11
|
}
|
|
12
|
-
return (jsx("div", { className: cn(
|
|
12
|
+
return (jsx("div", { className: cn(ChartS.legendContainer, verticalAlign === 'top' ? 'pb-3' : 'pt-3', className), children: payload
|
|
13
13
|
.filter(item => item.type !== 'none')
|
|
14
14
|
.map(item => (jsx(ChartLegendItem, { item: item, config: config, hideIcon: hideIcon, nameKey: nameKey }, item.value))) }));
|
|
15
15
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { getPayloadConfigFromPayload } from '../Chart.helpers.js';
|
|
3
|
-
import
|
|
3
|
+
import ChartS from '../Chart.styl.js';
|
|
4
4
|
|
|
5
5
|
function ChartLegendItem({ item, config, hideIcon, nameKey, }) {
|
|
6
6
|
const key = `${nameKey || item.dataKey || 'value'}`;
|
|
7
7
|
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
8
|
-
return (jsxs("div", { className:
|
|
8
|
+
return (jsxs("div", { className: ChartS.legendItem, children: [itemConfig?.icon && !hideIcon ? (jsx(itemConfig.icon, {})) : (jsx("div", { className: ChartS.legendIndicator, style: {
|
|
9
9
|
backgroundColor: item.color,
|
|
10
10
|
} })), itemConfig?.label] }, item.value));
|
|
11
11
|
}
|
|
@@ -3,7 +3,7 @@ import cn from 'classnames';
|
|
|
3
3
|
import { useState, useMemo, useEffect } from 'react';
|
|
4
4
|
import { useChart } from '../Chart.context.js';
|
|
5
5
|
import { normalizeTooltipPayload, getPayloadConfigFromPayload } from '../Chart.helpers.js';
|
|
6
|
-
import
|
|
6
|
+
import ChartS from '../Chart.styl.js';
|
|
7
7
|
import { ChartTooltipItem } from './ChartTooltipItem.js';
|
|
8
8
|
|
|
9
9
|
function ChartTooltipContent({ active, className, indicator = 'dot', hideLabel = false, hideIndicator = false, label, labelFormatter, labelClassName, payload, formatter, color, nameKey, labelKey, }) {
|
|
@@ -69,7 +69,7 @@ function ChartTooltipContent({ active, className, indicator = 'dot', hideLabel =
|
|
|
69
69
|
return null;
|
|
70
70
|
}
|
|
71
71
|
const nestLabel = displayPayload.length === 1 && indicator !== 'dot';
|
|
72
|
-
return (jsxs("div", { className: cn(
|
|
72
|
+
return (jsxs("div", { className: cn(ChartS.tooltipContainer, className), children: [!nestLabel ? tooltipLabel : null, jsx("div", { className: ChartS.tooltipContentGrid, children: displayPayload
|
|
73
73
|
.filter(item => item.type !== 'none')
|
|
74
74
|
.map((item, index) => (jsx(ChartTooltipItem, { item: item, index: index, config: config, indicator: indicator, hideIndicator: hideIndicator, nestLabel: nestLabel, tooltipLabel: tooltipLabel, color: color, nameKey: nameKey, formatter: formatter }, item.dataKey || index))) })] }));
|
|
75
75
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import cn from 'classnames';
|
|
3
3
|
import { getPayloadConfigFromPayload } from '../Chart.helpers.js';
|
|
4
|
-
import
|
|
4
|
+
import ChartS from '../Chart.styl.js';
|
|
5
5
|
|
|
6
6
|
function ChartTooltipItem({ item, index, config, indicator, hideIndicator, nestLabel, tooltipLabel, color, nameKey, formatter, }) {
|
|
7
7
|
const key = `${nameKey || item.name || item.dataKey || 'value'}`;
|
|
@@ -13,10 +13,10 @@ function ChartTooltipItem({ item, index, config, indicator, hideIndicator, nestL
|
|
|
13
13
|
? item.payload.fill
|
|
14
14
|
: undefined;
|
|
15
15
|
const indicatorColor = color || payloadFill || item.color;
|
|
16
|
-
return (jsx("div", { className: cn(
|
|
16
|
+
return (jsx("div", { className: cn(ChartS.tooltipItem, indicator === 'dot' && 'items-center'), children: formatter && item?.value !== undefined && item.name ? (formatter(item.value, item.name, item, index, item.payload)) : (jsxs(Fragment, { children: [itemConfig?.icon ? (jsx(itemConfig.icon, {})) : (!hideIndicator && (jsx("div", { className: cn(ChartS.tooltipIndicator, ChartS[`indicator-${indicator}`], nestLabel && ChartS.nested), style: {
|
|
17
17
|
'--color-bg': indicatorColor,
|
|
18
18
|
'--color-border': indicatorColor,
|
|
19
|
-
} }))), jsxs("div", { className: cn(
|
|
19
|
+
} }))), jsxs("div", { className: cn(ChartS.tooltipContent, nestLabel ? 'items-end' : 'items-center'), children: [jsxs("div", { className: ChartS.tooltipLabel, children: [nestLabel ? tooltipLabel : null, jsx("span", { className: cn('text-muted-foreground', ChartS.tooltipLabelText), children: itemConfig?.label || item.name })] }), item.value && (jsx("span", { className: ChartS.tooltipValue, children: Array.isArray(item.value)
|
|
20
20
|
? `${item.value[0].toLocaleString(undefined, { maximumFractionDigits: 20 })} – ${item.value[1].toLocaleString(undefined, { maximumFractionDigits: 20 })}`
|
|
21
21
|
: item.value.toLocaleString(undefined, {
|
|
22
22
|
maximumFractionDigits: 20,
|
|
@@ -16,7 +16,7 @@ function extractIdFromDataKey(dataKey) {
|
|
|
16
16
|
* Custom chart legend using AnalysesSelector (inline mode)
|
|
17
17
|
* Supports forecast icon indicator, failed badge, toggle visibility
|
|
18
18
|
*/
|
|
19
|
-
function CustomChartLegend({ payload, onClick, hiddenSeries, className, onAnalysisSelect, onFailedAnalysisClick, maxVisibleItems, preventDeselection = true, }) {
|
|
19
|
+
function CustomChartLegend({ payload, histories, onClick, hiddenSeries, className, onAnalysisSelect, onFailedAnalysisClick, maxVisibleItems, preventDeselection = true, }) {
|
|
20
20
|
const items = useMemo(() => (payload ?? []).map(p => ({
|
|
21
21
|
id: extractIdFromDataKey(p.dataKey),
|
|
22
22
|
label: p.value,
|
|
@@ -25,6 +25,11 @@ function CustomChartLegend({ payload, onClick, hiddenSeries, className, onAnalys
|
|
|
25
25
|
icon: p.icon,
|
|
26
26
|
updated_at: p.updated_at,
|
|
27
27
|
})), [payload]);
|
|
28
|
+
const historicalItems = useMemo(() => histories?.map(h => ({
|
|
29
|
+
seriesKey: h.dataKey,
|
|
30
|
+
label: h.value,
|
|
31
|
+
color: h.color,
|
|
32
|
+
})), [histories]);
|
|
28
33
|
const selectedIds = useMemo(() => {
|
|
29
34
|
if (preventDeselection) {
|
|
30
35
|
// Always keep all items selected when preventDeselection is true
|
|
@@ -56,9 +61,9 @@ function CustomChartLegend({ payload, onClick, hiddenSeries, className, onAnalys
|
|
|
56
61
|
onAnalysisSelect(id);
|
|
57
62
|
}
|
|
58
63
|
}, [onClick, payload, hiddenSeries, onAnalysisSelect]);
|
|
59
|
-
if (!items.length)
|
|
64
|
+
if (!items.length && !histories?.length)
|
|
60
65
|
return null;
|
|
61
|
-
return (jsx("div", { className: cn(S.legendContainer, className), children: jsx(AnalysesSelector, { items: items, selectedIds: selectedIds, onItemToggle: handleItemToggle, inlineMode: true, size: "xs", variant: "clear", onFailedItemClick: onFailedAnalysisClick, enableToggleHidden: true, maxVisibleItems: maxVisibleItems, preventDeselection: preventDeselection, hiddenSeries: hiddenSeries ?? new Set(), onToggleSeries: handleToggleSeriesVisibility }) }));
|
|
66
|
+
return (jsx("div", { className: cn(S.legendContainer, className), children: jsx(AnalysesSelector, { items: items, selectedIds: selectedIds, onItemToggle: handleItemToggle, inlineMode: true, size: "xs", variant: "clear", onFailedItemClick: onFailedAnalysisClick, enableToggleHidden: true, maxVisibleItems: maxVisibleItems, preventDeselection: preventDeselection, hiddenSeries: hiddenSeries ?? new Set(), historicalItems: historicalItems, onToggleSeries: handleToggleSeriesVisibility }) }));
|
|
62
67
|
}
|
|
63
68
|
|
|
64
69
|
export { CustomChartLegend };
|
|
@@ -13,7 +13,7 @@ function LegendSvg({ payload, width, marginLeft = 0 }) {
|
|
|
13
13
|
items.push({ x, item });
|
|
14
14
|
x += ICON_WIDTH + ITEM_GAP + item.value.length * FONT_SIZE * 0.6 + ITEM_GAP;
|
|
15
15
|
});
|
|
16
|
-
return (jsx("svg", { width: width, height: ROW_HEIGHT, viewBox: `0 0 ${Math.max(width, x)} ${ROW_HEIGHT}`, style: { display: 'block' }, children: items.map(({ x: itemX, item }) => (jsxs("g", { transform: `translate(${itemX}, 0)`, children: [jsx("line", { x1: 0, y1: ROW_HEIGHT / 2, x2: ICON_WIDTH, y2: ROW_HEIGHT / 2, stroke: item.color, strokeWidth: 2, strokeDasharray:
|
|
16
|
+
return (jsx("svg", { width: width, height: ROW_HEIGHT, viewBox: `0 0 ${Math.max(width, x)} ${ROW_HEIGHT}`, style: { display: 'block' }, children: items.map(({ x: itemX, item }) => (jsxs("g", { transform: `translate(${itemX}, 0)`, children: [jsx("line", { x1: 0, y1: ROW_HEIGHT / 2, x2: ICON_WIDTH, y2: ROW_HEIGHT / 2, stroke: item.color, strokeWidth: 2, strokeDasharray: item.solid ? undefined : '3 3' }), jsx("circle", { cx: 20, cy: ROW_HEIGHT / 2, r: 3, fill: item.color }), jsx("text", { x: ICON_WIDTH + ITEM_GAP, y: ROW_HEIGHT / 2, dy: "0.35em", fontSize: FONT_SIZE, fill: "#333333", children: item.value })] }, item.dataKey))) }));
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export { LegendSvg };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { isHistorySeriesKey } from './chartHistories.js';
|
|
2
|
+
|
|
2
3
|
// Find pin position for a specific date in the current filtered data
|
|
3
4
|
const findPinPositionForDate = (targetDate, filteredData) => {
|
|
4
5
|
if (!filteredData.length)
|
|
@@ -83,11 +84,21 @@ function hasPlottableChartSeriesValue(item) {
|
|
|
83
84
|
}
|
|
84
85
|
/**
|
|
85
86
|
* Row counts toward the "end" of the window when anchoring the time range to a
|
|
86
|
-
* selected forecast (
|
|
87
|
+
* selected forecast (the history it joins + that analysis line / quantiles).
|
|
88
|
+
* `historyKey`: that history's data key, null for none, undefined for any.
|
|
87
89
|
*/
|
|
88
|
-
function rowContributesToAnchoredTimeRange(item, analysisId) {
|
|
89
|
-
if (
|
|
90
|
-
|
|
90
|
+
function rowContributesToAnchoredTimeRange(item, analysisId, historyKey) {
|
|
91
|
+
if (historyKey !== undefined) {
|
|
92
|
+
if (historyKey !== null && isPlottableNumber(item[historyKey])) {
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
for (const key of Object.keys(item)) {
|
|
98
|
+
if (isHistorySeriesKey(key) && isPlottableNumber(item[key])) {
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
91
102
|
}
|
|
92
103
|
const forecastKey = `forecast_${analysisId}`;
|
|
93
104
|
if (isPlottableNumber(item[forecastKey])) {
|
|
@@ -108,7 +119,7 @@ function computeLatestPlottableDate(data, options) {
|
|
|
108
119
|
if (!item.date)
|
|
109
120
|
return null;
|
|
110
121
|
if (useAnchor && anchorId != null) {
|
|
111
|
-
if (!rowContributesToAnchoredTimeRange(item, anchorId)) {
|
|
122
|
+
if (!rowContributesToAnchoredTimeRange(item, anchorId, options?.anchorHistoryKey)) {
|
|
112
123
|
return null;
|
|
113
124
|
}
|
|
114
125
|
}
|