semiotic 3.5.1 → 3.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/CLAUDE.md +26 -23
  2. package/README.md +27 -21
  3. package/ai/chartSuggestions.cjs +191 -3
  4. package/ai/componentMetadata.cjs +3 -3
  5. package/ai/dist/mcp-server.js +266 -48
  6. package/ai/examples.md +68 -0
  7. package/ai/schema.json +914 -1
  8. package/ai/system-prompt.md +4 -1
  9. package/dist/components/ThemeProvider.d.ts +2 -2
  10. package/dist/components/Tooltip/FlippingTooltip.d.ts +16 -1
  11. package/dist/components/charts/geo/FlowMap.d.ts +13 -4
  12. package/dist/components/charts/index.d.ts +6 -0
  13. package/dist/components/charts/network/OrbitDiagram.d.ts +5 -5
  14. package/dist/components/charts/network/ProcessSankey.d.ts +163 -0
  15. package/dist/components/charts/network/SankeyDiagram.d.ts +5 -1
  16. package/dist/components/charts/network/processSankey/algorithm.d.ts +193 -0
  17. package/dist/components/charts/network/processSankey/buildScenes.d.ts +51 -0
  18. package/dist/components/charts/network/processSankey/ribbonInputs.d.ts +32 -0
  19. package/dist/components/charts/network/processSankey/streamingLayout.d.ts +71 -0
  20. package/dist/components/charts/network/processSankey/tooltipUtils.d.ts +41 -0
  21. package/dist/components/charts/ordinal/BarChart.d.ts +12 -0
  22. package/dist/components/charts/ordinal/DotPlot.d.ts +9 -0
  23. package/dist/components/charts/ordinal/GaugeChart.d.ts +20 -0
  24. package/dist/components/charts/ordinal/SwimlaneChart.d.ts +5 -0
  25. package/dist/components/charts/realtime/RealtimeHeatmap.d.ts +2 -0
  26. package/dist/components/charts/realtime/RealtimeHistogram.d.ts +16 -11
  27. package/dist/components/charts/realtime/RealtimeLineChart.d.ts +2 -0
  28. package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +2 -0
  29. package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +2 -0
  30. package/dist/components/charts/realtime/defaultRealtimeTooltip.d.ts +19 -0
  31. package/dist/components/charts/shared/axisExtent.d.ts +59 -0
  32. package/dist/components/charts/shared/chartSpecs.d.ts +75 -0
  33. package/dist/components/charts/shared/colorUtils.d.ts +8 -2
  34. package/dist/components/charts/shared/networkUtils.d.ts +3 -5
  35. package/dist/components/charts/shared/radialGeometry.d.ts +99 -0
  36. package/dist/components/charts/shared/regressionUtils.d.ts +59 -0
  37. package/dist/components/charts/shared/selectionUtils.d.ts +8 -1
  38. package/dist/components/charts/shared/streamPropsHelpers.d.ts +5 -0
  39. package/dist/components/charts/shared/tooltipUtils.d.ts +11 -0
  40. package/dist/components/charts/shared/types.d.ts +19 -0
  41. package/dist/components/charts/shared/useAreaSeriesSetup.d.ts +78 -0
  42. package/dist/components/charts/shared/useChartSetup.d.ts +2 -0
  43. package/dist/components/charts/shared/useCustomChartSetup.d.ts +1 -0
  44. package/dist/components/charts/shared/useEncodingDomain.d.ts +48 -0
  45. package/dist/components/charts/shared/useFrameImperativeHandle.d.ts +1 -1
  46. package/dist/components/charts/shared/useNetworkChartSetup.d.ts +150 -0
  47. package/dist/components/charts/shared/useOrdinalPieceStyle.d.ts +87 -0
  48. package/dist/components/charts/shared/useSeriesFeatures.d.ts +57 -0
  49. package/dist/components/charts/shared/useStreamStatus.d.ts +33 -0
  50. package/dist/components/charts/shared/useXYLineStyle.d.ts +69 -0
  51. package/dist/components/charts/shared/useXYPointStyle.d.ts +87 -0
  52. package/dist/components/charts/shared/withChartWrapper.d.ts +10 -3
  53. package/dist/components/charts/xy/AreaChart.d.ts +36 -2
  54. package/dist/components/charts/xy/BubbleChart.d.ts +9 -0
  55. package/dist/components/charts/xy/ConnectedScatterplot.d.ts +16 -0
  56. package/dist/components/charts/xy/DifferenceChart.d.ts +172 -0
  57. package/dist/components/charts/xy/LineChart.d.ts +26 -2
  58. package/dist/components/charts/xy/Scatterplot.d.ts +39 -1
  59. package/dist/components/geometry/ribbonGeometry.d.ts +76 -0
  60. package/dist/components/semiotic-ai.d.ts +2 -0
  61. package/dist/components/semiotic-network.d.ts +4 -0
  62. package/dist/components/semiotic-realtime.d.ts +2 -0
  63. package/dist/components/semiotic-utils.d.ts +4 -0
  64. package/dist/components/semiotic-xy.d.ts +2 -0
  65. package/dist/components/semiotic.d.ts +4 -4
  66. package/dist/components/server/renderToStaticSVG.d.ts +2 -1
  67. package/dist/components/server/serverChartConfigs.d.ts +3 -0
  68. package/dist/components/server/staticAnnotations.d.ts +1 -1
  69. package/dist/components/server/themeResolver.d.ts +7 -1
  70. package/dist/components/store/ThemeStore.d.ts +7 -1
  71. package/dist/components/stream/AccessibleDataTable.d.ts +2 -2
  72. package/dist/components/stream/GeoPipelineStore.d.ts +21 -0
  73. package/dist/components/stream/OrdinalSVGOverlay.d.ts +8 -0
  74. package/dist/components/stream/PipelineStore.d.ts +25 -13
  75. package/dist/components/stream/SVGOverlay.d.ts +9 -18
  76. package/dist/components/stream/accessorUtils.d.ts +2 -1
  77. package/dist/components/stream/annotationAccessorResolver.d.ts +39 -0
  78. package/dist/components/stream/geoTypes.d.ts +12 -0
  79. package/dist/components/stream/layouts/hierarchyLayoutPlugin.d.ts +1 -1
  80. package/dist/components/stream/networkTypes.d.ts +11 -0
  81. package/dist/components/stream/ordinalTypes.d.ts +27 -1
  82. package/dist/components/stream/renderers/cornerRadii.d.ts +33 -0
  83. package/dist/components/stream/renderers/wedgePathBuilder.d.ts +56 -0
  84. package/dist/components/stream/types.d.ts +127 -11
  85. package/dist/components/stream/xySceneBuilders/areaGradient.d.ts +20 -0
  86. package/dist/components/stream/xySceneBuilders/barScene.d.ts +2 -2
  87. package/dist/components/stream/xySceneBuilders/candlestickScene.d.ts +2 -2
  88. package/dist/components/stream/xySceneBuilders/heatmapScene.d.ts +2 -2
  89. package/dist/components/stream/xySceneBuilders/lineScene.d.ts +4 -3
  90. package/dist/components/stream/xySceneBuilders/pointScene.d.ts +2 -2
  91. package/dist/components/stream/xySceneBuilders/ribbonScene.d.ts +107 -0
  92. package/dist/components/stream/xySceneBuilders/swarmScene.d.ts +2 -2
  93. package/dist/components/stream/xySceneBuilders/types.d.ts +9 -12
  94. package/dist/components/stream/xySceneBuilders/waterfallScene.d.ts +2 -2
  95. package/dist/components/types/legendTypes.d.ts +1 -1
  96. package/dist/geo.min.js +1 -1
  97. package/dist/geo.module.min.js +1 -1
  98. package/dist/network.min.js +1 -1
  99. package/dist/network.module.min.js +1 -1
  100. package/dist/ordinal.min.js +1 -1
  101. package/dist/ordinal.module.min.js +1 -1
  102. package/dist/realtime.min.js +1 -1
  103. package/dist/realtime.module.min.js +1 -1
  104. package/dist/semiotic-ai.d.ts +2 -0
  105. package/dist/semiotic-ai.min.js +1 -1
  106. package/dist/semiotic-ai.module.min.js +1 -1
  107. package/dist/semiotic-data.min.js +1 -1
  108. package/dist/semiotic-data.module.min.js +1 -1
  109. package/dist/semiotic-network.d.ts +4 -0
  110. package/dist/semiotic-realtime.d.ts +2 -0
  111. package/dist/semiotic-recipes.min.js +1 -1
  112. package/dist/semiotic-recipes.module.min.js +1 -1
  113. package/dist/semiotic-themes.min.js +1 -1
  114. package/dist/semiotic-themes.module.min.js +1 -1
  115. package/dist/semiotic-utils.d.ts +4 -0
  116. package/dist/semiotic-utils.min.js +1 -1
  117. package/dist/semiotic-utils.module.min.js +1 -1
  118. package/dist/semiotic-xy.d.ts +2 -0
  119. package/dist/semiotic.d.ts +4 -4
  120. package/dist/semiotic.min.js +1 -1
  121. package/dist/semiotic.module.min.js +1 -1
  122. package/dist/server.min.js +1 -1
  123. package/dist/server.module.min.js +1 -1
  124. package/dist/xy.min.js +1 -1
  125. package/dist/xy.module.min.js +1 -1
  126. package/package.json +23 -10
  127. package/dist/components/stream/xySceneBuilders/boundsScene.d.ts +0 -9
