@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
|
@@ -8,6 +8,11 @@ export interface AnalysesSelectorItem {
|
|
|
8
8
|
icon?: ReactNode;
|
|
9
9
|
updated_at?: string;
|
|
10
10
|
}
|
|
11
|
+
export interface AnalysesSelectorHistoricalItem {
|
|
12
|
+
seriesKey: string;
|
|
13
|
+
label: string;
|
|
14
|
+
color?: string;
|
|
15
|
+
}
|
|
11
16
|
export interface AnalysesSelectorProps {
|
|
12
17
|
items: AnalysesSelectorItem[];
|
|
13
18
|
/** Single id, set, or array. Omit or `undefined` = nothing selected (Select falls back to first item for display). */
|
|
@@ -25,6 +30,13 @@ export interface AnalysesSelectorProps {
|
|
|
25
30
|
onFailedItemClick?: (id: number) => void;
|
|
26
31
|
/** Show historical item as first in the list */
|
|
27
32
|
showHistorical?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Several history lines (one per product), shown in place of the single
|
|
35
|
+
* "Historical" item, each with its own colour. Like "Historical" they are
|
|
36
|
+
* shown only, not toggled. `seriesKey` is the line's data key (e.g.
|
|
37
|
+
* `historical_<id>`); the entry dims while `hiddenSeries` has it.
|
|
38
|
+
*/
|
|
39
|
+
historicalItems?: AnalysesSelectorHistoricalItem[];
|
|
28
40
|
enableToggleHidden?: boolean;
|
|
29
41
|
maxVisibleItems?: number;
|
|
30
42
|
/** When true, prevents deselection and shows maxVisibleItems inline + rest in dropdown */
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { AnalysesSelector } from './AnalysesSelector';
|
|
2
|
-
export type { AnalysesSelectorItem, AnalysesSelectorProps, } from './AnalysesSelector.types';
|
|
2
|
+
export type { AnalysesSelectorHistoricalItem, AnalysesSelectorItem, AnalysesSelectorProps, } from './AnalysesSelector.types';
|
|
@@ -2,14 +2,16 @@ import * as RechartsPrimitive from 'recharts';
|
|
|
2
2
|
import { BaseChartWrapper, type BaseChartWrapperProps } from './components/BaseChartWrapper';
|
|
3
3
|
import { ChartContainer, ChartStyle } from './components/ChartContainer';
|
|
4
4
|
import { ChartLegendContent } from './components/ChartLegendContent';
|
|
5
|
+
import { ChartPlacedTooltip, NARROW_CHART_PX } from './components/ChartPlacedTooltip';
|
|
5
6
|
import { ChartTooltipContent } from './components/ChartTooltipContent';
|
|
6
|
-
|
|
7
|
+
/** recharts' Tooltip, opening under any chart narrower than {@link NARROW_CHART_PX}. */
|
|
8
|
+
declare const ChartTooltip: typeof ChartPlacedTooltip;
|
|
7
9
|
declare const ChartLegend: import("react").MemoExoticComponent<(outsideProps: RechartsPrimitive.LegendProps) => React.ReactPortal | null>;
|
|
8
10
|
export * from './Chart.types';
|
|
9
11
|
export { ChartTooltipItem } from './components/ChartTooltipItem';
|
|
10
12
|
export { ChartLegendItem } from './components/ChartLegendItem';
|
|
11
13
|
export { CustomChartLegend } from './components/CustomChartLegend/CustomChartLegend';
|
|
12
|
-
export { ChartContainer, ChartTooltip, ChartTooltipContent, ChartLegend, ChartLegendContent, ChartStyle, BaseChartWrapper, type BaseChartWrapperProps, };
|
|
14
|
+
export { ChartContainer, ChartTooltip, ChartTooltipContent, NARROW_CHART_PX, ChartLegend, ChartLegendContent, ChartStyle, BaseChartWrapper, type BaseChartWrapperProps, };
|
|
13
15
|
export { LightweightForecastChart, type LightweightForecastChartProps, } from './lightweight/LightweightForecastChart';
|
|
14
16
|
export { ChartEmptyState, type ChartEmptyStateProps, type ChartEmptyStatusTone, } from './components/ChartEmptyState/ChartEmptyState';
|
|
15
17
|
export { ConfidenceBands } from './components/ConfidenceBands';
|
|
@@ -30,5 +30,10 @@ export type ChartTooltipContentProps = ComponentProps<'div'> & {
|
|
|
30
30
|
labelFormatter?: (label: unknown, payload: unknown[]) => ReactNode;
|
|
31
31
|
labelClassName?: string;
|
|
32
32
|
formatter?: (value: unknown, name: string, props: unknown, index: number, payload: unknown) => ReactNode;
|
|
33
|
+
/**
|
|
34
|
+
* Formats each row's number (both ends of a range row). Without it the
|
|
35
|
+
* value prints as is.
|
|
36
|
+
*/
|
|
37
|
+
valueFormatter?: (value: number) => string;
|
|
33
38
|
color?: string;
|
|
34
39
|
};
|
|
@@ -83,4 +83,11 @@ export interface QuantileBandConfig {
|
|
|
83
83
|
strokeOpacity?: number;
|
|
84
84
|
type?: 'monotone' | 'linear' | 'step' | 'stepBefore' | 'stepAfter' | 'basis' | 'natural';
|
|
85
85
|
fillPattern?: 'solid' | 'dots' | 'lines';
|
|
86
|
+
/**
|
|
87
|
+
* Fill across months with no range (default true). Read by the Recharts
|
|
88
|
+
* charts' bands (BaseChartWrapper, ChartAreaInteractive's default mode),
|
|
89
|
+
* not by LightweightForecastChart or the intervals and thresholds overlays,
|
|
90
|
+
* which build their own bands.
|
|
91
|
+
*/
|
|
92
|
+
connectNulls?: boolean;
|
|
86
93
|
}
|
|
@@ -2,6 +2,7 @@ import { ComponentProps, ReactNode } from 'react';
|
|
|
2
2
|
import type { QuantileBandConfig } from '#uilib/components/ui/Chart/chartForecastVisualization.types';
|
|
3
3
|
import { ChartDataPoint } from '#uilib/components/ui/ChartAreaInteractive/ChartAreaInteractive.types';
|
|
4
4
|
import { ForecastItemData } from '#uilib/components/ui/ChartAreaInteractive/ChartLines';
|
|
5
|
+
import { HistoryItemData } from '#uilib/components/ui/ChartAreaInteractive/chartHistories';
|
|
5
6
|
import { LegendPayload } from 'recharts/types/component/DefaultLegendContent';
|
|
6
7
|
import type { ChartConfig } from '../Chart.types';
|
|
7
8
|
import { ChartContainer } from './ChartContainer';
|
|
@@ -12,6 +13,13 @@ export interface BaseChartWrapperProps {
|
|
|
12
13
|
chartData: ChartDataPoint[];
|
|
13
14
|
historicalLineColor?: string;
|
|
14
15
|
forecastData?: ForecastItemData[];
|
|
16
|
+
/**
|
|
17
|
+
* Several history lines (one per product), each under `historical_<id>` in
|
|
18
|
+
* `chartData`, with its own colour and legend entry. Omit for the single
|
|
19
|
+
* `historical` line. With it, `historicalLineColor` does not apply: give
|
|
20
|
+
* each history its `color`.
|
|
21
|
+
*/
|
|
22
|
+
historyData?: HistoryItemData[];
|
|
15
23
|
loading: boolean;
|
|
16
24
|
hasCombinedData?: boolean;
|
|
17
25
|
isDarkTheme: boolean;
|
|
@@ -32,6 +40,19 @@ export interface BaseChartWrapperProps {
|
|
|
32
40
|
yMax?: number;
|
|
33
41
|
autoScaleYAxis?: boolean;
|
|
34
42
|
formatNumber?: (value: number) => string;
|
|
43
|
+
/**
|
|
44
|
+
* Formats the numbers in the tooltip. Without it they print as is. Not
|
|
45
|
+
* `formatNumber`, which is the axis's and often compact ("1.2k").
|
|
46
|
+
*/
|
|
47
|
+
formatTooltipValue?: (value: number) => string;
|
|
48
|
+
/** Draw history lines across months with no value (default: a gap). */
|
|
49
|
+
connectHistoryNulls?: boolean;
|
|
50
|
+
/** Draw forecast lines across months with no value (default: a gap). */
|
|
51
|
+
connectForecastNulls?: boolean;
|
|
52
|
+
/** Draw history lines over the forecast lines (default: under them). */
|
|
53
|
+
historyOnTop?: boolean;
|
|
54
|
+
/** Mark each line's last point with a dot (default: on). */
|
|
55
|
+
showEndDots?: boolean;
|
|
35
56
|
formatDate?: (value: string, detailed?: boolean) => string;
|
|
36
57
|
labelFormatter?: (value: unknown) => string;
|
|
37
58
|
onLegendClick?: (data: LegendPayload, index: number, event: any) => void;
|
|
@@ -50,6 +71,10 @@ export interface BaseChartWrapperProps {
|
|
|
50
71
|
*/
|
|
51
72
|
disableLineDrawAnimation?: boolean;
|
|
52
73
|
showGrid?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Draw the axes. Off, a hidden x-axis is kept so the tooltip still names
|
|
76
|
+
* the row's date.
|
|
77
|
+
*/
|
|
53
78
|
showAxes?: boolean;
|
|
54
79
|
showTooltip?: boolean;
|
|
55
80
|
showLegend?: boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -10,6 +10,13 @@ interface ChartAxesProps {
|
|
|
10
10
|
yMin?: number;
|
|
11
11
|
yMax?: number;
|
|
12
12
|
autoScaleYAxis?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Draw no axes. A hidden x-axis is kept, so the tooltip still names the
|
|
15
|
+
* row's date. The y-axis keeps fixed `yMin`/`yMax` (with `autoScaleYAxis`
|
|
16
|
+
* off) as its range, widened if the data goes past it; otherwise it is
|
|
17
|
+
* recharts' default, as without axes.
|
|
18
|
+
*/
|
|
19
|
+
hide?: boolean;
|
|
13
20
|
}
|
|
14
|
-
export declare function ChartAxes({ xAxisClassName, yAxisClassName, xAxisLabel, yAxisLabel, formatDate, xMin, xMax, yMin, yMax, autoScaleYAxis, }: ChartAxesProps): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export declare function ChartAxes({ xAxisClassName, yAxisClassName, xAxisLabel, yAxisLabel, formatDate, formatNumber, xMin, xMax, yMin, yMax, autoScaleYAxis, hide, }: ChartAxesProps): import("react/jsx-runtime").JSX.Element;
|
|
15
22
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type ComponentProps } from 'react';
|
|
2
|
+
import { Tooltip } from 'recharts';
|
|
3
|
+
/** Charts narrower than this open their tooltip under the chart, not over it. */
|
|
4
|
+
export declare const NARROW_CHART_PX = 500;
|
|
5
|
+
/** Gap between a narrow chart's x-axis labels and its tooltip. */
|
|
6
|
+
export declare const NARROW_TOOLTIP_GAP_PX = 4;
|
|
7
|
+
/**
|
|
8
|
+
* Set to 1 on the tooltip wrapper's style while it sits under the chart, so
|
|
9
|
+
* code that moves the wrapper itself (BaseChartWrapper) leaves it alone
|
|
10
|
+
* instead of deciding again.
|
|
11
|
+
*/
|
|
12
|
+
export declare const TOOLTIP_UNDER_VAR = "--chart-tooltip-under";
|
|
13
|
+
/** Whether a chart this wide opens its tooltip under itself. */
|
|
14
|
+
export declare function opensTooltipUnder(chartWidth: number | undefined): boolean;
|
|
15
|
+
/** Whether ChartPlacedTooltip put this tooltip wrapper under its chart. */
|
|
16
|
+
export declare function isTooltipUnder(wrapper: HTMLElement): boolean;
|
|
17
|
+
type ChartPlacedTooltipProps = ComponentProps<typeof Tooltip>;
|
|
18
|
+
/**
|
|
19
|
+
* A recharts Tooltip that, on a chart narrower than {@link NARROW_CHART_PX},
|
|
20
|
+
* sits under the chart instead of over the lines, starting right under the
|
|
21
|
+
* x-axis labels (the chart's bottom margin is left out), so a small chart stays
|
|
22
|
+
* readable while it is hovered. It may then cover what follows the chart, be
|
|
23
|
+
* clipped by a parent that hides overflow, or run past the page edge; that is
|
|
24
|
+
* accepted. Under a chart it does not slide (no transition, whatever
|
|
25
|
+
* `wrapperStyle` says), and while no point is hovered it takes no room
|
|
26
|
+
* (`display: none`), so it never grows a scrolling parent. A caller's
|
|
27
|
+
* `position.x` and `position.y` each win, as does `isAnimationActive`. With
|
|
28
|
+
* `portal`, recharts places nothing, so neither does this.
|
|
29
|
+
*/
|
|
30
|
+
export declare function ChartPlacedTooltip(props: ChartPlacedTooltipProps): import("react/jsx-runtime").JSX.Element;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ChartTooltipContentProps } from '#uilib/components/ui/Chart/Chart.types';
|
|
2
|
-
export declare function ChartTooltipContent({ active, className, indicator, hideLabel, hideIndicator, label, labelFormatter, labelClassName, payload, formatter, color, nameKey, labelKey, }: ChartTooltipContentProps): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare function ChartTooltipContent({ active, className, indicator, hideLabel, hideIndicator, label, labelFormatter, labelClassName, payload, formatter, valueFormatter, color, nameKey, labelKey, }: ChartTooltipContentProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -12,6 +12,7 @@ type ChartTooltipItemProps = {
|
|
|
12
12
|
color?: string;
|
|
13
13
|
nameKey?: string;
|
|
14
14
|
formatter?: (value: unknown, name: string, props: unknown, index: number, payload: unknown) => ReactNode;
|
|
15
|
+
valueFormatter?: (value: number) => string;
|
|
15
16
|
};
|
|
16
|
-
export declare function ChartTooltipItem({ item, index, config, indicator, hideIndicator, nestLabel, tooltipLabel, color, nameKey, formatter, }: ChartTooltipItemProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare function ChartTooltipItem({ item, index, config, indicator, hideIndicator, nestLabel, tooltipLabel, color, nameKey, formatter, valueFormatter, }: ChartTooltipItemProps): import("react/jsx-runtime").JSX.Element;
|
|
17
18
|
export {};
|
package/dist/esm/types/src/components/ui/Chart/components/CustomChartLegend/CustomChartLegend.d.ts
CHANGED
|
@@ -7,8 +7,15 @@ interface CustomChartLegendPayloadItem {
|
|
|
7
7
|
dimmed?: boolean;
|
|
8
8
|
updated_at?: string;
|
|
9
9
|
}
|
|
10
|
+
interface CustomChartLegendHistoryItem {
|
|
11
|
+
value: string;
|
|
12
|
+
color: string;
|
|
13
|
+
dataKey: string;
|
|
14
|
+
}
|
|
10
15
|
interface CustomChartLegendProps {
|
|
11
16
|
payload?: CustomChartLegendPayloadItem[];
|
|
17
|
+
/** Several history lines, shown in place of the single "Historical" entry. */
|
|
18
|
+
histories?: CustomChartLegendHistoryItem[];
|
|
12
19
|
onClick?: (data: any, index: number, event: any) => void;
|
|
13
20
|
className?: string;
|
|
14
21
|
wrapperStyle?: React.CSSProperties;
|
|
@@ -27,5 +34,5 @@ interface CustomChartLegendProps {
|
|
|
27
34
|
* Custom chart legend using AnalysesSelector (inline mode)
|
|
28
35
|
* Supports forecast icon indicator, failed badge, toggle visibility
|
|
29
36
|
*/
|
|
30
|
-
export declare function CustomChartLegend({ payload, onClick, hiddenSeries, className, onAnalysisSelect, onFailedAnalysisClick, maxVisibleItems, preventDeselection, }: CustomChartLegendProps): import("react/jsx-runtime").JSX.Element;
|
|
37
|
+
export declare function CustomChartLegend({ payload, histories, onClick, hiddenSeries, className, onAnalysisSelect, onFailedAnalysisClick, maxVisibleItems, preventDeselection, }: CustomChartLegendProps): import("react/jsx-runtime").JSX.Element;
|
|
31
38
|
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ChartAreaInteractiveProps } from './ChartAreaInteractive.types';
|
|
2
2
|
export declare const chartConfig: {};
|
|
3
|
-
export declare function ChartAreaInteractive({ className, chartContainerClassName, legendClassName, xAxisClassName, yAxisClassName, timeRange, onTimeRangeChange, pinMonth, onPinMonthChange, onPreviewMonthChange, chartData, forecastData, error, loading, isDarkTheme, footerActions, mode, selectedForecast, upperQuantiles, lowerQuantiles, selectedLowerQuantile, selectedUpperQuantile, onLowerQuantileChange, onUpperQuantileChange, lowerThreshold, upperThreshold, onLowerThresholdChange, onUpperThresholdChange, discreteThresholdValues, headerActions, excludeLegendIds, loadingAnalyses, onLegendClick, onAnalysisSelect, disableTimeRangeSelector, enableTimeRangeBrush, forecastLineStyle, selectedAnalysisId, chartRenderId, toggleLegendSeries, ensureAnalysisSeriesVisible, overlayForecastData, hiddenSeries, disableForecastHistoricalBridge, overlayElements: overlayElementsProp, ...restProps }: ChartAreaInteractiveProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare function ChartAreaInteractive({ className, chartContainerClassName, legendClassName, xAxisClassName, yAxisClassName, timeRange, onTimeRangeChange, pinMonth, onPinMonthChange, onPreviewMonthChange, chartData, forecastData, historyData, error, loading, isDarkTheme, footerActions, mode, selectedForecast, upperQuantiles, lowerQuantiles, selectedLowerQuantile, selectedUpperQuantile, onLowerQuantileChange, onUpperQuantileChange, lowerThreshold, upperThreshold, onLowerThresholdChange, onUpperThresholdChange, discreteThresholdValues, headerActions, excludeLegendIds, loadingAnalyses, onLegendClick, onAnalysisSelect, disableTimeRangeSelector, enableTimeRangeBrush, forecastLineStyle, selectedAnalysisId, chartRenderId, toggleLegendSeries, ensureAnalysisSeriesVisible, overlayForecastData, hiddenSeries, disableForecastHistoricalBridge, overlayElements: overlayElementsProp, ...restProps }: ChartAreaInteractiveProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/esm/types/src/components/ui/ChartAreaInteractive/ChartAreaInteractive.helpers.d.ts
CHANGED
|
@@ -20,6 +20,11 @@ export type FilterDataForTimeRangeOptions = {
|
|
|
20
20
|
/** When set (e.g. selected forecast on Forecast tab), the window ends at the
|
|
21
21
|
* latest point that has shared historical or that analysis — not at another run. */
|
|
22
22
|
endDateAnchorAnalysisId?: number | null;
|
|
23
|
+
/**
|
|
24
|
+
* The history line that anchored forecast joins (`historical`,
|
|
25
|
+
* `historical_<id>`), or null for none. Omitted: any history line counts.
|
|
26
|
+
*/
|
|
27
|
+
anchorHistoryKey?: string | null;
|
|
23
28
|
};
|
|
24
29
|
export declare const filterDataForTimeRange: (data: ChartDataPoint[], currentTimeRange: string, options?: FilterDataForTimeRangeOptions) => ChartDataPoint[];
|
|
25
30
|
export declare const shortDateFormatter: (value: string) => string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ChartDataPoint } from './ChartAreaInteractive.types';
|
|
2
|
+
import { HistoryItemData } from './chartHistories';
|
|
2
3
|
export interface LineConfig {
|
|
3
4
|
dataKey: string;
|
|
4
5
|
color: string;
|
|
@@ -13,6 +14,11 @@ export type ForecastItemData = {
|
|
|
13
14
|
tooltip?: string;
|
|
14
15
|
dimmed?: boolean;
|
|
15
16
|
updated_at?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Id of the history (`historyData`) this forecast continues. With several
|
|
19
|
+
* histories, a forecast joins one only when this names it.
|
|
20
|
+
*/
|
|
21
|
+
continues?: string | number;
|
|
16
22
|
};
|
|
17
23
|
export type Dot = {
|
|
18
24
|
x: number;
|
|
@@ -32,11 +38,23 @@ export declare const FORECAST_COLORS_MAP: {
|
|
|
32
38
|
export declare const FORECAST_LINE_COLORS: string[];
|
|
33
39
|
export declare const getForecastColor: (index: number) => string;
|
|
34
40
|
export declare const getForecastQuantileBandColor: (index: number) => any;
|
|
41
|
+
/** A history line as drawn: data key, label and colour with defaults applied. */
|
|
42
|
+
export type HistoryLine = {
|
|
43
|
+
dataKey: string;
|
|
44
|
+
name: string;
|
|
45
|
+
color: string;
|
|
46
|
+
};
|
|
47
|
+
/** Default colour of the history at `index`: the forecast palette from its far end. */
|
|
48
|
+
export declare function getHistoryColor(index: number): string;
|
|
49
|
+
/** `historyData` with the defaults applied, in order (empty without it). */
|
|
50
|
+
export declare function resolveHistoryLines(histories?: HistoryItemData[]): HistoryLine[];
|
|
35
51
|
/** Same tint logic as intervals/threshold overlays: band fill follows forecast line hex when known. */
|
|
36
52
|
export declare function resolveQuantileBandFillForForecastLine(lineColor: string, forecastIndex: number): string;
|
|
37
|
-
export declare const ChartLines: import("react").MemoExoticComponent<({ chartData, forecastData, hiddenSeries, isDarkTheme, shouldAnimate, historicalLineColor, showLegend, forecastLineStyle, disableAnimation, disableHistoricalAnimation, }: {
|
|
53
|
+
export declare const ChartLines: import("react").MemoExoticComponent<({ chartData, forecastData, historyData, hiddenSeries, isDarkTheme, shouldAnimate, historicalLineColor, showLegend, forecastLineStyle, disableAnimation, disableHistoricalAnimation, connectHistoryNulls, connectForecastNulls, historyOnTop, showEndDots, }: {
|
|
38
54
|
chartData: ChartDataPoint[];
|
|
39
55
|
forecastData?: ForecastItemData[];
|
|
56
|
+
/** Several history lines (one per product). Omit for the single `historical` line. */
|
|
57
|
+
historyData?: HistoryItemData[];
|
|
40
58
|
hiddenSeries?: Set<string>;
|
|
41
59
|
isDarkTheme: boolean;
|
|
42
60
|
shouldAnimate?: boolean;
|
|
@@ -45,4 +63,15 @@ export declare const ChartLines: import("react").MemoExoticComponent<({ chartDat
|
|
|
45
63
|
forecastLineStyle?: "dashed" | "solid";
|
|
46
64
|
disableAnimation?: boolean;
|
|
47
65
|
disableHistoricalAnimation?: boolean;
|
|
66
|
+
/** Draw each history line across months it has no value for. */
|
|
67
|
+
connectHistoryNulls?: boolean;
|
|
68
|
+
/** Draw each forecast line across months it has no value for. */
|
|
69
|
+
connectForecastNulls?: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Draw the history lines after the forecast lines, over them (for many
|
|
72
|
+
* faint forecasts that would otherwise cover the history).
|
|
73
|
+
*/
|
|
74
|
+
historyOnTop?: boolean;
|
|
75
|
+
/** Mark each line's last point with a dot (default: on). */
|
|
76
|
+
showEndDots?: boolean;
|
|
48
77
|
}) => import("react/jsx-runtime").JSX.Element>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Several history lines in one chart (one per product).
|
|
3
|
+
*
|
|
4
|
+
* Without `historyData` a chart has one history line under the `historical`
|
|
5
|
+
* key, and every forecast joins it. With `historyData`, each history has its
|
|
6
|
+
* own line under `historical_<id>`, and a forecast joins a history only when
|
|
7
|
+
* it can say which one: its `continues` names the history, or the chart has
|
|
8
|
+
* exactly one. Otherwise the forecast starts on its own first point.
|
|
9
|
+
*/
|
|
10
|
+
/** The single history line's key, when the chart has no `historyData`. */
|
|
11
|
+
export declare const HISTORY_SERIES_KEY = "historical";
|
|
12
|
+
export type HistoryItemData = {
|
|
13
|
+
/** Unique within the chart. The line's data key is `historical_<id>`. */
|
|
14
|
+
id: string | number;
|
|
15
|
+
/** Legend and tooltip label. Defaults to the id (also when empty). */
|
|
16
|
+
name?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Line colour. Defaults to the forecast palette taken from its far end, so
|
|
19
|
+
* histories and forecasts differ while there are 8 lines or fewer (the
|
|
20
|
+
* palette's size). To pair a product's history and forecast, pass the same
|
|
21
|
+
* colour to both.
|
|
22
|
+
*/
|
|
23
|
+
color?: string;
|
|
24
|
+
};
|
|
25
|
+
/** Data key of one history line in `chartData` rows. */
|
|
26
|
+
export declare function historySeriesKey(id: string | number): string;
|
|
27
|
+
/** True for `historical` and for every `historical_<id>` key. */
|
|
28
|
+
export declare function isHistorySeriesKey(key: string): boolean;
|
|
29
|
+
/** The data keys of the chart's history lines, in order. */
|
|
30
|
+
export declare function historySeriesKeys(histories?: HistoryItemData[]): string[];
|
|
31
|
+
/**
|
|
32
|
+
* The history line a forecast joins, or null when it joins none.
|
|
33
|
+
*
|
|
34
|
+
* - No `historyData`: the single `historical` line, as before.
|
|
35
|
+
* - `continues` set: that history, or none when no history has that id.
|
|
36
|
+
* - Otherwise: the only history when there is exactly one, else none.
|
|
37
|
+
*/
|
|
38
|
+
export declare function forecastHistoryKey(forecast: {
|
|
39
|
+
continues?: string | number;
|
|
40
|
+
} | undefined, histories?: HistoryItemData[]): string | null;
|
|
@@ -2,4 +2,5 @@ export * from './ChartAreaInteractive';
|
|
|
2
2
|
export { DRAG_TIME_RANGE_PREFIX, encodeDragTimeRange, filterDataForTimeRange, findPinPositionForDate, isAnalysisDone, isAnalysisFailed, isAnalysisNotFailed, isTimeRangePreset, longDateFormatter, parseDragTimeRange, shortDateFormatter, type FilterDataForTimeRangeOptions, type TimeRangePreset, } from './ChartAreaInteractive.helpers';
|
|
3
3
|
export * from './ChartAreaInteractive.types';
|
|
4
4
|
export * from './ChartLines';
|
|
5
|
+
export * from './chartHistories';
|
|
5
6
|
export type { OverlayMode } from './ChartAreaInteractive.types';
|
|
@@ -10,6 +10,11 @@ interface UseChartYRangeOptions {
|
|
|
10
10
|
export interface CalculateChartYRangeOptions {
|
|
11
11
|
excludeQuantileBands: boolean;
|
|
12
12
|
forecastId?: number;
|
|
13
|
+
/**
|
|
14
|
+
* With `forecastId`: the history line that forecast joins (null: none).
|
|
15
|
+
* Other history lines are left out. Omitted: every history line counts.
|
|
16
|
+
*/
|
|
17
|
+
forecastHistoryKey?: string | null;
|
|
13
18
|
hiddenSeries?: Set<string>;
|
|
14
19
|
includeHiddenInYScale?: boolean;
|
|
15
20
|
}
|
|
@@ -18,7 +23,7 @@ export interface CalculateChartYRangeOptions {
|
|
|
18
23
|
*/
|
|
19
24
|
export declare function isKeyExcludedFromYScale(key: string, hiddenSeries?: Set<string>): boolean;
|
|
20
25
|
/** Pure Y-range calculation from chart data points. */
|
|
21
|
-
export declare function calculateChartYRange(dataToUse: ChartDataPoint[], { excludeQuantileBands, forecastId, hiddenSeries, includeHiddenInYScale, }: CalculateChartYRangeOptions): {
|
|
26
|
+
export declare function calculateChartYRange(dataToUse: ChartDataPoint[], { excludeQuantileBands, forecastId, forecastHistoryKey, hiddenSeries, includeHiddenInYScale, }: CalculateChartYRangeOptions): {
|
|
22
27
|
yMin: number;
|
|
23
28
|
yMax: number;
|
|
24
29
|
};
|
|
@@ -13,4 +13,4 @@ export interface PageXScrollProps extends Omit<React.ComponentProps<typeof Scrol
|
|
|
13
13
|
};
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
|
-
export declare function PageXScroll({ children, className, innerClassName, scrollbarClassName, fullWidth, size, scrollbarOffset, ...props }: PageXScrollProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export declare function PageXScroll({ children, className, innerClassName, scrollbarClassName, fullWidth, size, scrollbarOffset, onInnerRef, ...props }: PageXScrollProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { StackedAreaChartDatum } from './StackedAreaChart.types';
|
|
2
|
+
/** Data key of the margin layer. Prefixed so it cannot clash with a layer key. */
|
|
3
|
+
export declare const MARGIN_KEY = "__margin";
|
|
4
|
+
/** 1 when a row from {@link stackRows} has a value for any stacked layer, else 0. */
|
|
5
|
+
export declare const COST_KNOWN_KEY = "__costKnown";
|
|
6
|
+
/** Sum of the layers on a row; a missing value counts as 0. */
|
|
7
|
+
export declare function layersTotal(row: StackedAreaChartDatum, layerKeys: readonly string[]): number;
|
|
8
|
+
/**
|
|
9
|
+
* Rows ready to stack: every missing layer value becomes 0, and the margin
|
|
10
|
+
* layer (`MARGIN_KEY`) is `pct` percent of the total of `totalKeys` (the
|
|
11
|
+
* layers that are drawn; all layers by default). Without a positive `pct`
|
|
12
|
+
* the margin key is 0, so the layer can stay mounted. `COST_KNOWN_KEY` says
|
|
13
|
+
* whether any of `totalKeys` had a value, so a row with no cost at all is
|
|
14
|
+
* not compared as a cost of 0.
|
|
15
|
+
*/
|
|
16
|
+
export declare function stackRows(rows: readonly StackedAreaChartDatum[], layerKeys: readonly string[], marginPct?: number | null, totalKeys?: readonly string[]): StackedAreaChartDatum[];
|
|
17
|
+
/**
|
|
18
|
+
* Each layer's share of the total, in whole percent, at the last row where
|
|
19
|
+
* every layer has a value and the total is above zero; when no row is
|
|
20
|
+
* complete, at the last row with a total. A negative value counts as 0.
|
|
21
|
+
* Rounded by largest remainder, so the shares add up to 100. All zeros when
|
|
22
|
+
* no row has a total.
|
|
23
|
+
*/
|
|
24
|
+
export declare function stackWeights(rows: readonly StackedAreaChartDatum[], layerKeys: readonly string[]): Record<string, number>;
|
|
25
|
+
export type CompareZone = {
|
|
26
|
+
x1: string | number;
|
|
27
|
+
x2: string | number;
|
|
28
|
+
kind: 'above' | 'below';
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* The x ranges where the compare line is above or below the stacked total
|
|
32
|
+
* (the given layers plus the margin on rows from {@link stackRows}). Gaps in
|
|
33
|
+
* the compare line are bridged as the line is drawn; a row with no cost is
|
|
34
|
+
* on neither side. Each run of rows on one side becomes a range from its first
|
|
35
|
+
* row to the row after it (where the side changes), so adjacent ranges meet
|
|
36
|
+
* on a row; a row where the line touches the stack starts the next range.
|
|
37
|
+
* Ranges are whole rows: a crossing between two rows shows at the next, and a
|
|
38
|
+
* run of one row with no compared row after it has no width and is left out.
|
|
39
|
+
* Meant for a point-scale x axis, where a range starts and ends on its rows.
|
|
40
|
+
*/
|
|
41
|
+
export declare function compareZones(rows: readonly StackedAreaChartDatum[], xKey: string, layerKeys: readonly string[], compareKey: string): CompareZone[];
|
|
42
|
+
/**
|
|
43
|
+
* One zone per row on the side the compare line is on (x1 === x2), for a
|
|
44
|
+
* chart that draws each row as its own bar.
|
|
45
|
+
*/
|
|
46
|
+
export declare function compareRowZones(rows: readonly StackedAreaChartDatum[], xKey: string, layerKeys: readonly string[], compareKey: string): CompareZone[];
|
|
47
|
+
/**
|
|
48
|
+
* A value axis from 0 for a top value: at most `maxIntervals` steps of
|
|
49
|
+
* 1, 2, 2.5 or 5 × 10ⁿ, with a little headroom above the top. Small changes
|
|
50
|
+
* in the top (a margin being typed) move the axis by one step at most,
|
|
51
|
+
* instead of doubling it the way automatic rounding can.
|
|
52
|
+
*/
|
|
53
|
+
export declare function valueAxis(top: number, maxIntervals?: number, headroom?: number): {
|
|
54
|
+
max: number;
|
|
55
|
+
ticks: number[];
|
|
56
|
+
};
|
|
57
|
+
/** The highest stacked total (layers plus margin) or line value on any row. */
|
|
58
|
+
export declare function chartTop(rows: readonly StackedAreaChartDatum[], layerKeys: readonly string[], lineKeys: readonly string[]): number;
|
|
59
|
+
/**
|
|
60
|
+
* The x value of the first row in each year, when x values are date strings
|
|
61
|
+
* (`YYYY` or `YYYY-…`) and span at least `minYears` years; otherwise undefined.
|
|
62
|
+
*/
|
|
63
|
+
export declare function yearTicks(rows: readonly StackedAreaChartDatum[], xKey: string, minYears?: number): Array<string | number> | undefined;
|
|
64
|
+
/** The year of a year tick's x value, or the value as text. */
|
|
65
|
+
export declare function yearLabel(x: string | number): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ChartConfig } from '#uilib/components/ui/Chart';
|
|
2
|
+
export type TooltipRow = {
|
|
3
|
+
dataKey?: unknown;
|
|
4
|
+
name?: unknown;
|
|
5
|
+
value?: unknown;
|
|
6
|
+
color?: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Tooltip rows in series order, showing real zeros, and colouring each row
|
|
10
|
+
* from the chart config (an area's own colour is its white stack stroke).
|
|
11
|
+
*/
|
|
12
|
+
export declare function StackedTooltip({ active, payload, label, config, valueFormatter, labelFormatter, }: {
|
|
13
|
+
active?: boolean;
|
|
14
|
+
payload?: ReadonlyArray<TooltipRow>;
|
|
15
|
+
label?: unknown;
|
|
16
|
+
config: ChartConfig;
|
|
17
|
+
valueFormatter?: (value: number) => string;
|
|
18
|
+
labelFormatter?: (value: string | number) => string;
|
|
19
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export type StackedAreaChartDatum = Record<string, string | number | null | undefined>;
|
|
3
|
+
export interface StackedAreaChartLayer {
|
|
4
|
+
/** Data key of the layer in each datum. A value that is not a number stacks as 0. */
|
|
5
|
+
key: string;
|
|
6
|
+
/** Legend and tooltip label; falls back to the key. */
|
|
7
|
+
label?: ReactNode;
|
|
8
|
+
/** CSS colour; falls back to the built-in series palette. */
|
|
9
|
+
color?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface StackedAreaChartOverlay {
|
|
12
|
+
/** Data key of the line in each datum. Gaps are bridged. */
|
|
13
|
+
key: string;
|
|
14
|
+
/** Legend and tooltip label; falls back to the key. */
|
|
15
|
+
label?: ReactNode;
|
|
16
|
+
/** CSS colour; falls back to the foreground colour. */
|
|
17
|
+
color?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Shade the x ranges where this line is above or below the stacked total
|
|
20
|
+
* (the visible layers plus the margin), changing at rows. Hidden with the
|
|
21
|
+
* line. At most one overlay should set it; the first one that does is used.
|
|
22
|
+
*/
|
|
23
|
+
compare?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface StackedAreaChartMargin {
|
|
26
|
+
/**
|
|
27
|
+
* Margin on top of the layers, in percent of the layers' total at each x.
|
|
28
|
+
* null or 0 hides the margin layer; it stays mounted, so changing it as the
|
|
29
|
+
* user types does not redraw the chart from scratch.
|
|
30
|
+
*/
|
|
31
|
+
pct: number | null;
|
|
32
|
+
/** Legend and tooltip label; defaults to `margin <pct>%`. */
|
|
33
|
+
label?: ReactNode;
|
|
34
|
+
/** CSS colour of the margin layer. */
|
|
35
|
+
color?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface StackedAreaChartZoneLabels {
|
|
38
|
+
above: ReactNode;
|
|
39
|
+
below: ReactNode;
|
|
40
|
+
}
|
|
41
|
+
export interface StackedAreaChartProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
42
|
+
/** Rows in x order. */
|
|
43
|
+
data: StackedAreaChartDatum[];
|
|
44
|
+
/** Data key holding the x value (a date string such as `2026-01-01`, or a label). */
|
|
45
|
+
xKey: string;
|
|
46
|
+
/** Stacked layers, bottom first. */
|
|
47
|
+
layers: StackedAreaChartLayer[];
|
|
48
|
+
/** Lines drawn over the stack (e.g. prices paid). */
|
|
49
|
+
overlays?: StackedAreaChartOverlay[];
|
|
50
|
+
/** An extra layer on top of the stack, a percentage of the layers' total. */
|
|
51
|
+
margin?: StackedAreaChartMargin;
|
|
52
|
+
/**
|
|
53
|
+
* Show each visible layer's share of the total in the legend, from the last
|
|
54
|
+
* row where every visible layer has a value (or, when none has, the last
|
|
55
|
+
* row with a total).
|
|
56
|
+
*/
|
|
57
|
+
showWeights?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Label the x axis by year, one tick at the first row of each year, when
|
|
60
|
+
* the x values are dates (`YYYY…`) spanning at least three years.
|
|
61
|
+
*/
|
|
62
|
+
yearTicks?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* With fewer rows than this, the stack draws as bars (an area needs a
|
|
65
|
+
* few points to show anything). Default 3.
|
|
66
|
+
*/
|
|
67
|
+
barsBelow?: number;
|
|
68
|
+
/** Legend labels of the compare zones. */
|
|
69
|
+
zoneLabels?: StackedAreaChartZoneLabels;
|
|
70
|
+
/** Keys of hidden layers and overlays. With it, the host owns visibility. */
|
|
71
|
+
hiddenKeys?: ReadonlySet<string>;
|
|
72
|
+
/** Called with a layer or overlay key when its legend entry is clicked. */
|
|
73
|
+
onToggleKey?: (key: string) => void;
|
|
74
|
+
showLegend?: boolean;
|
|
75
|
+
showTooltip?: boolean;
|
|
76
|
+
showGrid?: boolean;
|
|
77
|
+
/** Formats numeric y-axis ticks and tooltip values. */
|
|
78
|
+
valueFormatter?: (value: number) => string;
|
|
79
|
+
/** Formats x-axis ticks (ignored for year ticks, which show the year). */
|
|
80
|
+
xTickFormatter?: (value: string | number) => string;
|
|
81
|
+
/** Formats the tooltip's x label. */
|
|
82
|
+
tooltipLabelFormatter?: (value: string | number) => string;
|
|
83
|
+
/** Fixed chart height in px; defaults to a 16:9 responsive box. */
|
|
84
|
+
height?: number;
|
|
85
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function StackedAreaChartPage(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -22,6 +22,7 @@ export * from './components/ui/Chart';
|
|
|
22
22
|
export * from './components/ui/ChartAreaInteractive';
|
|
23
23
|
export * from './components/ui/DonutChart';
|
|
24
24
|
export * from './components/ui/BarChart';
|
|
25
|
+
export * from './components/ui/StackedAreaChart';
|
|
25
26
|
export * from './components/ui/Checkbox';
|
|
26
27
|
export * from './components/ui/Confirm';
|
|
27
28
|
export * from './components/ui/DatePicker';
|
|
@@ -8,11 +8,18 @@ export type EnsureChartForecastBridgeOptions = {
|
|
|
8
8
|
forecastSeriesIds?: number[];
|
|
9
9
|
/** When true, returns `chartData` unchanged */
|
|
10
10
|
disabled?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* The history line each forecast joins, by forecast id: a data key such as
|
|
13
|
+
* `historical` or `historical_<id>`, or null to leave that forecast unjoined.
|
|
14
|
+
* Defaults to the single `historical` line for every forecast.
|
|
15
|
+
*/
|
|
16
|
+
historyKeyFor?: (forecastId: number) => string | null;
|
|
11
17
|
};
|
|
12
18
|
/**
|
|
13
19
|
* Injects `forecast_{id}` on the row before each series’ first forecast month (historical value)
|
|
14
20
|
* so dashed forecast lines meet the historical line. Matches sybilion-client bridge behavior.
|
|
15
|
-
* Never overwrites an existing forecast value on that row.
|
|
21
|
+
* Never overwrites an existing forecast value on that row. With several history lines,
|
|
22
|
+
* `historyKeyFor` says which one each forecast joins (null: none).
|
|
16
23
|
*/
|
|
17
24
|
export declare function ensureChartForecastBridge(chartData: ChartDataPoint[], options?: EnsureChartForecastBridgeOptions): ChartDataPoint[];
|
|
18
25
|
/**
|
|
@@ -20,9 +27,10 @@ export declare function ensureChartForecastBridge(chartData: ChartDataPoint[], o
|
|
|
20
27
|
*/
|
|
21
28
|
export declare function findLastValidHistoricalPoint(historical: TimeSeriesPoint[]): TimeSeriesPoint | null;
|
|
22
29
|
/**
|
|
23
|
-
* Find the last valid historical data point from ChartDataPoint array
|
|
30
|
+
* Find the last valid historical data point from ChartDataPoint array, on the
|
|
31
|
+
* single `historical` line or on the history line under `key`.
|
|
24
32
|
*/
|
|
25
|
-
export declare function findLastValidHistoricalChartPoint(historical: ChartDataPoint[]): ChartDataPoint | null;
|
|
33
|
+
export declare function findLastValidHistoricalChartPoint(historical: ChartDataPoint[], key?: string): ChartDataPoint | null;
|
|
26
34
|
/**
|
|
27
35
|
* Check if two dates are in the same month (ignoring day)
|
|
28
36
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|