semiotic 3.3.1 → 3.4.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/CLAUDE.md +25 -6
- package/README.md +1 -1
- package/ai/dist/mcp-server.js +104 -9
- package/ai/schema.json +42 -1
- package/ai/system-prompt.md +4 -0
- package/dist/components/Annotation.d.ts +42 -2
- package/dist/components/CategoryColors.d.ts +1 -1
- package/dist/components/ChartGrid.d.ts +1 -1
- package/dist/components/ContextLayout.d.ts +1 -1
- package/dist/components/DataSummaryContext.d.ts +1 -1
- package/dist/components/DetailsPanel.d.ts +3 -2
- package/dist/components/Legend.d.ts +2 -3
- package/dist/components/LinkedCharts.d.ts +9 -1
- package/dist/components/ThemeProvider.d.ts +1 -1
- package/dist/components/Tooltip/FlippingTooltip.d.ts +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts +4 -3
- package/dist/components/charts/geo/ChoroplethMap.d.ts +4 -4
- package/dist/components/charts/geo/DistanceCartogram.d.ts +5 -4
- package/dist/components/charts/geo/FlowMap.d.ts +4 -4
- package/dist/components/charts/geo/ProportionalSymbolMap.d.ts +4 -3
- package/dist/components/charts/index.d.ts +3 -1
- package/dist/components/charts/network/ChordDiagram.d.ts +4 -3
- package/dist/components/charts/network/CirclePack.d.ts +3 -3
- package/dist/components/charts/network/ForceDirectedGraph.d.ts +3 -2
- package/dist/components/charts/network/OrbitDiagram.d.ts +6 -5
- package/dist/components/charts/network/SankeyDiagram.d.ts +4 -3
- package/dist/components/charts/network/TreeDiagram.d.ts +3 -3
- package/dist/components/charts/network/Treemap.d.ts +3 -3
- package/dist/components/charts/ordinal/BarChart.d.ts +30 -4
- package/dist/components/charts/ordinal/BoxPlot.d.ts +4 -3
- package/dist/components/charts/ordinal/DonutChart.d.ts +4 -3
- package/dist/components/charts/ordinal/DotPlot.d.ts +13 -4
- package/dist/components/charts/ordinal/FunnelChart.d.ts +4 -3
- package/dist/components/charts/ordinal/GaugeChart.d.ts +2 -1
- package/dist/components/charts/ordinal/GroupedBarChart.d.ts +6 -5
- package/dist/components/charts/ordinal/Histogram.d.ts +4 -3
- package/dist/components/charts/ordinal/LikertChart.d.ts +8 -4
- package/dist/components/charts/ordinal/PieChart.d.ts +4 -3
- package/dist/components/charts/ordinal/RidgelinePlot.d.ts +4 -3
- package/dist/components/charts/ordinal/StackedBarChart.d.ts +6 -5
- package/dist/components/charts/ordinal/SwarmPlot.d.ts +4 -3
- package/dist/components/charts/ordinal/SwimlaneChart.d.ts +4 -3
- package/dist/components/charts/ordinal/ViolinPlot.d.ts +4 -3
- package/dist/components/charts/realtime/RealtimeHeatmap.d.ts +7 -6
- package/dist/components/charts/realtime/RealtimeHistogram.d.ts +10 -7
- package/dist/components/charts/realtime/RealtimeLineChart.d.ts +9 -6
- package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +7 -6
- package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +9 -6
- package/dist/components/charts/shared/ChartError.d.ts +1 -2
- package/dist/components/charts/shared/annotationResolvers.d.ts +4 -3
- package/dist/components/charts/shared/annotationRules.d.ts +2 -1
- package/dist/components/charts/shared/colorUtils.d.ts +4 -3
- package/dist/components/charts/shared/datumTypes.d.ts +20 -0
- package/dist/components/charts/shared/diagnoseConfig.d.ts +2 -7
- package/dist/components/charts/shared/formatUtils.d.ts +4 -2
- package/dist/components/charts/shared/hooks.d.ts +41 -24
- package/dist/components/charts/shared/legendUtils.d.ts +3 -2
- package/dist/components/charts/shared/mergeShapeStyle.d.ts +43 -0
- package/dist/components/charts/shared/networkUtils.d.ts +7 -6
- package/dist/components/charts/shared/selectionUtils.d.ts +14 -11
- package/dist/components/charts/shared/statisticalOverlays.d.ts +14 -26
- package/dist/components/charts/shared/statisticalOverlaysLazy.d.ts +2 -2
- package/dist/components/charts/shared/statsTooltip.d.ts +3 -2
- package/dist/components/charts/shared/tooltipUtils.d.ts +20 -7
- package/dist/components/charts/shared/types.d.ts +27 -19
- package/dist/components/charts/shared/useChartSetup.d.ts +15 -6
- package/dist/components/charts/shared/useLikertAggregation.d.ts +18 -7
- package/dist/components/charts/shared/useOrdinalStreaming.d.ts +3 -2
- package/dist/components/charts/shared/useResolvedSelection.d.ts +2 -0
- package/dist/components/charts/shared/useStreamingLegend.d.ts +2 -1
- package/dist/components/charts/shared/validateChartData.d.ts +2 -1
- package/dist/components/charts/shared/validateProps.d.ts +2 -8
- package/dist/components/charts/shared/withChartWrapper.d.ts +1 -1
- package/dist/components/charts/xy/AreaChart.d.ts +4 -3
- package/dist/components/charts/xy/BubbleChart.d.ts +4 -3
- package/dist/components/charts/xy/CandlestickChart.d.ts +47 -0
- package/dist/components/charts/xy/ConnectedScatterplot.d.ts +4 -3
- package/dist/components/charts/xy/Heatmap.d.ts +12 -7
- package/dist/components/charts/xy/LineChart.d.ts +4 -3
- package/dist/components/charts/xy/MinimapChart.d.ts +4 -4
- package/dist/components/charts/xy/MultiAxisLineChart.d.ts +5 -4
- package/dist/components/charts/xy/QuadrantChart.d.ts +4 -3
- package/dist/components/charts/xy/Scatterplot.d.ts +4 -3
- package/dist/components/charts/xy/ScatterplotMatrix.d.ts +3 -3
- package/dist/components/charts/xy/StackedAreaChart.d.ts +4 -3
- package/dist/components/data/transforms.d.ts +8 -7
- package/dist/components/export/chartConfig.d.ts +4 -3
- package/dist/components/geo/mergeData.d.ts +2 -1
- package/dist/components/realtime/BinAccumulator.d.ts +3 -2
- package/dist/components/realtime/renderers/types.d.ts +2 -1
- package/dist/components/realtime/renderers/waterfallRenderer.d.ts +2 -1
- package/dist/components/realtime/types.d.ts +32 -16
- package/dist/components/semiotic-geo.d.ts +4 -0
- package/dist/components/semiotic-network.d.ts +7 -0
- package/dist/components/semiotic-ordinal.d.ts +8 -0
- package/dist/components/semiotic-themes.d.ts +2 -1
- package/dist/components/semiotic-xy.d.ts +11 -0
- package/dist/components/semiotic.d.ts +3 -3
- package/dist/components/server/animatedGif.d.ts +4 -18
- package/dist/components/server/renderToStaticSVG.d.ts +6 -5
- package/dist/components/server/serverChartConfigs.d.ts +2 -10
- package/dist/components/server/staticAnnotations.d.ts +2 -1
- package/dist/components/server/staticLegend.d.ts +2 -1
- package/dist/components/store/ObservationStore.d.ts +4 -3
- package/dist/components/store/SelectionStore.d.ts +3 -8
- package/dist/components/store/ThemeStore.d.ts +34 -4
- package/dist/components/store/TooltipStore.d.ts +1 -1
- package/dist/components/store/useSelection.d.ts +6 -5
- package/dist/components/stream/AccessibleDataTable.d.ts +5 -5
- package/dist/components/stream/CanvasHitTester.d.ts +10 -4
- package/dist/components/stream/DataSourceAdapter.d.ts +19 -1
- package/dist/components/stream/FocusRing.d.ts +1 -2
- package/dist/components/stream/GeoCanvasHitTester.d.ts +1 -1
- package/dist/components/stream/GeoParticlePool.d.ts +2 -1
- package/dist/components/stream/GeoPipelineStore.d.ts +26 -7
- package/dist/components/stream/MarginalGraphics.d.ts +1 -2
- package/dist/components/stream/NetworkPipelineStore.d.ts +8 -2
- package/dist/components/stream/NetworkSVGOverlay.d.ts +4 -4
- package/dist/components/stream/OrdinalBrushOverlay.d.ts +1 -19
- package/dist/components/stream/OrdinalCanvasHitTester.d.ts +3 -1
- package/dist/components/stream/OrdinalPipelineStore.d.ts +44 -6
- package/dist/components/stream/OrdinalSVGOverlay.d.ts +6 -5
- package/dist/components/stream/ParticlePool.d.ts +4 -0
- package/dist/components/stream/PipelineStore.d.ts +80 -30
- package/dist/components/stream/SVGOverlay.d.ts +10 -10
- package/dist/components/stream/SceneGraph.d.ts +6 -5
- package/dist/components/stream/StreamGeoFrame.d.ts +2 -1
- package/dist/components/stream/StreamNetworkFrame.d.ts +2 -1
- package/dist/components/stream/StreamOrdinalFrame.d.ts +2 -1
- package/dist/components/stream/StreamXYFrame.d.ts +19 -1
- package/dist/components/stream/XYBrushOverlay.d.ts +1 -21
- package/dist/components/stream/devDataAccessWarning.d.ts +2 -11
- package/dist/components/stream/geoTypes.d.ts +32 -18
- package/dist/components/stream/hoverUtils.d.ts +14 -1
- package/dist/components/stream/layouts/hierarchySceneBuilders.d.ts +4 -3
- package/dist/components/stream/layouts/hierarchyUtils.d.ts +4 -3
- package/dist/components/stream/networkTypes.d.ts +51 -28
- package/dist/components/stream/ordinalSceneBuilders/barFunnelScene.d.ts +1 -1
- package/dist/components/stream/ordinalSceneBuilders/barScene.d.ts +2 -2
- package/dist/components/stream/ordinalSceneBuilders/connectorScene.d.ts +1 -1
- package/dist/components/stream/ordinalSceneBuilders/pointScene.d.ts +2 -2
- package/dist/components/stream/ordinalSceneBuilders/statisticalScene.d.ts +4 -4
- package/dist/components/stream/ordinalSceneBuilders/swimlaneScene.d.ts +1 -1
- package/dist/components/stream/ordinalSceneBuilders/timelineScene.d.ts +1 -1
- package/dist/components/stream/ordinalSceneBuilders/types.d.ts +9 -8
- package/dist/components/stream/ordinalTypes.d.ts +102 -29
- package/dist/components/stream/pipelineDecay.d.ts +2 -1
- package/dist/components/stream/pipelinePulse.d.ts +2 -1
- package/dist/components/stream/pipelineTransitionUtils.d.ts +21 -0
- package/dist/components/stream/pipelineTransitions.d.ts +16 -4
- package/dist/components/stream/quadtreeHitTest.d.ts +22 -0
- package/dist/components/stream/renderers/colorUtils.d.ts +20 -0
- package/dist/components/stream/renderers/resolveCSSColor.d.ts +23 -6
- package/dist/components/stream/types.d.ts +63 -8
- package/dist/components/stream/useFrame.d.ts +122 -0
- package/dist/components/stream/xySceneBuilders/areaScene.d.ts +3 -2
- package/dist/components/stream/xySceneBuilders/barScene.d.ts +2 -1
- package/dist/components/stream/xySceneBuilders/boundsScene.d.ts +2 -1
- package/dist/components/stream/xySceneBuilders/candlestickScene.d.ts +2 -1
- package/dist/components/stream/xySceneBuilders/emitPointNodes.d.ts +3 -2
- package/dist/components/stream/xySceneBuilders/heatmapScene.d.ts +2 -1
- package/dist/components/stream/xySceneBuilders/lineScene.d.ts +2 -1
- package/dist/components/stream/xySceneBuilders/mixedScene.d.ts +2 -1
- package/dist/components/stream/xySceneBuilders/pointScene.d.ts +2 -1
- package/dist/components/stream/xySceneBuilders/swarmScene.d.ts +2 -1
- package/dist/components/stream/xySceneBuilders/types.d.ts +35 -26
- package/dist/components/stream/xySceneBuilders/waterfallScene.d.ts +2 -1
- package/dist/components/types/marginType.d.ts +15 -0
- package/dist/geo.min.js +1 -1
- package/dist/geo.module.min.js +1 -1
- package/dist/network.min.js +1 -1
- package/dist/network.module.min.js +1 -1
- package/dist/ordinal.min.js +1 -1
- package/dist/ordinal.module.min.js +1 -1
- package/dist/realtime.min.js +1 -1
- package/dist/realtime.module.min.js +1 -1
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-geo.d.ts +4 -0
- package/dist/semiotic-network.d.ts +7 -0
- package/dist/semiotic-ordinal.d.ts +8 -0
- package/dist/semiotic-statisticalOverlays-Ckd_jM8z.js +1 -0
- package/dist/semiotic-themes.d.ts +2 -1
- package/dist/semiotic-themes.min.js +1 -1
- package/dist/semiotic-themes.module.min.js +1 -1
- package/dist/semiotic-utils.min.js +1 -1
- package/dist/semiotic-utils.module.min.js +1 -1
- package/dist/semiotic-xy.d.ts +11 -0
- package/dist/semiotic.d.ts +3 -3
- package/dist/semiotic.min.js +1 -1
- package/dist/semiotic.module.min.js +1 -1
- package/dist/server.min.js +1 -1
- package/dist/server.module.min.js +1 -1
- package/dist/test-utils/canvasMock.d.ts +35 -1
- package/dist/test-utils/ordinalFixtures.d.ts +48 -0
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +50 -42
- package/dist/components/types/annotationTypes.d.ts +0 -145
- package/dist/components/types/generalTypes.d.ts +0 -241
- package/dist/components/types/interactionTypes.d.ts +0 -72
- package/dist/components/types/networkTypes.d.ts +0 -174
- package/dist/components/types/ordinalTypes.d.ts +0 -112
- package/dist/semiotic-statisticalOverlays-DGX_WWc5.js +0 -1
|
@@ -2,8 +2,9 @@ import { createLegend } from "./legendUtils";
|
|
|
2
2
|
import type { SelectionHookResult } from "./selectionUtils";
|
|
3
3
|
import type { OnObservationCallback } from "../../store/ObservationStore";
|
|
4
4
|
import type { Accessor, SelectionConfig, LinkedHoverProp, ChartMode } from "./types";
|
|
5
|
-
import type { MarginType } from "../../types/
|
|
5
|
+
import type { MarginType, PartialMargin } from "../../types/marginType";
|
|
6
6
|
import type { TransitionConfig } from "../../stream/types";
|
|
7
|
+
import type { Datum } from "./datumTypes";
|
|
7
8
|
/**
|
|
8
9
|
* Default fill color used when no colorBy is specified
|
|
9
10
|
*/
|
|
@@ -13,6 +14,17 @@ export declare const DEFAULT_COLOR = "#007bff";
|
|
|
13
14
|
* the palette is empty. Safe to call outside a ThemeProvider (returns undefined).
|
|
14
15
|
*/
|
|
15
16
|
export declare function useThemeCategorical(): string[] | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Return the ambient theme's sequential scheme name (e.g. "blues", "viridis")
|
|
19
|
+
* for magnitude encodings. Safe to call outside a ThemeProvider (returns undefined).
|
|
20
|
+
*/
|
|
21
|
+
export declare function useThemeSequential(): string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Return the ambient theme's diverging scheme name (e.g. "RdBu", "PiYG")
|
|
24
|
+
* for midpoint encodings (likert, ±deviation). Safe to call outside a
|
|
25
|
+
* ThemeProvider (returns undefined).
|
|
26
|
+
*/
|
|
27
|
+
export declare function useThemeDiverging(): string | undefined;
|
|
16
28
|
/**
|
|
17
29
|
* Resolve the effective color for a data element when no colorBy is specified.
|
|
18
30
|
* Priority: color prop > theme categorical > colorScheme > DEFAULT_COLOR.
|
|
@@ -23,18 +35,27 @@ export declare function resolveDefaultFill(color: string | undefined, themeCateg
|
|
|
23
35
|
* Resolve an accessor (string key or function) into a function.
|
|
24
36
|
* Used across chart components to normalize `valueAccessor`, `categoryAccessor`, etc.
|
|
25
37
|
*/
|
|
26
|
-
export declare function resolveAccessor<T = any>(accessor: string | ((d:
|
|
38
|
+
export declare function resolveAccessor<T = any>(accessor: string | ((d: Datum, i?: number) => T)): (d: Datum) => T;
|
|
27
39
|
/**
|
|
28
40
|
* Hook to create a color scale from data and colorBy configuration.
|
|
29
41
|
* Returns undefined when colorBy is absent or data is empty (push API mode).
|
|
30
42
|
* Supports both string and function accessors for colorBy.
|
|
31
43
|
*/
|
|
32
|
-
export declare function useColorScale(data: Array<
|
|
44
|
+
export declare function useColorScale(data: Array<Datum>, colorBy: string | ((d: any, i?: number) => any) | undefined, colorScheme?: string | string[]): ((v: string) => string) | undefined;
|
|
33
45
|
/**
|
|
34
46
|
* Hook to sort data by a value accessor.
|
|
35
47
|
* Used by BarChart and DotPlot.
|
|
48
|
+
*
|
|
49
|
+
* `"auto"` and function comparators are pass-through here. The frame-
|
|
50
|
+
* level `resolveCategories` decides the visual category order:
|
|
51
|
+
* • `"auto"` → insertion order when streaming, value-desc when static.
|
|
52
|
+
* • function → runs as a category-key comparator on the axis list.
|
|
53
|
+
* The HOC's row-level `data` order only seeds insertion order via the
|
|
54
|
+
* store's category Set; rearranging rows with a category comparator
|
|
55
|
+
* makes no sense (it would call the comparator with row objects instead
|
|
56
|
+
* of strings), so we decline to sort in both cases.
|
|
36
57
|
*/
|
|
37
|
-
export declare function useSortedData(data: Array<
|
|
58
|
+
export declare function useSortedData(data: Array<Datum>, sort: boolean | "asc" | "desc" | "auto" | ((a: string, b: string) => number), valueAccessor: Accessor<number>): Array<Datum>;
|
|
38
59
|
/**
|
|
39
60
|
* Hook to set up selection and linked hover for a chart component.
|
|
40
61
|
* Consolidates normalizeLinkedHover, useSelection, useLinkedHover,
|
|
@@ -43,7 +64,7 @@ export declare function useSortedData(data: Array<Record<string, any>>, sort: bo
|
|
|
43
64
|
* @param unwrapData - Deprecated / no-op. Hover data is always unwrapped
|
|
44
65
|
* (stream frames wrap the raw datum in { data, time, value, x, y }).
|
|
45
66
|
*/
|
|
46
|
-
export declare function useChartSelection({ selection, linkedHover, fallbackFields, unwrapData, onObservation, chartType, chartId, onClick, hoverHighlight, colorByField, }: {
|
|
67
|
+
export declare function useChartSelection({ selection, linkedHover, fallbackFields, unwrapData: _unwrapData, onObservation, chartType, chartId, onClick, hoverHighlight, colorByField, }: {
|
|
47
68
|
selection?: SelectionConfig;
|
|
48
69
|
linkedHover?: LinkedHoverProp;
|
|
49
70
|
fallbackFields?: string[];
|
|
@@ -60,8 +81,8 @@ export declare function useChartSelection({ selection, linkedHover, fallbackFiel
|
|
|
60
81
|
}): {
|
|
61
82
|
activeSelectionHook: SelectionHookResult | null;
|
|
62
83
|
hoverSelectionHook: SelectionHookResult | null;
|
|
63
|
-
customHoverBehavior: (d:
|
|
64
|
-
customClickBehavior: (d:
|
|
84
|
+
customHoverBehavior: (d: Datum | null) => void;
|
|
85
|
+
customClickBehavior: (d: Datum | null) => void;
|
|
65
86
|
/** Stable ID for this chart instance, used to suppress linked crosshair on source chart */
|
|
66
87
|
crosshairSourceId: string;
|
|
67
88
|
};
|
|
@@ -80,27 +101,17 @@ export declare function getCrosshairProps(linkedHover: unknown, crosshairSourceI
|
|
|
80
101
|
*/
|
|
81
102
|
export type LegendPosition = "right" | "left" | "top" | "bottom";
|
|
82
103
|
export declare function useChartLegendAndMargin({ data, colorBy, colorScale, showLegend, legendPosition, userMargin, defaults, categories, }: {
|
|
83
|
-
data: Array<
|
|
104
|
+
data: Array<Datum>;
|
|
84
105
|
colorBy: Accessor<string> | undefined;
|
|
85
106
|
colorScale: ((v: string) => string) | undefined;
|
|
86
107
|
showLegend: boolean | undefined;
|
|
87
108
|
legendPosition?: LegendPosition;
|
|
88
|
-
userMargin:
|
|
89
|
-
defaults?:
|
|
90
|
-
top: number;
|
|
91
|
-
bottom: number;
|
|
92
|
-
left: number;
|
|
93
|
-
right: number;
|
|
94
|
-
};
|
|
109
|
+
userMargin: PartialMargin | undefined;
|
|
110
|
+
defaults?: MarginType;
|
|
95
111
|
categories?: string[];
|
|
96
112
|
}): {
|
|
97
113
|
legend: ReturnType<typeof createLegend> | undefined;
|
|
98
|
-
margin:
|
|
99
|
-
top: number;
|
|
100
|
-
bottom: number;
|
|
101
|
-
left: number;
|
|
102
|
-
right: number;
|
|
103
|
-
};
|
|
114
|
+
margin: MarginType;
|
|
104
115
|
legendPosition: LegendPosition;
|
|
105
116
|
};
|
|
106
117
|
export type LegendInteractionMode = "highlight" | "isolate" | "none";
|
|
@@ -116,15 +127,19 @@ export interface LegendInteractionState {
|
|
|
116
127
|
/** Selection predicate that dims non-matching data — use with wrapStyleWithSelection */
|
|
117
128
|
legendSelectionHook: {
|
|
118
129
|
isActive: boolean;
|
|
119
|
-
predicate: (d:
|
|
130
|
+
predicate: (d: Datum) => boolean;
|
|
120
131
|
} | null;
|
|
121
132
|
}
|
|
122
133
|
/**
|
|
123
134
|
* Hook managing legend highlight/isolate interaction.
|
|
124
|
-
* - "highlight": hover over legend item
|
|
135
|
+
* - "highlight": hover over a legend item produces a selection hook that
|
|
136
|
+
* `wrapStyleWithSelection` uses to dim non-matching data. The actual
|
|
137
|
+
* dim opacity resolves in this order: per-chart
|
|
138
|
+
* `selection.unselectedOpacity` → `theme.colors.selectionOpacity` →
|
|
139
|
+
* `DEFAULT_SELECTION_OPACITY` fallback.
|
|
125
140
|
* - "isolate": click toggles category visibility; click all to reset
|
|
126
141
|
*/
|
|
127
|
-
export declare function useLegendInteraction(mode: LegendInteractionMode | undefined, colorBy: string | ((d:
|
|
142
|
+
export declare function useLegendInteraction(mode: LegendInteractionMode | undefined, colorBy: string | ((d: Datum) => string) | undefined, allCategories: string[]): LegendInteractionState;
|
|
128
143
|
interface ChartModeInput {
|
|
129
144
|
width?: number;
|
|
130
145
|
height?: number;
|
|
@@ -169,6 +184,8 @@ interface ChartModeResult {
|
|
|
169
184
|
left: number;
|
|
170
185
|
right: number;
|
|
171
186
|
};
|
|
187
|
+
/** True when mode is context or sparkline — the "hide interactive chrome" union. */
|
|
188
|
+
compactMode: boolean;
|
|
172
189
|
}
|
|
173
190
|
/**
|
|
174
191
|
* Resolve chart display mode into concrete prop defaults.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Accessor } from "./types";
|
|
2
2
|
import type { LegendItem } from "../../types/legendTypes";
|
|
3
|
+
import type { Datum } from "./datumTypes";
|
|
3
4
|
/**
|
|
4
5
|
* Create a legend configuration for HOC components
|
|
5
6
|
*
|
|
@@ -12,10 +13,10 @@ import type { LegendItem } from "../../types/legendTypes";
|
|
|
12
13
|
* @returns Legend configuration object for Semiotic frames
|
|
13
14
|
*/
|
|
14
15
|
export declare function createLegend({ data, colorBy, colorScale, getColor, strokeColor, strokeWidth, categories }: {
|
|
15
|
-
data: Array<
|
|
16
|
+
data: Array<Datum>;
|
|
16
17
|
colorBy: Accessor<string>;
|
|
17
18
|
colorScale?: ((v: string) => string);
|
|
18
|
-
getColor: (d:
|
|
19
|
+
getColor: (d: Datum, accessor: Accessor<string>, scale?: ((v: string) => string)) => string;
|
|
19
20
|
strokeColor?: string;
|
|
20
21
|
strokeWidth?: number;
|
|
21
22
|
categories?: string[];
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Datum } from "./datumTypes";
|
|
2
|
+
/**
|
|
3
|
+
* mergeShapeStyle — overlay top-level primitive styling props on a style function.
|
|
4
|
+
*
|
|
5
|
+
* Phase B of the primitive-theming plan introduces three first-class props
|
|
6
|
+
* on every shape-drawing chart: `stroke`, `strokeWidth`, `opacity` (joining
|
|
7
|
+
* `color`, which was already there). They're resolved at the HOC layer via
|
|
8
|
+
* this helper so the merge order — and precedence — lands in exactly one
|
|
9
|
+
* place for every chart type.
|
|
10
|
+
*
|
|
11
|
+
* Precedence (highest wins):
|
|
12
|
+
* 1. Top-level primitive prop (this helper's `overrides` parameter)
|
|
13
|
+
* 2. User-supplied `frameProps.*Style` return value
|
|
14
|
+
* 3. HOC base style (categorical color resolution, theme fallback, etc.)
|
|
15
|
+
*
|
|
16
|
+
* The "top-level wins over function return" rule is deliberate: explicit >
|
|
17
|
+
* generic. A user writing `<BarChart stroke="red" />` expects red strokes,
|
|
18
|
+
* even if they also pass `frameProps.pieceStyle = d => ({ stroke: "blue" })`
|
|
19
|
+
* for per-datum customization. The top-level prop is the broad stroke, the
|
|
20
|
+
* per-datum function handles the exceptions.
|
|
21
|
+
*
|
|
22
|
+
* When no overrides are set, returns the input function unchanged so
|
|
23
|
+
* `useMemo` chains upstream preserve referential equality.
|
|
24
|
+
*/
|
|
25
|
+
export interface PrimitiveStyleOverrides {
|
|
26
|
+
stroke?: string;
|
|
27
|
+
strokeWidth?: number;
|
|
28
|
+
opacity?: number;
|
|
29
|
+
}
|
|
30
|
+
type StyleFnArg = (...args: any[]) => Datum;
|
|
31
|
+
/** Returns true when at least one override key has a non-undefined value. */
|
|
32
|
+
export declare function hasPrimitiveOverrides(overrides: PrimitiveStyleOverrides): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Overlay `overrides` on the output of `styleFn`. Returns a new style
|
|
35
|
+
* function that calls the underlying one (if present) and merges the
|
|
36
|
+
* override fields last, so top-level props win.
|
|
37
|
+
*
|
|
38
|
+
* When `overrides` has no fields set, returns `styleFn` unchanged — this
|
|
39
|
+
* keeps the memoization-stable identity path hot for the common case
|
|
40
|
+
* where a designer has set nothing.
|
|
41
|
+
*/
|
|
42
|
+
export declare function mergeShapeStyle<F extends StyleFnArg>(styleFn: F | undefined, overrides: PrimitiveStyleOverrides): F;
|
|
43
|
+
export {};
|
|
@@ -1,31 +1,32 @@
|
|
|
1
|
+
import type { Datum } from "./datumTypes";
|
|
1
2
|
import type { Accessor } from "./types";
|
|
2
3
|
/**
|
|
3
4
|
* Flatten a hierarchical data structure into an array of all nodes
|
|
4
5
|
* by recursively traversing children.
|
|
5
6
|
*/
|
|
6
|
-
export declare function flattenHierarchy(data:
|
|
7
|
+
export declare function flattenHierarchy(data: Datum | null, childrenAccessor: string | ((d: Datum) => any[])): Array<Datum>;
|
|
7
8
|
/**
|
|
8
9
|
* Infer nodes from edges when a nodes array is not provided.
|
|
9
10
|
* Extracts unique source/target IDs and returns `{ id }` objects.
|
|
10
11
|
* Returns the provided nodes array if it's non-empty.
|
|
11
12
|
*/
|
|
12
|
-
export declare function inferNodesFromEdges(nodes: any[] | undefined, edges: any[], sourceAccessor: string | ((d:
|
|
13
|
+
export declare function inferNodesFromEdges(nodes: any[] | undefined, edges: any[], sourceAccessor: string | ((d: Datum) => string), targetAccessor: string | ((d: Datum) => string)): Array<{
|
|
13
14
|
id: string;
|
|
14
15
|
}>;
|
|
15
16
|
/**
|
|
16
17
|
* Convert a valueAccessor prop into a hierarchy sum function.
|
|
17
18
|
* Used by TreeDiagram, Treemap, and CirclePack for d3-hierarchy's `.sum()`.
|
|
18
19
|
*/
|
|
19
|
-
export declare function resolveHierarchySum(valueAccessor: string | ((d:
|
|
20
|
+
export declare function resolveHierarchySum(valueAccessor: string | ((d: Datum) => number)): (d: Datum) => number;
|
|
20
21
|
/**
|
|
21
22
|
* Create an edge style function for Sankey/Chord edge coloring.
|
|
22
23
|
* Handles edgeColorBy = "source" | "target" | "gradient" | function.
|
|
23
24
|
*/
|
|
24
25
|
export declare function createEdgeStyleFn({ edgeColorBy, colorBy, colorScale, nodeStyleFn, edgeOpacity, baseStyle, }: {
|
|
25
|
-
edgeColorBy: "source" | "target" | "gradient" | ((d:
|
|
26
|
+
edgeColorBy: "source" | "target" | "gradient" | ((d: Datum) => string);
|
|
26
27
|
colorBy: Accessor<string> | undefined;
|
|
27
28
|
colorScale: ((v: string) => string) | undefined;
|
|
28
|
-
nodeStyleFn: (d: any, index?: number) =>
|
|
29
|
+
nodeStyleFn: (d: any, index?: number) => Datum;
|
|
29
30
|
edgeOpacity: number;
|
|
30
31
|
baseStyle?: Record<string, string | number>;
|
|
31
|
-
}): (d:
|
|
32
|
+
}): (d: Datum) => Datum;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Datum } from "./datumTypes";
|
|
1
2
|
/**
|
|
2
3
|
* Selection integration utilities for HOC charts.
|
|
3
4
|
*
|
|
@@ -41,26 +42,28 @@ export declare function normalizeLinkedBrush(prop: string | {
|
|
|
41
42
|
} | undefined): NormalizedLinkedBrush | null;
|
|
42
43
|
export interface SelectionHookResult {
|
|
43
44
|
isActive: boolean;
|
|
44
|
-
predicate: (datum:
|
|
45
|
+
predicate: (datum: Datum) => boolean;
|
|
45
46
|
}
|
|
46
47
|
export interface SelectionStyleConfig {
|
|
47
48
|
unselectedOpacity?: number;
|
|
48
|
-
unselectedStyle?:
|
|
49
|
-
selectedStyle?:
|
|
49
|
+
unselectedStyle?: Datum;
|
|
50
|
+
selectedStyle?: Datum;
|
|
50
51
|
}
|
|
51
|
-
/** Default opacity for unselected (dimmed) elements */
|
|
52
|
-
export declare const DEFAULT_SELECTION_OPACITY = 0.2;
|
|
53
52
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
53
|
+
* Library fallback opacity for unselected (dimmed) elements.
|
|
54
|
+
*
|
|
55
|
+
* This is the last-resort value when nothing else supplies one. Clients
|
|
56
|
+
* control the effective default declaratively through `ThemeProvider`'s
|
|
57
|
+
* `colors.selectionOpacity` (built-in presets set this). Per-chart
|
|
58
|
+
* `selection.unselectedOpacity` still overrides the theme value.
|
|
56
59
|
*/
|
|
57
|
-
export declare
|
|
60
|
+
export declare const DEFAULT_SELECTION_OPACITY = 0.5;
|
|
58
61
|
/**
|
|
59
62
|
* Wrap a base style function with selection awareness.
|
|
60
63
|
* When a selection is active, non-matching datums get dimmed.
|
|
61
64
|
*
|
|
62
65
|
* Dimming opacity is resolved in this order:
|
|
63
|
-
* 1. `config.unselectedOpacity` (explicit
|
|
64
|
-
* 2. `DEFAULT_SELECTION_OPACITY`
|
|
66
|
+
* 1. `config.unselectedOpacity` (explicit, usually per-chart or theme-merged)
|
|
67
|
+
* 2. `DEFAULT_SELECTION_OPACITY`
|
|
65
68
|
*/
|
|
66
|
-
export declare function wrapStyleWithSelection(baseStyleFn: (d:
|
|
69
|
+
export declare function wrapStyleWithSelection(baseStyleFn: (d: Datum) => Datum, selectionHook: SelectionHookResult | null, config?: SelectionStyleConfig): (d: Datum) => Datum;
|
|
@@ -1,16 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Statistical overlay processing for LineChart.
|
|
3
|
-
*
|
|
4
|
-
* Two modes:
|
|
5
|
-
* **Auto mode** — provide `trainEnd` + optional `steps`/`confidence`.
|
|
6
|
-
* The module computes regression, generates forecast points, and builds
|
|
7
|
-
* annotations (envelope, anomaly band, boundary line).
|
|
8
|
-
*
|
|
9
|
-
* **Pre-computed mode** — provide field accessors (`isTraining`, `isForecast`,
|
|
10
|
-
* `isAnomaly`, `upperBounds`, `lowerBounds`). The module reads segment/bounds
|
|
11
|
-
* from the data and generates annotations without any statistical computation.
|
|
12
|
-
* Use this when bounds come from an external ML model.
|
|
13
|
-
*/
|
|
1
|
+
import type { Datum } from "./datumTypes";
|
|
14
2
|
export interface AnomalyConfig {
|
|
15
3
|
/** Standard deviation multiplier for anomaly bounds. Default: 2 */
|
|
16
4
|
threshold?: number;
|
|
@@ -39,15 +27,15 @@ export interface ForecastConfig {
|
|
|
39
27
|
/** Confidence level for prediction interval (0-1). Default: 0.95 */
|
|
40
28
|
confidence?: number;
|
|
41
29
|
/** Field or function marking training data points */
|
|
42
|
-
isTraining?: string | ((d:
|
|
30
|
+
isTraining?: string | ((d: Datum) => boolean);
|
|
43
31
|
/** Field or function marking forecast data points */
|
|
44
|
-
isForecast?: string | ((d:
|
|
32
|
+
isForecast?: string | ((d: Datum) => boolean);
|
|
45
33
|
/** Field or function marking anomalous data points */
|
|
46
|
-
isAnomaly?: string | ((d:
|
|
34
|
+
isAnomaly?: string | ((d: Datum) => boolean);
|
|
47
35
|
/** Field or function for upper envelope bound per data point */
|
|
48
|
-
upperBounds?: string | ((d:
|
|
36
|
+
upperBounds?: string | ((d: Datum) => number);
|
|
49
37
|
/** Field or function for lower envelope bound per data point */
|
|
50
|
-
lowerBounds?: string | ((d:
|
|
38
|
+
lowerBounds?: string | ((d: Datum) => number);
|
|
51
39
|
/** Color for forecast line and envelope. Default: "#6366f1" */
|
|
52
40
|
color?: string;
|
|
53
41
|
/** Envelope fill opacity. Default: 0.15 */
|
|
@@ -82,19 +70,19 @@ export interface ForecastConfig {
|
|
|
82
70
|
* - `string`: fixed color (default: "#ef4444")
|
|
83
71
|
* - `(datum) => string`: per-datum color function
|
|
84
72
|
*/
|
|
85
|
-
anomalyColor?: string | ((datum:
|
|
73
|
+
anomalyColor?: string | ((datum: Datum) => string);
|
|
86
74
|
/**
|
|
87
75
|
* Outlier dot radius.
|
|
88
76
|
* - `number`: fixed radius (default: 6)
|
|
89
77
|
* - `(datum) => number`: per-datum radius function (e.g. for count-based sizing)
|
|
90
78
|
*/
|
|
91
|
-
anomalyRadius?: number | ((datum:
|
|
79
|
+
anomalyRadius?: number | ((datum: Datum) => number);
|
|
92
80
|
/**
|
|
93
81
|
* Full style override for anomaly dots.
|
|
94
82
|
* When provided as a function, receives the datum and should return a CSS style object.
|
|
95
83
|
* Overrides `anomalyColor` when provided.
|
|
96
84
|
*/
|
|
97
|
-
anomalyStyle?:
|
|
85
|
+
anomalyStyle?: Datum | ((datum: Datum) => Datum);
|
|
98
86
|
/**
|
|
99
87
|
* Internal: field name used to group data into separate lines (e.g. "metricLabel").
|
|
100
88
|
* When set, boundary point duplication only bridges within the same group,
|
|
@@ -109,11 +97,11 @@ export interface ForecastConfig {
|
|
|
109
97
|
/** Internal segment marker added to each datum */
|
|
110
98
|
export declare const SEGMENT_FIELD: "__forecastSegment";
|
|
111
99
|
export type SegmentType = "training" | "training-base" | "observed" | "forecast";
|
|
112
|
-
export declare function buildAnomalyAnnotations(config: AnomalyConfig):
|
|
100
|
+
export declare function buildAnomalyAnnotations(config: AnomalyConfig): Datum[];
|
|
113
101
|
export interface ForecastResult {
|
|
114
|
-
processedData:
|
|
115
|
-
annotations:
|
|
102
|
+
processedData: Datum[];
|
|
103
|
+
annotations: Datum[];
|
|
116
104
|
}
|
|
117
|
-
export declare function buildForecast(data:
|
|
105
|
+
export declare function buildForecast(data: Datum[], xAccessor: string, yAccessor: string, forecastConfig: ForecastConfig, anomalyConfig?: AnomalyConfig): ForecastResult;
|
|
118
106
|
export { darkenColor, lightenColor } from "./colorManipulation";
|
|
119
|
-
export declare function createSegmentLineStyle(baseStyle: (d:
|
|
107
|
+
export declare function createSegmentLineStyle(baseStyle: (d: Datum) => Datum, forecastConfig: ForecastConfig): (d: Datum) => Datum;
|
|
@@ -6,5 +6,5 @@ export type { ForecastResult } from "./statisticalOverlays";
|
|
|
6
6
|
/** Duplicated here to avoid pulling in the heavy statisticalOverlays module at import time */
|
|
7
7
|
export declare const SEGMENT_FIELD: "__forecastSegment";
|
|
8
8
|
export declare function buildForecastLazy(...args: Parameters<typeof import("./statisticalOverlays")["buildForecast"]>): Promise<import("./statisticalOverlays").ForecastResult>;
|
|
9
|
-
export declare function buildAnomalyAnnotationsLazy(...args: Parameters<typeof import("./statisticalOverlays")["buildAnomalyAnnotations"]>): Promise<
|
|
10
|
-
export declare function createSegmentLineStyleLazy(...args: Parameters<typeof import("./statisticalOverlays")["createSegmentLineStyle"]>): Promise<(d:
|
|
9
|
+
export declare function buildAnomalyAnnotationsLazy(...args: Parameters<typeof import("./statisticalOverlays")["buildAnomalyAnnotations"]>): Promise<import("./datumTypes").Datum[]>;
|
|
10
|
+
export declare function createSegmentLineStyleLazy(...args: Parameters<typeof import("./statisticalOverlays")["createSegmentLineStyle"]>): Promise<(d: import("./datumTypes").Datum) => import("./datumTypes").Datum>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Datum } from "./datumTypes";
|
|
1
2
|
import * as React from "react";
|
|
2
3
|
/**
|
|
3
4
|
* Shared tooltip for distribution charts (BoxPlot, ViolinPlot, RidgelinePlot).
|
|
@@ -7,5 +8,5 @@ import * as React from "react";
|
|
|
7
8
|
*/
|
|
8
9
|
export declare function buildStatsTooltip(options?: {
|
|
9
10
|
/** If provided, computes fallback stats from raw data when d.stats is missing */
|
|
10
|
-
valueAccessor?: string | ((d:
|
|
11
|
-
}): (d:
|
|
11
|
+
valueAccessor?: string | ((d: Datum) => number);
|
|
12
|
+
}): (d: Datum) => React.ReactElement;
|
|
@@ -1,17 +1,26 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import type { HoverData } from "../../realtime/types";
|
|
3
|
+
import type { Datum } from "./datumTypes";
|
|
3
4
|
export interface TooltipFieldConfig {
|
|
4
5
|
label: string;
|
|
5
6
|
accessor: string | ((d: any) => any);
|
|
6
7
|
role?: "title" | "x" | "y" | "color" | "size" | "group" | "value";
|
|
8
|
+
/** Per-field formatter. HOCs pass `xFormat`/`yFormat`/`valueFormat` here so
|
|
9
|
+
* the default tooltip renders values consistently with the axis. Typed
|
|
10
|
+
* permissively (`any` → `ReactNode`) to match the mixed formatter
|
|
11
|
+
* signatures across ordinal (`(d: string | number) => string`) and XY
|
|
12
|
+
* (`(d, index?, allTicks?) => ReactNode`). A ReactNode return renders
|
|
13
|
+
* as-is in the tooltip span. If the formatter throws, the tooltip
|
|
14
|
+
* falls back to the built-in `formatVal`. */
|
|
15
|
+
format?: (v: any, ...rest: any[]) => React.ReactNode;
|
|
7
16
|
}
|
|
8
17
|
/**
|
|
9
18
|
* Extract a display name from an accessor.
|
|
10
19
|
* Strings return themselves; functions return "value".
|
|
11
20
|
*/
|
|
12
|
-
export declare function accessorName(acc: string |
|
|
21
|
+
export declare function accessorName(acc: string | ((...args: any[]) => any)): string;
|
|
13
22
|
export declare function formatVal(v: unknown): string;
|
|
14
|
-
export declare function resolveValue(d:
|
|
23
|
+
export declare function resolveValue(d: Datum, acc: string | ((d: Datum) => any)): unknown;
|
|
15
24
|
/**
|
|
16
25
|
* Build a default tooltipContent function for StreamXYFrame HOCs.
|
|
17
26
|
* Receives HoverData ({ data, time, value, x, y }) and renders
|
|
@@ -25,10 +34,14 @@ export declare function buildDefaultTooltip(fields: TooltipFieldConfig[]): (hove
|
|
|
25
34
|
* @param pieData - If true, extracts datum via `d.data?.[0] || d.data || d`
|
|
26
35
|
* (PieChart/DonutChart wrap data in arrays). Default: `d.data || d`.
|
|
27
36
|
*/
|
|
28
|
-
export declare function buildOrdinalTooltip({ categoryAccessor, valueAccessor, groupAccessor, groupLabel, pieData, }: {
|
|
29
|
-
categoryAccessor: string | ((d:
|
|
30
|
-
valueAccessor: string | ((d:
|
|
31
|
-
groupAccessor?: string | ((d:
|
|
37
|
+
export declare function buildOrdinalTooltip({ categoryAccessor, valueAccessor, groupAccessor, groupLabel, pieData, valueFormat, }: {
|
|
38
|
+
categoryAccessor: string | ((d: Datum) => any);
|
|
39
|
+
valueAccessor: string | ((d: Datum) => any);
|
|
40
|
+
groupAccessor?: string | ((d: Datum) => any);
|
|
32
41
|
groupLabel?: string;
|
|
33
42
|
pieData?: boolean;
|
|
34
|
-
|
|
43
|
+
/** Same formatter the HOC passes to the value axis. Threaded here so the
|
|
44
|
+
* default tooltip shows values consistently with the axis ("$450k", not
|
|
45
|
+
* "450000"). Override by passing a custom `tooltip` prop. */
|
|
46
|
+
valueFormat?: (v: any, ...rest: any[]) => React.ReactNode;
|
|
47
|
+
}): (d: Datum) => React.ReactNode;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type React from "react";
|
|
2
|
-
import type {
|
|
2
|
+
import type { PartialMargin } from "../../types/marginType";
|
|
3
3
|
import type { OnObservationCallback } from "../../store/ObservationStore";
|
|
4
|
+
import type { AnimateProp } from "../../stream/pipelineTransitionUtils";
|
|
5
|
+
import type { Datum } from "./datumTypes";
|
|
4
6
|
/**
|
|
5
7
|
* Selection consumption config — makes this chart react to a named selection
|
|
6
8
|
*/
|
|
@@ -10,9 +12,9 @@ export interface SelectionConfig {
|
|
|
10
12
|
/** Opacity for unselected elements (default 0.2) */
|
|
11
13
|
unselectedOpacity?: number;
|
|
12
14
|
/** Style overrides for unselected elements */
|
|
13
|
-
unselectedStyle?:
|
|
15
|
+
unselectedStyle?: Datum;
|
|
14
16
|
/** Style overrides for selected elements */
|
|
15
|
-
selectedStyle?:
|
|
17
|
+
selectedStyle?: Datum;
|
|
16
18
|
}
|
|
17
19
|
/**
|
|
18
20
|
* Linked hover config
|
|
@@ -51,8 +53,10 @@ export interface BaseChartProps {
|
|
|
51
53
|
width?: number;
|
|
52
54
|
/** Chart height in pixels. Default: 400 */
|
|
53
55
|
height?: number;
|
|
54
|
-
/** Margin around the chart.
|
|
55
|
-
|
|
56
|
+
/** Margin around the chart. Accepts a number (same on all sides) or an object
|
|
57
|
+
* with any subset of `top`/`bottom`/`left`/`right`. Missing sides fall back
|
|
58
|
+
* to the chart-mode defaults. */
|
|
59
|
+
margin?: PartialMargin;
|
|
56
60
|
/** Auto-match width to parent container. Default: false */
|
|
57
61
|
responsiveWidth?: boolean;
|
|
58
62
|
/** Auto-match height to parent container (requires parent with explicit height). Default: false */
|
|
@@ -79,6 +83,12 @@ export interface BaseChartProps {
|
|
|
79
83
|
/** Uniform fill color for all data marks. Overrides colorScheme and theme categorical.
|
|
80
84
|
* For per-category coloring, use `colorBy` + `colorScheme` instead. */
|
|
81
85
|
color?: string;
|
|
86
|
+
/** Uniform stroke color for all data marks. Accepts a CSS variable. */
|
|
87
|
+
stroke?: string;
|
|
88
|
+
/** Uniform stroke width in pixels. */
|
|
89
|
+
strokeWidth?: number;
|
|
90
|
+
/** Uniform opacity for all data marks (0–1). Distinct from `--semiotic-selection-opacity` which only dims non-selected marks. */
|
|
91
|
+
opacity?: number;
|
|
82
92
|
/** Accessible description overriding the auto-generated aria-label on the chart container.
|
|
83
93
|
* Should describe the chart's purpose or content for screen reader users. */
|
|
84
94
|
description?: string;
|
|
@@ -98,17 +108,15 @@ export interface BaseChartProps {
|
|
|
98
108
|
/** Max pixel distance for hover/click hit testing. Default 30. Increase for sparse charts, decrease for dense ones. */
|
|
99
109
|
hoverRadius?: number;
|
|
100
110
|
/** ID accessor for remove()/update() on XY charts. Extracts a unique identifier from each datum. */
|
|
101
|
-
pointIdAccessor?: string | ((d:
|
|
111
|
+
pointIdAccessor?: string | ((d: Datum) => string);
|
|
102
112
|
/** ID accessor for remove()/update() on ordinal charts. Extracts a unique identifier from each datum. */
|
|
103
|
-
dataIdAccessor?: string | ((d:
|
|
113
|
+
dataIdAccessor?: string | ((d: Datum) => string);
|
|
104
114
|
/** Visual emphasis level for dashboard hierarchy. "primary" spans two columns in ChartGrid. */
|
|
105
115
|
emphasis?: "primary" | "secondary";
|
|
106
|
-
/** Enable declarative bounded animation (enter/exit/update transitions).
|
|
107
|
-
* `true` uses defaults (300ms ease-out). Object form allows customization.
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
easing?: "linear" | "ease-out";
|
|
111
|
-
};
|
|
116
|
+
/** Enable declarative bounded animation (enter/exit/update transitions + intro).
|
|
117
|
+
* `true` uses defaults (300ms ease-out, intro enabled). Object form allows customization.
|
|
118
|
+
* Set `{ intro: false }` to disable the animated intro on first render. */
|
|
119
|
+
animate?: AnimateProp;
|
|
112
120
|
}
|
|
113
121
|
/**
|
|
114
122
|
* Axis configuration props
|
|
@@ -119,9 +127,9 @@ export interface AxisConfig {
|
|
|
119
127
|
/** Label for the y-axis */
|
|
120
128
|
yLabel?: string;
|
|
121
129
|
/** Format function for x-axis tick labels. Return string or ReactNode for custom rendering. */
|
|
122
|
-
xFormat?: (d:
|
|
130
|
+
xFormat?: (d: number | Date | string, index?: number, allTicks?: number[]) => string | React.ReactNode;
|
|
123
131
|
/** Format function for y-axis tick labels. Return string or ReactNode for custom rendering. */
|
|
124
|
-
yFormat?: (d:
|
|
132
|
+
yFormat?: (d: number | Date | string) => string | React.ReactNode;
|
|
125
133
|
}
|
|
126
134
|
/**
|
|
127
135
|
* Category formatting for ordinal chart tick labels.
|
|
@@ -135,14 +143,14 @@ export type CategoryFormatFn = (label: string, index?: number) => string | React
|
|
|
135
143
|
export type Accessor<T = any> = string | ((d: any, i?: number) => T);
|
|
136
144
|
/**
|
|
137
145
|
* Generic accessor type that provides autocomplete when TDatum is specified.
|
|
138
|
-
* Uses
|
|
146
|
+
* Uses Datum in the function param so HOC charts can pass
|
|
139
147
|
* accessors to Stream Frames without contravariance errors under strict mode.
|
|
140
148
|
*/
|
|
141
|
-
export type ChartAccessor<TDatum, T> = (keyof TDatum & string) | ((d:
|
|
149
|
+
export type ChartAccessor<TDatum, T> = (keyof TDatum & string) | ((d: Datum, i?: number) => T);
|
|
142
150
|
/**
|
|
143
151
|
* Color configuration
|
|
144
152
|
*/
|
|
145
|
-
export interface ColorConfig<TDatum =
|
|
153
|
+
export interface ColorConfig<TDatum = Datum> {
|
|
146
154
|
/** Field name or function to determine color */
|
|
147
155
|
colorBy?: ChartAccessor<TDatum, string>;
|
|
148
156
|
/** Color scheme name (e.g., "blues", "category10") */
|
|
@@ -153,7 +161,7 @@ export interface ColorConfig<TDatum = Record<string, any>> {
|
|
|
153
161
|
/**
|
|
154
162
|
* Size configuration
|
|
155
163
|
*/
|
|
156
|
-
export interface SizeConfig<TDatum =
|
|
164
|
+
export interface SizeConfig<TDatum = Datum> {
|
|
157
165
|
/** Field name or function to determine size */
|
|
158
166
|
sizeBy?: ChartAccessor<TDatum, number>;
|
|
159
167
|
/** Min and max size range */
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type { Datum } from "./datumTypes";
|
|
1
2
|
import { useChartLegendAndMargin, useLegendInteraction, DEFAULT_COLOR } from "./hooks";
|
|
2
3
|
import type { LegendInteractionMode, LegendPosition } from "./hooks";
|
|
3
4
|
import type { Accessor, SelectionConfig, LinkedHoverProp } from "./types";
|
|
4
5
|
import type { OnObservationCallback } from "../../store/ObservationStore";
|
|
5
|
-
import type {
|
|
6
|
+
import type { PartialMargin } from "../../types/marginType";
|
|
6
7
|
import type { SelectionHookResult } from "./selectionUtils";
|
|
7
8
|
import type { ReactElement, ReactNode } from "react";
|
|
8
9
|
/**
|
|
@@ -14,7 +15,7 @@ import type { ReactElement, ReactNode } from "react";
|
|
|
14
15
|
*/
|
|
15
16
|
export interface ChartSetupInput {
|
|
16
17
|
/** The data array used for color scale and category extraction */
|
|
17
|
-
data: Array<
|
|
18
|
+
data: Array<Datum>;
|
|
18
19
|
/** The original data prop (may be undefined) — used for empty-state check */
|
|
19
20
|
rawData: unknown[] | undefined;
|
|
20
21
|
/** The color-by accessor (may be an "actual" colorBy derived from stackBy/groupBy/categoryAccessor) */
|
|
@@ -42,7 +43,7 @@ export interface ChartSetupInput {
|
|
|
42
43
|
/** Show legend override */
|
|
43
44
|
showLegend: boolean | undefined;
|
|
44
45
|
/** User-provided margin */
|
|
45
|
-
userMargin:
|
|
46
|
+
userMargin: PartialMargin | undefined;
|
|
46
47
|
/** Mode-resolved margin defaults */
|
|
47
48
|
marginDefaults: {
|
|
48
49
|
top: number;
|
|
@@ -81,9 +82,9 @@ export interface ChartSetupResult {
|
|
|
81
82
|
/** The active cross-chart selection hook (before legend merge) */
|
|
82
83
|
activeSelectionHook: SelectionHookResult | null;
|
|
83
84
|
/** Custom hover behavior callback for the frame */
|
|
84
|
-
customHoverBehavior: (d:
|
|
85
|
+
customHoverBehavior: (d: Datum | null) => void;
|
|
85
86
|
/** Custom click behavior callback for the frame */
|
|
86
|
-
customClickBehavior: (d:
|
|
87
|
+
customClickBehavior: (d: Datum | null) => void;
|
|
87
88
|
/** Legend config (or undefined if no legend) */
|
|
88
89
|
legend: ReturnType<typeof useChartLegendAndMargin>["legend"];
|
|
89
90
|
/** Computed margin with legend-aware adjustments */
|
|
@@ -98,12 +99,20 @@ export interface ChartSetupResult {
|
|
|
98
99
|
/** If non-null, the HOC should return this element (loading or empty state) */
|
|
99
100
|
earlyReturn: ReactElement | null;
|
|
100
101
|
/** Props to spread into the stream frame for legend behavior */
|
|
101
|
-
legendBehaviorProps:
|
|
102
|
+
legendBehaviorProps: Datum;
|
|
102
103
|
/** Crosshair props to spread into StreamXYFrame when linkedHover mode is "x-position" */
|
|
103
104
|
crosshairProps: {
|
|
104
105
|
linkedCrosshairName: string;
|
|
105
106
|
linkedCrosshairSourceId: string;
|
|
106
107
|
} | undefined;
|
|
108
|
+
/**
|
|
109
|
+
* Selection config merged with theme-level defaults. HOCs should pass this
|
|
110
|
+
* to `wrapStyleWithSelection` instead of the raw `selection` prop so that
|
|
111
|
+
* the current theme's `colors.selectionOpacity` becomes the effective
|
|
112
|
+
* unselected-opacity fallback. Per-chart `selection.unselectedOpacity`
|
|
113
|
+
* still takes priority over the theme value.
|
|
114
|
+
*/
|
|
115
|
+
resolvedSelection: SelectionConfig | undefined;
|
|
107
116
|
}
|
|
108
117
|
/**
|
|
109
118
|
* Hook that consolidates the shared boilerplate across all HOC charts:
|