@sybilion/uilib 1.7.2 → 1.8.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.
- 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.js +4 -1
- package/dist/esm/src/components/ui/Chart/Chart.styl.js +2 -2
- package/dist/esm/src/components/ui/Chart/components/BaseChartWrapper.js +74 -57
- package/dist/esm/src/components/ui/Chart/components/ChartAxes.js +8 -7
- 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/ChartPlacedTooltip.js +65 -0
- package/dist/esm/src/components/ui/Chart/components/ChartTooltipContent.js +4 -4
- package/dist/esm/src/components/ui/Chart/components/ChartTooltipItem.js +24 -8
- 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/Chart/components/QuantileBands.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 +55 -19
- 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 +28 -0
- package/dist/esm/src/components/widgets/DriverCard/DriverPerformanceChart.js +5 -25
- package/dist/esm/src/index.js +4 -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/Chart.d.ts +4 -2
- package/dist/esm/types/src/components/ui/Chart/Chart.types.d.ts +5 -0
- package/dist/esm/types/src/components/ui/Chart/chartForecastVisualization.types.d.ts +7 -0
- package/dist/esm/types/src/components/ui/Chart/components/BaseChartWrapper.d.ts +25 -0
- package/dist/esm/types/src/components/ui/Chart/components/BaseChartWrapper.test.d.ts +1 -0
- package/dist/esm/types/src/components/ui/Chart/components/ChartAxes.d.ts +8 -1
- package/dist/esm/types/src/components/ui/Chart/components/ChartAxes.test.d.ts +1 -0
- package/dist/esm/types/src/components/ui/Chart/components/ChartPlacedTooltip.d.ts +31 -0
- package/dist/esm/types/src/components/ui/Chart/components/ChartPlacedTooltip.test.d.ts +1 -0
- package/dist/esm/types/src/components/ui/Chart/components/ChartTooltipContent.d.ts +1 -1
- package/dist/esm/types/src/components/ui/Chart/components/ChartTooltipContent.test.d.ts +1 -0
- package/dist/esm/types/src/components/ui/Chart/components/ChartTooltipItem.d.ts +2 -1
- 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 +30 -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 +19 -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 +2 -2
- 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/AGENT.md +5 -0
- package/src/components/ui/Chart/Chart.tsx +7 -1
- package/src/components/ui/Chart/Chart.types.ts +5 -0
- package/src/components/ui/Chart/chartForecastVisualization.types.ts +7 -0
- package/src/components/ui/Chart/components/BaseChartWrapper.test.tsx +344 -0
- package/src/components/ui/Chart/components/BaseChartWrapper.tsx +149 -88
- package/src/components/ui/Chart/components/ChartAxes.test.tsx +49 -0
- package/src/components/ui/Chart/components/ChartAxes.tsx +36 -20
- package/src/components/ui/Chart/components/ChartPlacedTooltip.test.tsx +160 -0
- package/src/components/ui/Chart/components/ChartPlacedTooltip.tsx +93 -0
- package/src/components/ui/Chart/components/ChartTooltipContent.test.tsx +85 -0
- package/src/components/ui/Chart/components/ChartTooltipContent.tsx +2 -0
- package/src/components/ui/Chart/components/ChartTooltipItem.tsx +41 -10
- 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/Chart/components/QuantileBands.tsx +1 -1
- package/src/components/ui/ChartAreaInteractive/AGENT.md +4 -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 +151 -65
- 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 +81 -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/components/widgets/DriverCard/DriverPerformanceChart.tsx +2 -2
- 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
|
@@ -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)',
|
|
@@ -5,6 +5,8 @@ import 'classnames';
|
|
|
5
5
|
import 'react';
|
|
6
6
|
import './Chart.context.js';
|
|
7
7
|
import './Chart.styl.js';
|
|
8
|
+
import { ChartPlacedTooltip } from './components/ChartPlacedTooltip.js';
|
|
9
|
+
export { NARROW_CHART_PX } from './components/ChartPlacedTooltip.js';
|
|
8
10
|
import '../AnalysisLineIcon/AnalysisLineIcon.styl.js';
|
|
9
11
|
import 'lucide-react';
|
|
10
12
|
import '../Chip/Chip.styl.js';
|
|
@@ -25,7 +27,8 @@ import './lightweight/LightweightForecastChart.styl.js';
|
|
|
25
27
|
import './components/ChartEmptyState/ChartEmptyState.styl.js';
|
|
26
28
|
export { DEFAULT_QUANTILE_BAND_COLOR, QuantileBands } from './components/QuantileBands.js';
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
/** recharts' Tooltip, opening under any chart narrower than {@link NARROW_CHART_PX}. */
|
|
31
|
+
const ChartTooltip = ChartPlacedTooltip;
|
|
29
32
|
const ChartLegend = RechartsPrimitive.Legend;
|
|
30
33
|
|
|
31
34
|
export { ChartLegend, ChartTooltip };
|
|
@@ -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,10 +1,11 @@
|
|
|
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
|
-
import {
|
|
8
|
+
import { LineChart, ComposedChart } from 'recharts';
|
|
8
9
|
import { normalizeTooltipPayload } from '../Chart.helpers.js';
|
|
9
10
|
import { resolveChartMargin, getPlotViewBox } from '../tools/chartPlotGeometry.js';
|
|
10
11
|
import { formatDate } from '../tools/formatters.js';
|
|
@@ -13,6 +14,7 @@ import { ChartAxes } from './ChartAxes.js';
|
|
|
13
14
|
import { ChartContainer } from './ChartContainer.js';
|
|
14
15
|
import { ChartEmptyState } from './ChartEmptyState/ChartEmptyState.js';
|
|
15
16
|
import { ChartGrid } from './ChartGrid.js';
|
|
17
|
+
import { ChartPlacedTooltip, isTooltipUnder } from './ChartPlacedTooltip.js';
|
|
16
18
|
import { ChartTooltipContent } from './ChartTooltipContent.js';
|
|
17
19
|
import { CustomChartLegend } from './CustomChartLegend/CustomChartLegend.js';
|
|
18
20
|
import { LegendSvg } from './LegendSvg/LegendSvg.js';
|
|
@@ -37,6 +39,18 @@ function clampTooltipTranslate(args) {
|
|
|
37
39
|
ty = clamp(ty, minY, maxY);
|
|
38
40
|
return { x: tx, y: ty };
|
|
39
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* The tooltip slides after the cursor, unless the user asked for less motion.
|
|
44
|
+
* ChartPlacedTooltip turns this off under a narrow chart.
|
|
45
|
+
*/
|
|
46
|
+
const TOOLTIP_WRAPPER_STYLE = {
|
|
47
|
+
transition: 'transform 0.2s ease-out, opacity 0.2s ease-out',
|
|
48
|
+
};
|
|
49
|
+
function tooltipWrapperStyle() {
|
|
50
|
+
const reduceMotion = typeof window !== 'undefined' &&
|
|
51
|
+
window.matchMedia?.('(prefers-reduced-motion: reduce)').matches;
|
|
52
|
+
return reduceMotion ? undefined : TOOLTIP_WRAPPER_STYLE;
|
|
53
|
+
}
|
|
40
54
|
/**
|
|
41
55
|
* Simple loading component without hooks for better performance
|
|
42
56
|
* Rendered when chart is waiting in render queue
|
|
@@ -50,7 +64,7 @@ BaseChartWrapperLoading.displayName = 'BaseChartWrapperLoading';
|
|
|
50
64
|
* Separated to maintain hook order consistency
|
|
51
65
|
*/
|
|
52
66
|
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;
|
|
67
|
+
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, formatTooltipValue, connectHistoryNulls, connectForecastNulls, historyOnTop, showEndDots, 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
68
|
const [shouldAnimate, setShouldAnimate] = useState(false);
|
|
55
69
|
const lineDataInitializedRef = useRef(false);
|
|
56
70
|
const rootRef = useRef(null);
|
|
@@ -77,9 +91,16 @@ const BaseChartWrapperContent = forwardRef((props, ref) => {
|
|
|
77
91
|
const applyTooltipPosition = () => {
|
|
78
92
|
const wrapper = tooltipWrapperRef.current;
|
|
79
93
|
const coord = rawTooltipCoordinateRef.current;
|
|
80
|
-
|
|
94
|
+
// The chart the tooltip belongs to (with the grid on, the first chart in
|
|
95
|
+
// the root is the grid layer's).
|
|
96
|
+
const chartWrapper = wrapper?.closest('.recharts-wrapper') ??
|
|
97
|
+
rootRef.current?.querySelector('.recharts-wrapper');
|
|
81
98
|
if (!wrapper || !coord || !(chartWrapper instanceof HTMLElement))
|
|
82
99
|
return;
|
|
100
|
+
// A narrow chart's tooltip sits under it, where ChartPlacedTooltip has
|
|
101
|
+
// recharts put it. Leave it there: one writer, so it does not jump.
|
|
102
|
+
if (isTooltipUnder(wrapper))
|
|
103
|
+
return;
|
|
83
104
|
const measured = wrapper.getBoundingClientRect();
|
|
84
105
|
const width = tooltipSizeRef.current.width || measured.width;
|
|
85
106
|
const height = tooltipSizeRef.current.height || measured.height;
|
|
@@ -122,8 +143,6 @@ const BaseChartWrapperContent = forwardRef((props, ref) => {
|
|
|
122
143
|
resizeRo.observe(wrapperEl);
|
|
123
144
|
if (wrapperEl instanceof HTMLElement) {
|
|
124
145
|
tooltipWrapperRef.current = wrapperEl;
|
|
125
|
-
wrapperEl.style.transition =
|
|
126
|
-
'transform 0.2s ease-out, opacity 0.2s ease-out';
|
|
127
146
|
requestAnimationFrame(() => applyTooltipPositionRef.current());
|
|
128
147
|
}
|
|
129
148
|
};
|
|
@@ -171,7 +190,7 @@ const BaseChartWrapperContent = forwardRef((props, ref) => {
|
|
|
171
190
|
// If no valid payload items, render ChartTooltipContent with active=false and empty payload
|
|
172
191
|
// This allows ChartTooltipContent to clear its lastTooltipData state
|
|
173
192
|
if (!filteredPayload || filteredPayload.length === 0) {
|
|
174
|
-
return (jsx(ChartTooltipContent, { active: false, payload: [], label: props.label, labelFormatter: labelFormatter || defaultLabelFormatter, indicator: "dot" }));
|
|
193
|
+
return (jsx(ChartTooltipContent, { active: false, payload: [], label: props.label, labelFormatter: labelFormatter || defaultLabelFormatter, indicator: "dot", valueFormatter: formatTooltipValue }));
|
|
175
194
|
}
|
|
176
195
|
const isActive = props.active === true;
|
|
177
196
|
if (isActive && props.coordinate) {
|
|
@@ -184,44 +203,30 @@ const BaseChartWrapperContent = forwardRef((props, ref) => {
|
|
|
184
203
|
else {
|
|
185
204
|
rawTooltipCoordinateRef.current = null;
|
|
186
205
|
}
|
|
187
|
-
return (jsx(ChartTooltipContent, { active: props.active, payload: filteredPayload, label: props.label, labelFormatter: labelFormatter || defaultLabelFormatter, indicator: "dot" }));
|
|
206
|
+
return (jsx(ChartTooltipContent, { active: props.active, payload: filteredPayload, label: props.label, labelFormatter: labelFormatter || defaultLabelFormatter, indicator: "dot", valueFormatter: formatTooltipValue }));
|
|
188
207
|
};
|
|
189
|
-
//
|
|
190
|
-
//
|
|
191
|
-
//
|
|
192
|
-
const
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
if (point
|
|
196
|
-
|
|
197
|
-
|
|
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;
|
|
208
|
+
// Only the line data (history and forecast_* keys) triggers the draw
|
|
209
|
+
// animation, so a change to quantile band data alone does not re-animate.
|
|
210
|
+
// The string key keeps the array's reference stable while the values are.
|
|
211
|
+
const lineData = useMemo(() => chartData.map(point => {
|
|
212
|
+
const linePoint = { date: point.date };
|
|
213
|
+
Object.keys(point).forEach(key => {
|
|
214
|
+
if ((isHistorySeriesKey(key) && point[key] !== undefined) ||
|
|
215
|
+
key.startsWith('forecast_')) {
|
|
216
|
+
linePoint[key] = point[key];
|
|
214
217
|
}
|
|
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
218
|
});
|
|
223
|
-
return
|
|
224
|
-
}, [
|
|
219
|
+
return linePoint;
|
|
220
|
+
}), [chartData]);
|
|
221
|
+
const lineDataKey = useMemo(() => JSON.stringify(lineData), [lineData]);
|
|
222
|
+
const lineDataForAnimation = useMemo(() => lineData, [lineDataKey]);
|
|
223
|
+
const historyLegend = useMemo(() => showLegend && historyData?.length
|
|
224
|
+
? resolveHistoryLines(historyData).map(h => ({
|
|
225
|
+
value: h.name,
|
|
226
|
+
color: h.color,
|
|
227
|
+
dataKey: h.dataKey,
|
|
228
|
+
}))
|
|
229
|
+
: undefined, [historyData, showLegend]);
|
|
225
230
|
const legendPayload = useMemo(() => {
|
|
226
231
|
if (!showLegend)
|
|
227
232
|
return [];
|
|
@@ -294,11 +299,10 @@ const BaseChartWrapperContent = forwardRef((props, ref) => {
|
|
|
294
299
|
let effectiveAutoScale = autoScaleYAxis;
|
|
295
300
|
if (autoScaleYAxis !== false && yMin !== undefined && yMax !== undefined) {
|
|
296
301
|
const dataKeys = chartData.length > 0 ? Object.keys(chartData[0]) : [];
|
|
297
|
-
const
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
.filter(v => v !== null && v !== undefined);
|
|
302
|
+
const visibleHistoryKeys = historySeriesKeys(historyData).filter(k => includeHiddenInYScale || !hiddenSeries?.has(k));
|
|
303
|
+
const historicalValues = chartData
|
|
304
|
+
.flatMap(p => visibleHistoryKeys.map(k => p[k]))
|
|
305
|
+
.filter(v => v !== null && v !== undefined);
|
|
302
306
|
const forecastKeys = dataKeys.filter(k => k.startsWith('forecast_'));
|
|
303
307
|
const visibleForecastKeys = !includeHiddenInYScale && hiddenSeries
|
|
304
308
|
? forecastKeys.filter(k => !hiddenSeries.has(k))
|
|
@@ -308,10 +312,16 @@ const BaseChartWrapperContent = forwardRef((props, ref) => {
|
|
|
308
312
|
.filter(v => v !== null && v !== undefined);
|
|
309
313
|
const allLineValues = [...historicalValues, ...forecastValues];
|
|
310
314
|
if (allLineValues.length > 0) {
|
|
311
|
-
//
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
+
// A loop, not Math.min(...values): one value per row and line can
|
|
316
|
+
// exceed the engine's argument limit.
|
|
317
|
+
let dataMin = Infinity;
|
|
318
|
+
let dataMax = -Infinity;
|
|
319
|
+
for (const v of allLineValues) {
|
|
320
|
+
if (v < dataMin)
|
|
321
|
+
dataMin = v;
|
|
322
|
+
if (v > dataMax)
|
|
323
|
+
dataMax = v;
|
|
324
|
+
}
|
|
315
325
|
const explicitRange = yMax - yMin;
|
|
316
326
|
const dataRange = dataMax - dataMin;
|
|
317
327
|
const wastedSpaceRatio = (explicitRange - dataRange) / dataRange;
|
|
@@ -323,12 +333,19 @@ const BaseChartWrapperContent = forwardRef((props, ref) => {
|
|
|
323
333
|
}
|
|
324
334
|
const ChartComponent = chartType === 'line' ? LineChart : ComposedChart;
|
|
325
335
|
const defaultLabelFormatter = (v) => formatDateFn(v, true);
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
336
|
+
// The same axes in the grid layer and the chart layer, so both share one
|
|
337
|
+
// scale. Hidden when showAxes is off: the hidden x-axis still places the
|
|
338
|
+
// rows by date, so the tooltip names it.
|
|
339
|
+
const axes = (jsx(ChartAxes, { hide: !showAxes, formatDate: formatDateFn, formatNumber: formatNumber, xAxisClassName: xAxisClassName, yAxisClassName: yAxisClassName, xAxisLabel: xAxisLabel, yAxisLabel: yAxisLabel, xMin: xMin, xMax: xMax, yMin: yMin, yMax: yMax, autoScaleYAxis: effectiveAutoScale }));
|
|
340
|
+
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, {}), axes] }) })), jsx(ChartContainer, { config: chartConfig, className: cn(S.chartLayer, chartClassName), style: height ? { height: `${height}px` } : undefined, ...containerProps, children: jsxs(ChartComponent, { data: chartData, margin: margin, children: [axes, 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, connectHistoryNulls: connectHistoryNulls, connectForecastNulls: connectForecastNulls, historyOnTop: historyOnTop, showEndDots: showEndDots }), showTooltip && (jsx("div", { children: jsx(ChartPlacedTooltip, { cursor: false, offset: TOOLTIP_OFFSET, allowEscapeViewBox: { x: false, y: false }, wrapperStyle: tooltipWrapperStyle(), content: renderTooltipContent }) }))] }) }), overlayElements, jsxs("div", { className: cn(S.footer, footerClassName), children: [showLegend &&
|
|
341
|
+
(legendVariant === 'svg' ? (jsx(LegendSvg, { payload: [
|
|
342
|
+
...(historyLegend ?? []).map(p => ({ ...p, solid: true })),
|
|
343
|
+
...legendPayload.map(p => ({
|
|
344
|
+
value: p.value,
|
|
345
|
+
color: p.color,
|
|
346
|
+
dataKey: p.dataKey,
|
|
347
|
+
})),
|
|
348
|
+
], 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
349
|
});
|
|
333
350
|
BaseChartWrapperContent.displayName = 'BaseChartWrapperContent';
|
|
334
351
|
/**
|
|
@@ -4,14 +4,15 @@ import { XAxis, Label, YAxis } from 'recharts';
|
|
|
4
4
|
import { generateRoundedYTicks, formatNumber, formatYAxisNumber } from '../tools/formatters.js';
|
|
5
5
|
|
|
6
6
|
function ChartAxes({ xAxisClassName, yAxisClassName, xAxisLabel, yAxisLabel, formatDate,
|
|
7
|
-
//
|
|
8
|
-
|
|
7
|
+
// The host's number format for the y-axis ticks; uilib's compact one
|
|
8
|
+
// (K/M/B, whole numbers below 1000) without it.
|
|
9
|
+
formatNumber: formatNumber$1 = formatNumber, xMin, xMax, yMin, yMax, autoScaleYAxis = false, hide = false, }) {
|
|
9
10
|
const tickColor = 'var(--muted-foreground)';
|
|
10
11
|
// Generate rounded ticks to avoid duplicates when we have explicit domain
|
|
11
12
|
const yTicks = useMemo(() => {
|
|
12
|
-
if (yMin !== undefined && yMax !== undefined && !autoScaleYAxis) {
|
|
13
|
+
if (!hide && yMin !== undefined && yMax !== undefined && !autoScaleYAxis) {
|
|
13
14
|
const ticks = generateRoundedYTicks(yMin, yMax);
|
|
14
|
-
const formatter = formatNumber || formatYAxisNumber;
|
|
15
|
+
const formatter = formatNumber$1 || formatYAxisNumber;
|
|
15
16
|
// Group ticks by formatted value and keep the one closest to its rounded value
|
|
16
17
|
const ticksByFormatted = new Map();
|
|
17
18
|
ticks.forEach(tick => {
|
|
@@ -33,7 +34,7 @@ xMin, xMax, yMin, yMax, autoScaleYAxis = false, }) {
|
|
|
33
34
|
return Array.from(ticksByFormatted.values()).sort((a, b) => a - b);
|
|
34
35
|
}
|
|
35
36
|
return undefined;
|
|
36
|
-
}, [yMin, yMax, autoScaleYAxis, formatNumber]);
|
|
37
|
+
}, [hide, yMin, yMax, autoScaleYAxis, formatNumber$1]);
|
|
37
38
|
// Determine Y-axis domain
|
|
38
39
|
let yDomain;
|
|
39
40
|
if (autoScaleYAxis) {
|
|
@@ -45,8 +46,8 @@ xMin, xMax, yMin, yMax, autoScaleYAxis = false, }) {
|
|
|
45
46
|
else if (yMin !== undefined && yMax !== undefined) {
|
|
46
47
|
yDomain = [yMin, yMax];
|
|
47
48
|
}
|
|
48
|
-
return (jsxs(Fragment, { children: [jsx(XAxis, { className: xAxisClassName, dataKey: "date", tickLine: false, axisLine: false, tickMargin: 8, minTickGap: 32, tick: { fill: tickColor }, tickFormatter: value => formatDate(value), ...(xMin !== undefined &&
|
|
49
|
-
xMax !== undefined && { domain: [xMin, xMax] }), children: xAxisLabel && (jsx(Label, { value: xAxisLabel, position: "insideBottom", offset: -5 })) }), jsx(YAxis, { className: yAxisClassName, tickLine: false, axisLine: false, tickMargin: 8, minTickGap: 32, tick: { fill: tickColor }, tickFormatter: formatNumber, ...(yDomain && { domain: yDomain }), ...(yTicks && { ticks: yTicks }), allowDataOverflow: !autoScaleYAxis, children: yAxisLabel && (jsx(Label, { value: yAxisLabel, angle: -90, position: "insideLeft" })) })] }));
|
|
49
|
+
return (jsxs(Fragment, { children: [jsx(XAxis, { className: xAxisClassName, dataKey: "date", hide: hide, tickLine: false, axisLine: false, tickMargin: 8, minTickGap: 32, tick: { fill: tickColor }, tickFormatter: value => formatDate(value), ...(xMin !== undefined &&
|
|
50
|
+
xMax !== undefined && { domain: [xMin, xMax] }), children: xAxisLabel && (jsx(Label, { value: xAxisLabel, position: "insideBottom", offset: -5 })) }), hide && !autoScaleYAxis && yMin !== undefined && yMax !== undefined && (jsx(YAxis, { hide: true, domain: [yMin, yMax] })), !hide && (jsx(YAxis, { className: yAxisClassName, tickLine: false, axisLine: false, tickMargin: 8, minTickGap: 32, tick: { fill: tickColor }, tickFormatter: formatNumber$1, ...(yDomain && { domain: yDomain }), ...(yTicks && { ticks: yTicks }), allowDataOverflow: !autoScaleYAxis, children: yAxisLabel && (jsx(Label, { value: yAxisLabel, angle: -90, position: "insideLeft" })) }))] }));
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
export { ChartAxes };
|
|
@@ -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
|
}
|