@@ -0,0 +1,69 @@
1
+ import type { Datum } from "./datumTypes";
2
+ import type { Accessor, ChartAccessor } from "./types";
3
+ import type { SelectionHookResult, SelectionStyleConfig } from "./selectionUtils";
4
+ export interface XYLineStyleOptions {
5
+ /**
6
+ * Base stroke width. The top-level `strokeWidth` override below
7
+ * wins via `mergeShapeStyle` when both are supplied.
8
+ * @default 2
9
+ */
10
+ lineWidth?: number;
11
+ /** Color accessor (string field name or function). */
12
+ colorBy?: Accessor<string> | ChartAccessor<Datum, string>;
13
+ /** Resolved categorical color scale (typically from useChartSetup). */
14
+ colorScale?: ((v: string) => string);
15
+ /** Static color used as the fallback stroke when `colorBy` is unset. */
16
+ color?: string;
17
+ /** Custom stroke resolver. Wins over `colorBy`/`colorScale`/`color`.
18
+ * Receives the datum and the optional `group` key the frame
19
+ * passes through `resolveLineStyle`. */
20
+ resolveStroke?: (d: Datum, group?: string) => string;
21
+ /** When `true`, every line fills. When a `string[]`, only series
22
+ * whose `group` key appears in the array fill. When omitted/false,
23
+ * no fill is set on the style. */
24
+ fillArea?: boolean | string[];
25
+ /** Fill opacity used when `fillArea` triggers a fill. @default 0.3 */
26
+ areaOpacity?: number;
27
+ stroke?: string;
28
+ strokeWidth?: number;
29
+ opacity?: number;
30
+ /** Selection hook result from `useChartSelection`/`useChartSetup`.
31
+ * Pass `null`/`undefined` to skip dimming entirely (MinimapChart's
32
+ * overview line and main line both skip selection wrapping). */
33
+ effectiveSelectionHook?: SelectionHookResult | null;
34
+ /** Resolved selection style config (matched/unmatched style overrides). */
35
+ resolvedSelection?: SelectionStyleConfig;
36
+ }
37
+ /**
38
+ * Returns a memoized `lineStyle` callback that the XY frame's
39
+ * `resolveLineStyle` invokes with `(datum, group?)`.
40
+ *
41
+ * @example
42
+ * ```tsx
43
+ * // LineChart's recipe collapses to a single hook call:
44
+ * const lineStyle = useXYLineStyle({
45
+ * lineWidth, colorBy, colorScale, color, fillArea, areaOpacity,
46
+ * stroke, strokeWidth, opacity,
47
+ * effectiveSelectionHook, resolvedSelection,
48
+ * })
49
+ * ```
50
+ *
51
+ * @example
52
+ * ```tsx
53
+ * // MultiAxisLineChart hands in a series-aware resolver:
54
+ * const lineStyle = useXYLineStyle({
55
+ * lineWidth,
56
+ * resolveStroke: (d) => seriesColorMap.get(d[SERIES_FIELD]) || seriesColors[0],
57
+ * stroke, strokeWidth, opacity,
58
+ * effectiveSelectionHook: setup.effectiveSelectionHook,
59
+ * resolvedSelection: setup.resolvedSelection,
60
+ * })
61
+ * ```
62
+ *
63
+ * @example
64
+ * ```tsx
65
+ * // MinimapChart's overview line: thin stroke, no selection, no primitives.
66
+ * const overviewLineStyle = useXYLineStyle({ lineWidth: 1, colorBy, colorScale })
67
+ * ```
68
+ */
69
+ export declare function useXYLineStyle(options: XYLineStyleOptions): (d: Datum, group?: string) => Datum;
@@ -0,0 +1,87 @@
1
+ import type { Datum } from "./datumTypes";
2
+ import type { Accessor, ChartAccessor } from "./types";
3
+ import type { SelectionHookResult } from "./selectionUtils";
4
+ export interface XYPointStyleOptions {
5
+ /** colorBy accessor — string field name or function. */
6
+ colorBy?: Accessor<string> | ChartAccessor<Datum, string>;
7
+ /** Resolved categorical color scale (typically from useChartSetup). */
8
+ colorScale: ((v: string) => string) | undefined;
9
+ /** Top-level uniform `color` prop. Used as the fallback fill when
10
+ * `colorBy` is unset. */
11
+ color?: string;
12
+ /**
13
+ * Fixed point radius. When `radiusFn` is supplied, that wins
14
+ * (per-datum sizing for BubbleChart / Scatterplot's `sizeBy`).
15
+ * @default 5
16
+ */
17
+ pointRadius?: number;
18
+ /** Per-datum radius resolver (e.g. wraps `getSize(d, sizeBy, …)`).
19
+ * Ignored when undefined; HOCs with no `sizeBy` should pass it
20
+ * unset and rely on `pointRadius`. */
21
+ radiusFn?: (d: Datum) => number;
22
+ /** Default fillOpacity. Charts override this through their own
23
+ * prop name (`pointOpacity`, `bubbleOpacity`). @default 1 */
24
+ fillOpacity?: number;
25
+ /**
26
+ * Fallback fill resolver invoked when `colorBy` is unset. Used by
27
+ * QuadrantChart to pick a color from the quadrant the point lands
28
+ * in. When omitted, fallback is `color || DEFAULT_COLOR` (the
29
+ * standard Scatterplot/BubbleChart behavior).
30
+ */
31
+ fallbackFill?: (d: Datum) => string;
32
+ /**
33
+ * Static or per-datum extra style applied BEFORE color resolution
34
+ * and primitive overlay. Use for shape-constant defaults
35
+ * (BubbleChart's `{ stroke: bubbleStrokeColor, strokeWidth: 1 }`).
36
+ * If extras supply a `fill`, the standard color resolution is
37
+ * skipped — same bypass as `useOrdinalPieceStyle`. Lets
38
+ * ConnectedScatterplot drop in its viridis-by-order fill.
39
+ */
40
+ baseStyleExtras?: Record<string, string | number | undefined> | ((d: Datum) => Record<string, string | number | undefined>);
41
+ /** Top-level primitive props — applied last via `mergeShapeStyle`. */
42
+ stroke?: string;
43
+ strokeWidth?: number;
44
+ opacity?: number;
45
+ /** Selection hook output (typically `setup.effectiveSelectionHook`). */
46
+ effectiveSelectionHook: SelectionHookResult | null | undefined;
47
+ /** Resolved selection config (typically `setup.resolvedSelection`). */
48
+ resolvedSelection: import("./types").SelectionConfig | undefined;
49
+ /**
50
+ * For ConnectedScatterplot-style charts whose color depends on the
51
+ * point's position in an ordered sequence, the resolver may need
52
+ * the point's parent line. Defaults to identity (`d => d`).
53
+ * Same hook BarChart's `parentLine` cascade uses.
54
+ */
55
+ colorDatumAccessor?: (d: Datum) => Datum;
56
+ }
57
+ /**
58
+ * Build a memoized `pointStyle` function for an XY HOC.
59
+ *
60
+ * @example
61
+ * ```tsx
62
+ * // Scatterplot — sizeBy-driven radius, standard color fallback
63
+ * const pointStyle = useXYPointStyle({
64
+ * colorBy, colorScale: setup.colorScale,
65
+ * color, pointRadius, fillOpacity: pointOpacity,
66
+ * radiusFn: sizeBy ? (d) => getSize(d, sizeBy, sizeRange, sizeDomain) : undefined,
67
+ * stroke, strokeWidth, opacity,
68
+ * effectiveSelectionHook: setup.effectiveSelectionHook,
69
+ * resolvedSelection: setup.resolvedSelection,
70
+ * })
71
+ * ```
72
+ *
73
+ * @example
74
+ * ```tsx
75
+ * // QuadrantChart — bespoke fallback fill from quadrant lookup
76
+ * const pointStyle = useXYPointStyle({
77
+ * colorBy, colorScale: setup.colorScale, color,
78
+ * pointRadius, fillOpacity: pointOpacity,
79
+ * radiusFn: sizeBy ? (d) => getSize(d, sizeBy, sizeRange, sizeDomain) : undefined,
80
+ * fallbackFill: (d) => quadrantColor(d, getXValue, getYValue, xCenter, yCenter, quadrants),
81
+ * stroke, strokeWidth, opacity,
82
+ * effectiveSelectionHook: setup.effectiveSelectionHook,
83
+ * resolvedSelection: setup.resolvedSelection,
84
+ * })
85
+ * ```
86
+ */
87
+ export declare function useXYPointStyle(options: XYPointStyleOptions): (d: Datum) => Record<string, string | number | undefined>;
@@ -27,10 +27,17 @@ export declare function SafeRender({ componentName, width, height, children }: S
27
27
  */
28
28
  export declare function renderEmptyState(data: any[] | undefined | null, width: number, height: number, emptyContent?: React.ReactNode | false): React.ReactElement | null;
29
29
  /**
30
- * Renders a shimmer/skeleton loading placeholder.
31
- * Returns null when loading is false.
30
+ * Renders a loading placeholder while `loading` is true.
31
+ *
32
+ * When `loadingContent` is provided, it replaces the default shimmer
33
+ * skeleton — wrapped in the same sized container so the chart still
34
+ * occupies the slot it would when rendered. Pass `false` to suppress
35
+ * the skeleton entirely (the early-return becomes null and the chart's
36
+ * own loading UI takes over).
37
+ *
38
+ * Returns null when `loading` is falsy.
32
39
  */
33
- export declare function renderLoadingState(loading: boolean | undefined, width: number, height: number): React.ReactElement | null;
40
+ export declare function renderLoadingState(loading: boolean | undefined, width: number, height: number, loadingContent?: React.ReactNode | false): React.ReactElement | null;
34
41
  /** Warn if a string accessor isn't found in the first data element */
35
42
  export declare function warnMissingField(componentName: string, data: any[] | undefined, accessorName: string, accessorValue: any): void;
36
43
  /** Warn if data looks like the wrong shape for this chart type */
@@ -1,10 +1,11 @@
1
1
  import type { Datum } from "../shared/datumTypes";
2
2
  import * as React from "react";
3
- import type { StreamXYFrameProps } from "../../stream/types";
3
+ import type { StreamXYFrameProps, BandConfig } from "../../stream/types";
4
4
  import type { RealtimeFrameHandle } from "../../realtime/types";
5
5
  import type { LegendInteractionMode, LegendPosition } from "../shared/hooks";
6
6
  import type { BaseChartProps, AxisConfig, ChartAccessor } from "../shared/types";
7
7
  import { type TooltipProp } from "../../Tooltip/Tooltip";
8
+ import type { ForecastConfig, AnomalyConfig } from "../shared/statisticalOverlays";
8
9
  /**
9
10
  * AreaChart component props
10
11
  */
@@ -22,7 +23,7 @@ export interface AreaChartProps<TDatum extends Datum = Datum> extends BaseChartP
22
23
  * Field name or function to access x values
23
24
  * @default "x"
24
25
  */
25
- xAccessor?: ChartAccessor<TDatum, number>;
26
+ xAccessor?: ChartAccessor<TDatum, number | Date | string>;
26
27
  /**
27
28
  * Field name or function to access y values
28
29
  * @default "y"
@@ -159,6 +160,39 @@ export interface AreaChartProps<TDatum extends Datum = Datum> extends BaseChartP
159
160
  * Annotation objects to render on the chart
160
161
  */
161
162
  annotations?: Datum[];
163
+ /**
164
+ * Forecast overlay — extends the area with a tagged training /
165
+ * observed / forecast region and (optionally) a confidence
166
+ * envelope. Same shape as LineChart's `forecast` prop. Pair with
167
+ * `anomaly` for combined anomaly + forecast visualization.
168
+ *
169
+ * @example
170
+ * ```tsx
171
+ * <AreaChart data={obs} xAccessor="t" yAccessor="value"
172
+ * forecast={{ trainEnd: 80, steps: 10, color: "#6366f1" }} />
173
+ * ```
174
+ */
175
+ forecast?: ForecastConfig;
176
+ /**
177
+ * Anomaly overlay — adds a ±σ band and per-point anomaly dots.
178
+ * Standalone (without forecast) gives raw anomaly detection.
179
+ *
180
+ * @example
181
+ * ```tsx
182
+ * <AreaChart data={obs} anomaly={{ threshold: 2 }} />
183
+ * ```
184
+ */
185
+ anomaly?: AnomalyConfig;
186
+ /**
187
+ * Asymmetric min/max band(s) drawn under the area fill. Distinct from
188
+ * `y0Accessor` (which replaces the area's baseline) — `band` is a
189
+ * decorative envelope painted beneath the area, driven by independent
190
+ * `y0Accessor` / `y1Accessor` per band. Pass an array for fan charts.
191
+ *
192
+ * The hovered datum gets `band: { y0, y1 }` and `bands: [...]` for
193
+ * tooltip access. See the LineChart docs for full ergonomics.
194
+ */
195
+ band?: BandConfig<TDatum> | Array<BandConfig<TDatum>>;
162
196
  /**
163
197
  * Fixed x domain `[min, max]`. Either bound may be `undefined` to leave
164
198
  * that side data-derived. Useful for pinning a time axis to a known
@@ -5,6 +5,7 @@ import type { RealtimeFrameHandle } from "../../realtime/types";
5
5
  import type { LegendInteractionMode, LegendPosition } from "../shared/hooks";
6
6
  import type { BaseChartProps, AxisConfig, ChartAccessor } from "../shared/types";
7
7
  import { type TooltipProp } from "../../Tooltip/Tooltip";
8
+ import { type RegressionProp } from "../shared/regressionUtils";
8
9
  /**
9
10
  * BubbleChart component props
10
11
  */
@@ -110,6 +111,14 @@ export interface BubbleChartProps<TDatum extends Datum = Datum> extends BaseChar
110
111
  * Annotation objects to render on the chart
111
112
  */
112
113
  annotations?: Datum[];
114
+ /**
115
+ * Overlay a regression line on the bubbles. Accepts `true` (linear
116
+ * with default styling), a method name (`"linear"` | `"polynomial"`
117
+ * | `"loess"`), or a full `RegressionConfig`. Sugar over the `trend`
118
+ * annotation — drop into the `annotations` array directly for richer
119
+ * setups.
120
+ */
121
+ regression?: RegressionProp;
113
122
  /** Fixed x domain `[min, max]` (either bound may be undefined to leave that side data-derived). */
114
123
  xExtent?: [number | undefined, number | undefined] | [number];
115
124
  /** Fixed y domain `[min, max]` (either bound may be undefined to leave that side data-derived). */
@@ -5,6 +5,8 @@ import type { RealtimeFrameHandle } from "../../realtime/types";
5
5
  import type { BaseChartProps, AxisConfig, ChartAccessor } from "../shared/types";
6
6
  import { type TooltipProp } from "../../Tooltip/Tooltip";
7
7
  import type { LegendInteractionMode } from "../shared/hooks";
8
+ import { type RegressionProp } from "../shared/regressionUtils";
9
+ import type { ForecastConfig, AnomalyConfig } from "../shared/statisticalOverlays";
8
10
  /**
9
11
  * ConnectedScatterplot component props
10
12
  */
@@ -37,6 +39,20 @@ export interface ConnectedScatterplotProps<TDatum extends Datum = Datum> extends
37
39
  legendInteraction?: LegendInteractionMode;
38
40
  /** Annotation objects to render on the chart */
39
41
  annotations?: Datum[];
42
+ /**
43
+ * Overlay a regression line under the connected path. Accepts
44
+ * `true`, a method name (`"linear"` | `"polynomial"` | `"loess"`),
45
+ * or a full `RegressionConfig`. Sugar over the `trend` annotation.
46
+ */
47
+ regression?: RegressionProp;
48
+ /**
49
+ * Forecast overlay — same shape as LineChart's `forecast` prop.
50
+ * Adds tagged future points + envelope annotations to the
51
+ * connected path.
52
+ */
53
+ forecast?: ForecastConfig;
54
+ /** Anomaly overlay — adds a ±σ band + anomaly dot annotations. */
55
+ anomaly?: AnomalyConfig;
40
56
  /** Fixed x domain `[min, max]` (either bound may be undefined to leave that side data-derived). */
41
57
  xExtent?: [number | undefined, number | undefined] | [number];
42
58
  /** Fixed y domain `[min, max]` (either bound may be undefined to leave that side data-derived). */
@@ -0,0 +1,172 @@
1
+ import type { Datum } from "../shared/datumTypes";
2
+ import * as React from "react";
3
+ import type { StreamXYFrameProps } from "../../stream/types";
4
+ import type { RealtimeFrameHandle } from "../../realtime/types";
5
+ import type { LegendInteractionMode, LegendPosition } from "../shared/hooks";
6
+ import type { BaseChartProps, AxisConfig, ChartAccessor } from "../shared/types";
7
+ import { type TooltipProp } from "../../Tooltip/Tooltip";
8
+ /**
9
+ * DifferenceChart props
10
+ */
11
+ export interface DifferenceChartProps<TDatum extends Datum = Datum> extends BaseChartProps, AxisConfig {
12
+ /** Array of `{x, a, b}` data points. Omit for push API mode. */
13
+ data?: TDatum[];
14
+ /** Accessor for the x value. Default `"x"`. */
15
+ xAccessor?: ChartAccessor<TDatum, number>;
16
+ /** Accessor for series A. Default `"a"`. */
17
+ seriesAAccessor?: ChartAccessor<TDatum, number>;
18
+ /** Accessor for series B. Default `"b"`. */
19
+ seriesBAccessor?: ChartAccessor<TDatum, number>;
20
+ /** Display label for series A (legend + tooltip). Default `"A"`. */
21
+ seriesALabel?: string;
22
+ /** Display label for series B. Default `"B"`. */
23
+ seriesBLabel?: string;
24
+ /** Fill color when series A is above series B. Default `"var(--semiotic-danger, #dc2626)"`. */
25
+ seriesAColor?: string;
26
+ /** Fill color when series B is above series A. Default `"var(--semiotic-info, #2563eb)"`. */
27
+ seriesBColor?: string;
28
+ /** Show the A and B series as overlay lines on top of the filled difference. Default `true`. */
29
+ showLines?: boolean;
30
+ /** Line stroke width when `showLines` is true. Default `1.5`. */
31
+ lineWidth?: number;
32
+ /** Show data points on the overlay lines. Default `false`. */
33
+ showPoints?: boolean;
34
+ /** Point radius when `showPoints` is true. Default `3`. */
35
+ pointRadius?: number;
36
+ /** Curve interpolation for both the area boundary and overlay lines. Default `"linear"`. */
37
+ curve?: "linear" | "monotoneX" | "monotoneY" | "step" | "stepAfter" | "stepBefore" | "basis" | "cardinal" | "catmullRom";
38
+ /** Fill opacity for the difference region. Default `0.6`. */
39
+ areaOpacity?: number;
40
+ /** Gradient fill across each segment, same shape as AreaChart.gradientFill. */
41
+ gradientFill?: boolean | {
42
+ topOpacity: number;
43
+ bottomOpacity: number;
44
+ } | {
45
+ colorStops: Array<{
46
+ offset: number;
47
+ color: string;
48
+ }>;
49
+ };
50
+ /** Enable hover annotations. */
51
+ enableHover?: boolean;
52
+ /** Show grid lines. Default `false`. */
53
+ showGrid?: boolean;
54
+ /** Show legend. Default `true`. */
55
+ showLegend?: boolean;
56
+ /** Legend interaction mode. */
57
+ legendInteraction?: LegendInteractionMode;
58
+ /** Legend position. */
59
+ legendPosition?: LegendPosition;
60
+ /** Tooltip config. */
61
+ tooltip?: TooltipProp;
62
+ /** Annotation objects. */
63
+ annotations?: Datum[];
64
+ /** Fixed x domain. */
65
+ xExtent?: [number | undefined, number | undefined] | [number];
66
+ /** Fixed y domain. */
67
+ yExtent?: [number | undefined, number | undefined] | [number];
68
+ /** Stable ID accessor for push-mode `remove()` / `update()`. */
69
+ pointIdAccessor?: string | ((d: Datum) => string);
70
+ /** Maximum number of raw rows kept in the push buffer. When exceeded,
71
+ * oldest rows are evicted FIFO (sliding window). Default: unbounded.
72
+ * Recommended for long-running streams so the per-render segment
73
+ * recomputation stays bounded. */
74
+ windowSize?: number;
75
+ /** Pass-through StreamXYFrame props. */
76
+ frameProps?: Partial<Omit<StreamXYFrameProps, "chartType" | "data" | "size">>;
77
+ }
78
+ /**
79
+ * Crossover-segmented record used by the area pipeline. One row per
80
+ * vertex along either the upper or lower boundary; `__diffSegment` is a
81
+ * group key per segment so the area scene builder produces one polygon
82
+ * per id with the correct fill color.
83
+ */
84
+ interface SegmentRow {
85
+ __x: number;
86
+ /** Upper boundary y value (max of A, B). The area pipeline reads this. */
87
+ __y: number;
88
+ /** Lower boundary y value (min of A, B) — picked up as per-datum y0. */
89
+ __y0: number;
90
+ /** Segment id. Format: `"seg-<index>-<winner>"`. */
91
+ __diffSegment: string;
92
+ /** Which series is on top in this segment ("A" or "B"). Drives fill. */
93
+ __diffWinner: "A" | "B";
94
+ /** Original A value at this x (or interpolated at crossovers). */
95
+ __valA: number;
96
+ /** Original B value at this x (or interpolated at crossovers). */
97
+ __valB: number;
98
+ /** Original datum (for tooltip lookup at non-crossover vertices). */
99
+ __sourceDatum?: Datum;
100
+ }
101
+ /**
102
+ * Walk sorted data, splitting at each A↔B crossover. Inserts an
103
+ * interpolated vertex on BOTH sides of every crossover so adjacent
104
+ * segments meet at a zero-width point (no jagged edges).
105
+ *
106
+ * Non-finite rows are skipped; the algorithm tracks the most recent
107
+ * VALID non-tie row (not the index neighbor) for crossover detection,
108
+ * so a non-finite gap doesn't drop a crossover that straddles it.
109
+ *
110
+ * Tie rows (a === b) are handled distinctly from non-tie rows:
111
+ *
112
+ * - When a tie row sits BETWEEN two non-tie rows with the SAME
113
+ * winner, the tie is emitted in that winner's segment as a
114
+ * zero-width vertex.
115
+ * - When a tie row sits between non-tie rows with DIFFERENT winners,
116
+ * the FIRST tie of the run becomes the crossover vertex. The old
117
+ * segment closes at the tie's x, the new segment opens at the same
118
+ * point, and any subsequent tie rows (multi-tie runs) carry into
119
+ * the new segment as zero-width vertices.
120
+ *
121
+ * This preserves the data's actual zero-difference point: if the user
122
+ * supplied a tie row explicitly, the fill switches color exactly at
123
+ * that x rather than at a linear-interpolated x that ignored the tie.
124
+ *
125
+ * Exported for direct unit-testing — the area pipeline depends on the
126
+ * exact crossover-vertex shape produced here.
127
+ */
128
+ export declare function computeDifferenceSegments<TDatum extends Datum>(raw: TDatum[], getX: (d: TDatum) => number, getA: (d: TDatum) => number, getB: (d: TDatum) => number): SegmentRow[];
129
+ /**
130
+ * DifferenceChart — fills the area between two series with a color
131
+ * that switches based on which series is higher at each x. Crossover
132
+ * points are interpolated so segments meet cleanly. Both series can
133
+ * optionally be drawn as overlay lines on top of the fill.
134
+ *
135
+ * Classic uses: temperature anomaly (actual vs. normal), forecast
136
+ * accuracy (actual vs. predicted), budget variance, A/B comparison.
137
+ *
138
+ * @example
139
+ * ```tsx
140
+ * <DifferenceChart
141
+ * data={[
142
+ * { date: 1, actual: 50, forecast: 45 },
143
+ * { date: 2, actual: 52, forecast: 60 },
144
+ * { date: 3, actual: 70, forecast: 58 },
145
+ * ]}
146
+ * xAccessor="date"
147
+ * seriesAAccessor="actual"
148
+ * seriesBAccessor="forecast"
149
+ * seriesALabel="Actual"
150
+ * seriesBLabel="Forecast"
151
+ * />
152
+ * ```
153
+ *
154
+ * @example
155
+ * ```tsx
156
+ * // Streaming via push API — omit `data`, push raw {x, a, b} rows.
157
+ * const ref = useRef<RealtimeFrameHandle>(null)
158
+ * useEffect(() => {
159
+ * const id = setInterval(() => {
160
+ * const t = Date.now()
161
+ * ref.current?.push({ x: t, a: 50 + Math.random() * 10, b: 50 + Math.random() * 10 })
162
+ * }, 500)
163
+ * return () => clearInterval(id)
164
+ * }, [])
165
+ * return <DifferenceChart ref={ref} xAccessor="x" seriesAAccessor="a" seriesBAccessor="b" />
166
+ * ```
167
+ */
168
+ export declare const DifferenceChart: {
169
+ <TDatum extends Datum = Datum>(props: DifferenceChartProps<TDatum> & React.RefAttributes<RealtimeFrameHandle>): React.ReactElement | null;
170
+ displayName?: string;
171
+ };
172
+ export {};
@@ -1,6 +1,6 @@
1
1
  import type { Datum } from "../shared/datumTypes";
2
2
  import * as React from "react";
3
- import type { StreamXYFrameProps } from "../../stream/types";
3
+ import type { StreamXYFrameProps, BandConfig } from "../../stream/types";
4
4
  import type { RealtimeFrameHandle } from "../../realtime/types";
5
5
  import type { LegendInteractionMode } from "../shared/hooks";
6
6
  import type { BaseChartProps, AxisConfig, ChartAccessor } from "../shared/types";
@@ -29,7 +29,7 @@ export interface LineChartProps<TDatum extends Datum = Datum> extends BaseChartP
29
29
  * Field name or function to access x values
30
30
  * @default "x"
31
31
  */
32
- xAccessor?: ChartAccessor<TDatum, number>;
32
+ xAccessor?: ChartAccessor<TDatum, number | Date | string>;
33
33
  /**
34
34
  * Field name or function to access y values
35
35
  * @default "y"
@@ -181,6 +181,30 @@ export interface LineChartProps<TDatum extends Datum = Datum> extends BaseChartP
181
181
  * envelope around the extrapolated forecast region.
182
182
  */
183
183
  forecast?: ForecastConfig;
184
+ /**
185
+ * Asymmetric min/max band(s) drawn under the line. Differs from
186
+ * `forecast`/`anomaly` (computed envelopes around a series) by being
187
+ * pure data passthrough — provide `y0Accessor` / `y1Accessor` and the
188
+ * band is drawn between them at each x.
189
+ *
190
+ * Pass an array for percentile fans (e.g. p25/p75 on top of p10/p90).
191
+ * Each band participates in y-extent auto-derivation, so a tall band
192
+ * can never get clipped. The hovered datum is enriched with
193
+ * `band: { y0, y1 }` (first band) and `bands: [...]` (all bands) so
194
+ * tooltip functions can read the envelope without re-running the
195
+ * accessors.
196
+ *
197
+ * @example
198
+ * ```tsx
199
+ * <LineChart
200
+ * data={[{ time, average, min, max }, ...]}
201
+ * xAccessor="time"
202
+ * yAccessor="average"
203
+ * band={{ y0Accessor: "min", y1Accessor: "max" }}
204
+ * />
205
+ * ```
206
+ */
207
+ band?: BandConfig<TDatum> | Array<BandConfig<TDatum>>;
184
208
  /**
185
209
  * Fixed x domain `[min, max]`. Either bound may be `undefined` to leave
186
210
  * that side data-derived.
@@ -5,6 +5,8 @@ import type { RealtimeFrameHandle } from "../../realtime/types";
5
5
  import type { BaseChartProps, AxisConfig, ChartAccessor } from "../shared/types";
6
6
  import { type TooltipProp } from "../../Tooltip/Tooltip";
7
7
  import type { LegendInteractionMode, LegendPosition } from "../shared/hooks";
8
+ import { type RegressionProp } from "../shared/regressionUtils";
9
+ import type { ForecastConfig, AnomalyConfig } from "../shared/statisticalOverlays";
8
10
  /**
9
11
  * Scatterplot component props
10
12
  */
@@ -12,9 +14,13 @@ export interface ScatterplotProps<TDatum extends Datum = Datum> extends BaseChar
12
14
  /** Array of data points. Each point should have x and y properties. */
13
15
  data?: TDatum[];
14
16
  /** Field name or function to access x values @default "x" */
15
- xAccessor?: ChartAccessor<TDatum, number>;
17
+ xAccessor?: ChartAccessor<TDatum, number | Date | string>;
16
18
  /** Field name or function to access y values @default "y" */
17
19
  yAccessor?: ChartAccessor<TDatum, number>;
20
+ /** X scale type @default "linear" */
21
+ xScaleType?: "linear" | "log" | "time";
22
+ /** Y scale type @default "linear" */
23
+ yScaleType?: "linear" | "log";
18
24
  /** Field name or function to determine point color */
19
25
  colorBy?: ChartAccessor<TDatum, string>;
20
26
  /** Color scheme for categorical data or custom colors array @default "category10" */
@@ -45,6 +51,38 @@ export interface ScatterplotProps<TDatum extends Datum = Datum> extends BaseChar
45
51
  legendPosition?: LegendPosition;
46
52
  /** Annotation objects to render on the chart */
47
53
  annotations?: Datum[];
54
+ /**
55
+ * Overlay a regression line on the scatter. Accepts:
56
+ * - `true` — linear regression with default styling
57
+ * - `"linear"` | `"polynomial"` | `"loess"` — pick a method
58
+ * - `RegressionConfig` — full control (method, bandwidth, order,
59
+ * color, strokeWidth, strokeDasharray, label)
60
+ *
61
+ * Sugar over `annotations={[{ type: "trend", … }]}` — for richer
62
+ * setups (multiple regression lines, custom anchoring) drop into
63
+ * the annotations array directly.
64
+ *
65
+ * @example
66
+ * ```tsx
67
+ * <Scatterplot data={d} xAccessor="x" yAccessor="y" regression />
68
+ * <Scatterplot data={d} xAccessor="x" yAccessor="y" regression="loess" />
69
+ * <Scatterplot data={d} xAccessor="x" yAccessor="y"
70
+ * regression={{ method: "polynomial", order: 3, color: "#ef4444", label: "Cubic" }} />
71
+ * ```
72
+ */
73
+ regression?: RegressionProp;
74
+ /**
75
+ * Forecast overlay — extends the scatter with tagged future
76
+ * points + (optional) confidence-envelope annotations. Same shape
77
+ * as LineChart's `forecast` prop.
78
+ */
79
+ forecast?: ForecastConfig;
80
+ /**
81
+ * Anomaly overlay — adds a ±σ band annotation and per-point
82
+ * anomaly dots. Standalone (without forecast) gives raw anomaly
83
+ * detection on the scatter.
84
+ */
85
+ anomaly?: AnomalyConfig;
48
86
  /** Fixed x domain `[min, max]` (either bound may be undefined to leave that side data-derived). */
49
87
  xExtent?: [number | undefined, number | undefined] | [number];
50
88
  /** Fixed y domain `[min, max]` (either bound may be undefined to leave that side data-derived). */
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Shared ribbon geometry — emits both the SVG path-D string and the
3
+ * centerline cubic-bezier cache for a sankey-style band.
4
+ *
5
+ * Both SankeyDiagram (via `areaLink` in `./sankeyLinks`) and
6
+ * ProcessSankey (via the HOC's ribbon-spec construction) need to
7
+ * draw the same M-C-L-C-Z trapezoid-cap-with-bezier-sides shape and
8
+ * provide a matching 4-point centerline bezier for the particle
9
+ * pool. The two charts compute their inputs differently — Sankey
10
+ * reads (x0/x1/y0/y1, sankeyWidth) from the d3-sankey layout while
11
+ * ProcessSankey computes (sx, sTop, sBot, tx, tTop, tBot, cp1X, cp2X)
12
+ * from its temporal attachment math — but the *emission* is shared.
13
+ *
14
+ * For Sankey: cp1X = xi(curvature), cp2X = xi(1-curvature) (smooth
15
+ * S-curve, symmetric around the midpoint).
16
+ * For ProcessSankey: cp1X = cp2X = cx where `cx` depends on
17
+ * `ribbonLane` ("source"/"target"/"both") — concentrates
18
+ * the bend at a chosen x position.
19
+ */
20
+ import type { BezierCache } from "../stream/networkTypes";
21
+ export interface RibbonGeometryInput {
22
+ /** Source x coordinate. */
23
+ sx: number;
24
+ /** Source band top (y at source end, smaller y). */
25
+ sTop: number;
26
+ /** Source band bottom (y at source end, larger y). */
27
+ sBot: number;
28
+ /** Target x coordinate. */
29
+ tx: number;
30
+ /** Target band top. */
31
+ tTop: number;
32
+ /** Target band bottom. */
33
+ tBot: number;
34
+ /** x of the near-source bezier control point. The top curve uses
35
+ * `(cp1X, sTop)` as its first control point and the bottom curve
36
+ * uses `(cp1X, sBot)` as its last (mirrored). */
37
+ cp1X: number;
38
+ /** x of the near-target bezier control point. The top curve uses
39
+ * `(cp2X, tTop)` as its second control point and the bottom curve
40
+ * uses `(cp2X, tBot)` as its first (mirrored). */
41
+ cp2X: number;
42
+ }
43
+ export interface RibbonGeometryOutput {
44
+ /** Closed SVG path describing the visible ribbon band. */
45
+ pathD: string;
46
+ /** Centerline cubic for the particle pool. Matches the shape
47
+ * `NetworkPipelineStore.buildStandardBezier` produces for sankey
48
+ * edges, so both ribbon kinds drive the shared particle
49
+ * pipeline identically. */
50
+ bezier: BezierCache;
51
+ }
52
+ /**
53
+ * Build both the visible-ribbon path-D and the centerline bezier
54
+ * cache from a single set of geometric inputs.
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * // SankeyDiagram (smooth curvature-based S-curve):
59
+ * const xi = interpolateNumber(source.x1, target.x0)
60
+ * buildRibbonGeometry({
61
+ * sx: source.x1, tx: target.x0,
62
+ * sTop: edge.y0 - edge.sankeyWidth / 2,
63
+ * sBot: edge.y0 + edge.sankeyWidth / 2,
64
+ * tTop: edge.y1 - edge.sankeyWidth / 2,
65
+ * tBot: edge.y1 + edge.sankeyWidth / 2,
66
+ * cp1X: xi(0.5), cp2X: xi(0.5), // curvature defaults to 0.5
67
+ * })
68
+ *
69
+ * // ProcessSankey (lane-aware bend):
70
+ * const cx = ribbonLane === "source" ? sx + (tx - sx) * 0.85
71
+ * : ribbonLane === "target" ? sx + (tx - sx) * 0.15
72
+ * : (sx + tx) / 2
73
+ * buildRibbonGeometry({ sx, sTop, sBot, tx, tTop, tBot, cp1X: cx, cp2X: cx })
74
+ * ```
75
+ */
76
+ export declare function buildRibbonGeometry(input: RibbonGeometryInput): RibbonGeometryOutput;
@@ -1,5 +1,6 @@
1
1
  export { LineChart } from "./charts/xy/LineChart";
2
2
  export { AreaChart } from "./charts/xy/AreaChart";
3
+ export { DifferenceChart } from "./charts/xy/DifferenceChart";
3
4
  export { StackedAreaChart } from "./charts/xy/StackedAreaChart";
4
5
  export { Scatterplot } from "./charts/xy/Scatterplot";
5
6
  export { ConnectedScatterplot } from "./charts/xy/ConnectedScatterplot";
@@ -30,6 +31,7 @@ export { SwimlaneChart } from "./charts/ordinal/SwimlaneChart";
30
31
  export { ForceDirectedGraph } from "./charts/network/ForceDirectedGraph";
31
32
  export { ChordDiagram } from "./charts/network/ChordDiagram";
32
33
  export { SankeyDiagram } from "./charts/network/SankeyDiagram";
34
+ export { ProcessSankey } from "./charts/network/ProcessSankey";
33
35
  export { TreeDiagram } from "./charts/network/TreeDiagram";
34
36
  export { Treemap } from "./charts/network/Treemap";
35
37
  export { CirclePack } from "./charts/network/CirclePack";