semiotic 3.7.4 → 3.7.5
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 +10 -7
- package/README.md +36 -19
- package/ai/schema.json +221 -1
- package/ai/system-prompt.md +2 -1
- package/dist/components/Annotation.d.ts +4 -0
- package/dist/components/DataSummaryContext.d.ts +1 -0
- package/dist/components/ai/chartCapabilityTypes.d.ts +16 -0
- package/dist/components/ai/dataPitfallsBridge.d.ts +101 -0
- package/dist/components/ai/dataQualityBridge.d.ts +201 -0
- package/dist/components/ai/describeChart.d.ts +2 -0
- package/dist/components/ai/generativeChart.d.ts +145 -0
- package/dist/components/charts/custom/NetworkCustomChart.d.ts +14 -1
- package/dist/components/charts/ordinal/SwarmPlot.d.ts +7 -0
- package/dist/components/charts/realtime/RealtimeLineChart.d.ts +21 -0
- package/dist/components/charts/realtime/aggregate.d.ts +51 -0
- package/dist/components/charts/realtime/eventTime.d.ts +26 -0
- package/dist/components/charts/shared/colorPalettes.d.ts +2 -0
- package/dist/components/charts/shared/colorUtils.d.ts +1 -12
- package/dist/components/charts/shared/minMax.d.ts +3 -0
- package/dist/components/charts/shared/radialGeometry.d.ts +0 -18
- package/dist/components/charts/shared/smartTooltip.d.ts +27 -0
- package/dist/components/charts/shared/statisticalOverlays.d.ts +35 -0
- package/dist/components/charts/shared/tooltipUtils.d.ts +2 -0
- package/dist/components/charts/shared/useChartSetup.d.ts +1 -1
- package/dist/components/charts/shared/useCustomChartSetup.d.ts +1 -1
- package/dist/components/charts/shared/validateChartData.d.ts +1 -1
- package/dist/components/charts/xy/Scatterplot.d.ts +9 -0
- package/dist/components/data/fromArrow.d.ts +54 -0
- package/dist/components/data/fromMermaid.d.ts +47 -0
- package/dist/components/data/fromObservablePlot.d.ts +69 -0
- package/dist/components/data/portability/index.d.ts +14 -0
- package/dist/components/data/portability/spec.d.ts +129 -0
- package/dist/components/data/portability/vegaLite.d.ts +62 -0
- package/dist/components/realtime/ReorderBuffer.d.ts +54 -0
- package/dist/components/realtime/RunningStats.d.ts +66 -0
- package/dist/components/realtime/WindowAccumulator.d.ts +105 -0
- package/dist/components/realtime/parseWindowDuration.d.ts +12 -0
- package/dist/components/recipes/customTooltip.d.ts +31 -0
- package/dist/components/recipes/gofish.d.ts +207 -0
- package/dist/components/recipes/gofishBoba.d.ts +23 -0
- package/dist/components/recipes/gofishIR.d.ts +169 -0
- package/dist/components/recipes/gofishIRExamples.d.ts +89 -0
- package/dist/components/recipes/gofishInterpreter.d.ts +52 -0
- package/dist/components/recipes/gofishLambdas.d.ts +145 -0
- package/dist/components/recipes/mermaidDag.d.ts +44 -0
- package/dist/components/recipes/packedClusterMatrix.d.ts +166 -0
- package/dist/components/recipes/recipeChrome.d.ts +100 -0
- package/dist/components/recipes/recipeLegend.d.ts +57 -0
- package/dist/components/recipes/recipeUtils.d.ts +105 -0
- package/dist/components/semiotic-ai.d.ts +6 -0
- package/dist/components/semiotic-data.d.ts +2 -0
- package/dist/components/semiotic-experimental.d.ts +20 -0
- package/dist/components/semiotic-network.d.ts +3 -1
- package/dist/components/semiotic-ordinal.d.ts +2 -0
- package/dist/components/semiotic-realtime.d.ts +9 -1
- package/dist/components/semiotic-recipes.d.ts +18 -1
- package/dist/components/semiotic-themes.d.ts +2 -0
- package/dist/components/semiotic-xy.d.ts +2 -0
- package/dist/components/semiotic.d.ts +4 -0
- package/dist/components/store/ObservationStore.d.ts +21 -2
- package/dist/components/store/SelectionStore.d.ts +1 -1
- package/dist/components/store/ThemeStore.d.ts +1 -1
- package/dist/components/store/TooltipStore.d.ts +1 -1
- package/dist/components/store/createStore.d.ts +1 -1
- package/dist/components/store/designTokens.d.ts +15 -0
- package/dist/components/stream/NetworkHtmlMarksLayer.d.ts +44 -0
- package/dist/components/stream/NetworkPipelineStore.d.ts +32 -0
- package/dist/components/stream/NetworkSVGOverlay.d.ts +12 -0
- package/dist/components/stream/OrdinalPipelineStore.d.ts +18 -0
- package/dist/components/stream/PipelineStore.d.ts +27 -0
- package/dist/components/stream/SceneGraph.d.ts +5 -1
- package/dist/components/stream/customLayout.d.ts +20 -0
- package/dist/components/stream/customLayoutDiagnostics.d.ts +11 -0
- package/dist/components/stream/customLayoutSelection.d.ts +52 -0
- package/dist/components/stream/networkCustomLayout.d.ts +66 -1
- package/dist/components/stream/networkTypes.d.ts +29 -1
- package/dist/components/stream/ordinalCustomLayout.d.ts +17 -1
- package/dist/components/stream/ordinalSceneBuilders/types.d.ts +2 -0
- package/dist/components/stream/ordinalTypes.d.ts +19 -3
- package/dist/components/stream/renderers/networkSymbolRenderer.d.ts +2 -0
- package/dist/components/stream/renderers/symbolCanvasRenderer.d.ts +2 -0
- package/dist/components/stream/stalenessBands.d.ts +28 -0
- package/dist/components/stream/symbolPath.d.ts +24 -0
- package/dist/components/stream/types.d.ts +72 -3
- package/dist/components/stream/useStalenessCheck.d.ts +6 -1
- package/dist/components/stream/xySceneBuilders/pointScene.d.ts +2 -2
- package/dist/components/stream/xySceneBuilders/types.d.ts +5 -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-semiotic-ai-u954ylUn.js +2 -0
- package/dist/semiotic-ai-statisticalOverlays-CU7jW05Q.js +1 -0
- package/dist/semiotic-ai.d.ts +6 -0
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-data.d.ts +2 -0
- package/dist/semiotic-data.min.js +1 -1
- package/dist/semiotic-data.module.min.js +1 -1
- package/dist/semiotic-experimental.d.ts +20 -0
- package/dist/semiotic-experimental.min.js +1 -0
- package/dist/semiotic-experimental.module.min.js +1 -0
- package/dist/semiotic-network.d.ts +3 -1
- package/dist/semiotic-ordinal.d.ts +2 -0
- package/dist/semiotic-realtime.d.ts +9 -1
- package/dist/semiotic-recipes.d.ts +18 -1
- package/dist/semiotic-recipes.min.js +1 -1
- package/dist/semiotic-recipes.module.min.js +1 -1
- package/dist/semiotic-semiotic-BmrYbi99.js +2 -0
- package/dist/semiotic-statisticalOverlays-IjZw8Lsu.js +1 -0
- package/dist/semiotic-themes.d.ts +2 -0
- 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-value.min.js +1 -1
- package/dist/semiotic-value.module.min.js +1 -1
- package/dist/semiotic-xy.d.ts +2 -0
- package/dist/semiotic.d.ts +4 -0
- 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/xy-semiotic-xy-Dufu3D0-.js +2 -0
- package/dist/xy-statisticalOverlays-3Ni9bRph.js +1 -0
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +11 -3
- package/dist/semiotic-ai-statisticalOverlays-C2PPlmXv.js +0 -1
- package/dist/semiotic-statisticalOverlays-C3DsOgr_.js +0 -1
- package/dist/xy-statisticalOverlays-C2PPlmXv.js +0 -1
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Data-quality → provenanced-annotation bridge.
|
|
3
|
+
*
|
|
4
|
+
* Ingests data-quality results — dbt source-freshness + test artifacts, Great
|
|
5
|
+
* Expectations validation results, or a normalized form anyone can hand-build —
|
|
6
|
+
* and maps them to **provenanced, lifecycled chart annotations**. A failed dbt
|
|
7
|
+
* freshness check becomes a danger threshold on the chart that says *who* found
|
|
8
|
+
* it (a system rule), *how* (a freshness rule), *when*, and against *which data
|
|
9
|
+
* snapshot* — so the chart's communicative act flips from report to alert,
|
|
10
|
+
* driven entirely by external metadata.
|
|
11
|
+
*
|
|
12
|
+
* Doctrine this module honors:
|
|
13
|
+
* - Pure, no React, no new dependencies — it shapes plain JSON into the
|
|
14
|
+
* `Annotated[]` surface that already ships (`withProvenance` + the lifecycle
|
|
15
|
+
* helpers do the rest).
|
|
16
|
+
* - **Read-only overlay.** It consumes a data-quality system's output and never
|
|
17
|
+
* writes back into it. Clicking the chart does not trigger a dbt run.
|
|
18
|
+
* - **Refuse rather than mistranslate.** A check with no faithful chart
|
|
19
|
+
* coordinate (a `not_null` test, a uniqueness expectation) is NOT given a
|
|
20
|
+
* fabricated position — it is returned in `unplaced[]` with a reason, so the
|
|
21
|
+
* 30% an adapter can't place is announced rather than hidden.
|
|
22
|
+
*
|
|
23
|
+
* The data-quality system owns query execution, governance, and the test
|
|
24
|
+
* definitions; this bridge owns only the visual overlay and its provenance.
|
|
25
|
+
*/
|
|
26
|
+
import type { Datum } from "../charts/shared/datumTypes";
|
|
27
|
+
import type { AnnotationAnchor, AnnotationBasis, AnnotationStatus, Annotated } from "./annotationProvenance";
|
|
28
|
+
export type DataQualityStatus = "pass" | "fail" | "warn" | "error";
|
|
29
|
+
/**
|
|
30
|
+
* How a check relates to a chart. Only the kinds with a clear visual analog
|
|
31
|
+
* produce an annotation; the rest are reported as `unplaced`.
|
|
32
|
+
*/
|
|
33
|
+
export type DataQualityCheckKind = "range" | "min" | "max" | "threshold" | "freshness" | "not-null" | "unique" | "accepted-values" | "row-condition" | "custom";
|
|
34
|
+
/**
|
|
35
|
+
* A single data-quality result, normalized across source systems. The dbt and
|
|
36
|
+
* Great-Expectations parsers produce these; consumers can also hand-build them
|
|
37
|
+
* (e.g. to bridge Monte Carlo or a bespoke checker).
|
|
38
|
+
*/
|
|
39
|
+
export interface DataQualityResult {
|
|
40
|
+
/** Stable id of the check (test/expectation id). Becomes provenance.stableId. */
|
|
41
|
+
id: string;
|
|
42
|
+
/** Human-readable check name; falls back to id. Doubles as the provenance author. */
|
|
43
|
+
name?: string;
|
|
44
|
+
/** Concise phrase drawn on the chart. Falls back to `name`. Keep it short. */
|
|
45
|
+
label?: string;
|
|
46
|
+
status: DataQualityStatus;
|
|
47
|
+
kind: DataQualityCheckKind;
|
|
48
|
+
/** Column/field the check applies to (mapped through `fieldMap`). */
|
|
49
|
+
column?: string;
|
|
50
|
+
/** Lower bound (range/min). */
|
|
51
|
+
min?: number;
|
|
52
|
+
/** Upper bound (range/max). */
|
|
53
|
+
max?: number;
|
|
54
|
+
/** Single reference value (threshold/min/max). */
|
|
55
|
+
value?: number;
|
|
56
|
+
/** Freshness deadline or observed event time (ISO string or epoch ms). */
|
|
57
|
+
at?: string | number;
|
|
58
|
+
/** Free-form detail surfaced in the label. */
|
|
59
|
+
message?: string;
|
|
60
|
+
/** Source system. */
|
|
61
|
+
source?: "dbt" | "great-expectations" | (string & {});
|
|
62
|
+
/** Evidence type. Defaults to "rule" (deterministic constraint). */
|
|
63
|
+
basis?: AnnotationBasis;
|
|
64
|
+
/** 0–1; surfaced in the label only when < 1 (a hard rule needs no percent). */
|
|
65
|
+
confidence?: number;
|
|
66
|
+
/** ISO timestamp the check ran. */
|
|
67
|
+
createdAt?: string;
|
|
68
|
+
/** Data snapshot id (dbt invocation_id, GE run id). */
|
|
69
|
+
dataVersion?: string;
|
|
70
|
+
/** Failing-row count etc., surfaced in the label. */
|
|
71
|
+
observedCount?: number;
|
|
72
|
+
}
|
|
73
|
+
export interface DataQualityAnnotationOptions {
|
|
74
|
+
/** Map normalized column names → chart accessor field names. */
|
|
75
|
+
fieldMap?: Record<string, string>;
|
|
76
|
+
/** Which axis numeric thresholds map onto. Default "y". (Ranges always band on y.) */
|
|
77
|
+
valueAxis?: "x" | "y";
|
|
78
|
+
/** TTL applied to every generated annotation's lifecycle — drives freshness decay. */
|
|
79
|
+
ttlHint?: string | number;
|
|
80
|
+
/** Surface passing checks too (default false — only failures/warnings overlay). */
|
|
81
|
+
includePassed?: boolean;
|
|
82
|
+
/** Editorial status stamped on generated notes. Default "proposed". */
|
|
83
|
+
status?: AnnotationStatus;
|
|
84
|
+
/** Anchor mode. Default "semantic" so notes re-resolve through stableId on refresh. */
|
|
85
|
+
anchor?: AnnotationAnchor;
|
|
86
|
+
/** Color for failing/erroring checks. Default CSS var --semiotic-danger. */
|
|
87
|
+
failColor?: string;
|
|
88
|
+
/** Color for warnings. Default CSS var --semiotic-warning. */
|
|
89
|
+
warnColor?: string;
|
|
90
|
+
/** Color for passing checks (only used when includePassed). Default --semiotic-success. */
|
|
91
|
+
passColor?: string;
|
|
92
|
+
}
|
|
93
|
+
/** A result the bridge declined to place, with the reason (the D7 honesty surface). */
|
|
94
|
+
export interface UnplacedDataQualityResult {
|
|
95
|
+
result: DataQualityResult;
|
|
96
|
+
reason: string;
|
|
97
|
+
}
|
|
98
|
+
export interface DataQualityAnnotationsResult {
|
|
99
|
+
/** Annotations ready to pass to a chart's `annotations` prop. */
|
|
100
|
+
annotations: Annotated<Datum>[];
|
|
101
|
+
/** Results with no faithful chart coordinate, each with a reason. */
|
|
102
|
+
unplaced: UnplacedDataQualityResult[];
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Map normalized data-quality results to provenanced annotations. The pure core
|
|
106
|
+
* both the dbt and Great-Expectations parsers funnel through; call it directly
|
|
107
|
+
* to bridge any other checker.
|
|
108
|
+
*/
|
|
109
|
+
export declare function dataQualityToAnnotations(results: ReadonlyArray<DataQualityResult>, options?: DataQualityAnnotationOptions): DataQualityAnnotationsResult;
|
|
110
|
+
/** Subset of a dbt artifact's `metadata` block we read. */
|
|
111
|
+
interface DbtMetadata {
|
|
112
|
+
generated_at?: string;
|
|
113
|
+
invocation_id?: string;
|
|
114
|
+
}
|
|
115
|
+
/** A `sources.json` (source-freshness) result entry. */
|
|
116
|
+
interface DbtFreshnessResult {
|
|
117
|
+
unique_id?: string;
|
|
118
|
+
status?: string;
|
|
119
|
+
max_loaded_at?: string;
|
|
120
|
+
snapshotted_at?: string;
|
|
121
|
+
criteria?: {
|
|
122
|
+
warn_after?: {
|
|
123
|
+
count?: number;
|
|
124
|
+
period?: string;
|
|
125
|
+
};
|
|
126
|
+
error_after?: {
|
|
127
|
+
count?: number;
|
|
128
|
+
period?: string;
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
/** A `run_results.json` result entry (we read the test-relevant fields). */
|
|
133
|
+
interface DbtRunResult {
|
|
134
|
+
unique_id?: string;
|
|
135
|
+
status?: string;
|
|
136
|
+
failures?: number | null;
|
|
137
|
+
message?: string | null;
|
|
138
|
+
}
|
|
139
|
+
export interface DbtArtifacts {
|
|
140
|
+
/** Parsed `sources.json` (dbt source freshness). */
|
|
141
|
+
sources?: {
|
|
142
|
+
metadata?: DbtMetadata;
|
|
143
|
+
results?: ReadonlyArray<DbtFreshnessResult>;
|
|
144
|
+
};
|
|
145
|
+
/** Parsed `run_results.json`. */
|
|
146
|
+
runResults?: {
|
|
147
|
+
metadata?: DbtMetadata;
|
|
148
|
+
results?: ReadonlyArray<DbtRunResult>;
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Map dbt artifacts to provenanced annotations. The strongest mapping is source
|
|
153
|
+
* freshness (`sources.json`) — a real timestamp + status becomes a time
|
|
154
|
+
* threshold. Test results (`run_results.json`) carry pass/fail but not, without
|
|
155
|
+
* `manifest.json`, the column/range semantics needed to place them; those land
|
|
156
|
+
* in `unplaced[]` with a reason (D7).
|
|
157
|
+
*/
|
|
158
|
+
export declare function fromDbtArtifacts(artifacts: DbtArtifacts, options?: DataQualityAnnotationOptions): DataQualityAnnotationsResult;
|
|
159
|
+
interface GEExpectationConfig {
|
|
160
|
+
expectation_type?: string;
|
|
161
|
+
kwargs?: {
|
|
162
|
+
column?: string;
|
|
163
|
+
min_value?: number | null;
|
|
164
|
+
max_value?: number | null;
|
|
165
|
+
value?: number | null;
|
|
166
|
+
[key: string]: unknown;
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
interface GEResultEntry {
|
|
170
|
+
success?: boolean;
|
|
171
|
+
expectation_config?: GEExpectationConfig;
|
|
172
|
+
result?: {
|
|
173
|
+
observed_value?: number | string;
|
|
174
|
+
element_count?: number;
|
|
175
|
+
unexpected_count?: number;
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
export interface GEValidationResult {
|
|
179
|
+
success?: boolean;
|
|
180
|
+
results?: ReadonlyArray<GEResultEntry>;
|
|
181
|
+
meta?: {
|
|
182
|
+
run_id?: {
|
|
183
|
+
run_name?: string;
|
|
184
|
+
run_time?: string;
|
|
185
|
+
} | string;
|
|
186
|
+
[key: string]: unknown;
|
|
187
|
+
};
|
|
188
|
+
statistics?: {
|
|
189
|
+
evaluated_expectations?: number;
|
|
190
|
+
successful_expectations?: number;
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Map a Great Expectations validation result to provenanced annotations.
|
|
195
|
+
* Range expectations (`expect_*_to_be_between`) become bands; single-bound
|
|
196
|
+
* expectations become thresholds. Set/uniqueness/null expectations have no
|
|
197
|
+
* single chart coordinate and are returned in `unplaced[]`. GE expectations are
|
|
198
|
+
* statistical assertions, so `basis` defaults to "statistical-test".
|
|
199
|
+
*/
|
|
200
|
+
export declare function fromGreatExpectations(validation: GEValidationResult, options?: DataQualityAnnotationOptions): DataQualityAnnotationsResult;
|
|
201
|
+
export {};
|
|
@@ -99,6 +99,8 @@ export declare function communicativeActForIntent(intent: IntentId): Communicati
|
|
|
99
99
|
* family classification. Returns undefined only when nothing identifies it.
|
|
100
100
|
*/
|
|
101
101
|
export declare function resolveCommunicativeAct(component: string, context: ChartCapability | DescribeCapabilityContext | undefined): CommunicativeAct | undefined;
|
|
102
|
+
/** True when props carry a provenanced, system/agent-generated alert annotation. */
|
|
103
|
+
export declare function hasGeneratedAlertAnnotation(props: Datum): boolean;
|
|
102
104
|
/** Build a number formatter — compact (6.5M) for large magnitudes, plain
|
|
103
105
|
* otherwise. Exported so the navigation tree formats values identically. */
|
|
104
106
|
export declare function chartValueFormatter(locale?: string): (n: number) => string;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generative-UI trust layer.
|
|
3
|
+
*
|
|
4
|
+
* "Generation is cheap; trust is scarce." An LLM can emit chart code in a
|
|
5
|
+
* sentence — but hand-written JSX breaks on first paint, and a plausible-looking
|
|
6
|
+
* chart for the wrong data misleads exactly the reader who can't tell. This
|
|
7
|
+
* module is the trust layer an AI framework wraps around chart generation: it
|
|
8
|
+
* turns an LLM's *proposal* (a component name + props) into a result that is
|
|
9
|
+
* either guaranteed-renderable or accompanied by structured reasons and ranked
|
|
10
|
+
* alternatives to retry with — never a broken chart.
|
|
11
|
+
*
|
|
12
|
+
* It composes the already-shipped surface into the documented loop —
|
|
13
|
+
* **generate → validate → diagnose → repair → render+prove** — and rides
|
|
14
|
+
* `ChartConfig`, the gate-defended public artifact. It is framework-agnostic by
|
|
15
|
+
* construction: no Vercel/LangChain/OpenAI/Anthropic SDK enters the library
|
|
16
|
+
* (the tool-definition shapers below are pure object transforms over JSON
|
|
17
|
+
* Schema). The one heavy step — rendering to SVG with render evidence — is
|
|
18
|
+
* *dependency-injected* (`RenderFn`), so this module stays free of server deps
|
|
19
|
+
* and usable in a browser, an edge runtime, or a notebook.
|
|
20
|
+
*/
|
|
21
|
+
import type { Datum } from "../charts/shared/datumTypes";
|
|
22
|
+
import type { ChartConfig } from "../export/chartConfig";
|
|
23
|
+
import type { ValidationResult } from "../charts/shared/validateProps";
|
|
24
|
+
import type { Diagnosis } from "../charts/shared/diagnoseConfig";
|
|
25
|
+
import type { RepairResult } from "./repairChartConfig";
|
|
26
|
+
import type { IntentId } from "./intents";
|
|
27
|
+
import type { RenderEvidence } from "../server/renderEvidence";
|
|
28
|
+
/**
|
|
29
|
+
* A renderer that turns a validated config into SVG + render evidence. Inject
|
|
30
|
+
* `renderChartWithEvidence` from `semiotic/server` in Node/SSR; omit it in the
|
|
31
|
+
* browser (the helper still validates, diagnoses, repairs, and emits JSX).
|
|
32
|
+
*/
|
|
33
|
+
export type RenderFn = (component: string, props: Datum) => {
|
|
34
|
+
svg: string;
|
|
35
|
+
evidence: RenderEvidence;
|
|
36
|
+
};
|
|
37
|
+
export interface PrepareChartInput {
|
|
38
|
+
/** Chart component name the model proposed (e.g. "LineChart"). */
|
|
39
|
+
component: string;
|
|
40
|
+
/** Props the model proposed. */
|
|
41
|
+
props?: Datum;
|
|
42
|
+
}
|
|
43
|
+
export interface PrepareChartOptions {
|
|
44
|
+
/**
|
|
45
|
+
* The dataset, used to route a repair when the proposed chart is unknown or a
|
|
46
|
+
* poor fit. When present, `repair` runs by default.
|
|
47
|
+
*/
|
|
48
|
+
data?: ReadonlyArray<Datum>;
|
|
49
|
+
/** Ranking intent passed to repair's alternative search. */
|
|
50
|
+
intent?: IntentId | IntentId[];
|
|
51
|
+
/** Run `diagnoseConfig` anti-pattern checks (default true). */
|
|
52
|
+
diagnose?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Run repair routing (fit check + ranked alternatives). Default: true when
|
|
55
|
+
* `data` is provided, false otherwise (repair needs the data to profile).
|
|
56
|
+
*/
|
|
57
|
+
repair?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Inject a renderer to prove the config paints (and to read render evidence —
|
|
60
|
+
* the first-try oracle). When omitted, the result has no `svg`/`evidence`,
|
|
61
|
+
* and `ok` is decided on validation + diagnostics alone.
|
|
62
|
+
*/
|
|
63
|
+
render?: RenderFn;
|
|
64
|
+
/**
|
|
65
|
+
* Treat error-severity diagnostics as blocking `ok` (default true). Set false
|
|
66
|
+
* to let a caller surface warnings without failing the gate.
|
|
67
|
+
*/
|
|
68
|
+
treatErrorsAsBlocking?: boolean;
|
|
69
|
+
}
|
|
70
|
+
export interface PrepareChartResult {
|
|
71
|
+
/**
|
|
72
|
+
* True only when the proposal is trustworthy: it validates, carries no
|
|
73
|
+
* error-severity diagnostics, and — if a renderer was injected — produced a
|
|
74
|
+
* non-empty scene. A `false` result is the signal to retry with `reasons` and
|
|
75
|
+
* `repair.alternatives`, never to paint.
|
|
76
|
+
*/
|
|
77
|
+
ok: boolean;
|
|
78
|
+
component: string;
|
|
79
|
+
props: Datum;
|
|
80
|
+
/** The serializable, validated config — present whenever the component is known. */
|
|
81
|
+
config?: ChartConfig;
|
|
82
|
+
/** JSX string for the validated config (only when a config could be built). */
|
|
83
|
+
jsx?: string;
|
|
84
|
+
/** Structural validation: required props, types, enums, accessor/data shape. */
|
|
85
|
+
validation: ValidationResult;
|
|
86
|
+
/** Anti-pattern diagnostics (empty data, misleading design, contrast, …). */
|
|
87
|
+
diagnostics: Diagnosis[];
|
|
88
|
+
/** Fit verdict + ranked alternatives, when repair ran. */
|
|
89
|
+
repair?: RepairResult;
|
|
90
|
+
/** Render evidence (mark count, domains, ariaLabel, …) when a renderer ran. */
|
|
91
|
+
evidence?: RenderEvidence;
|
|
92
|
+
/** Rendered SVG when a renderer ran. */
|
|
93
|
+
svg?: string;
|
|
94
|
+
/** Human-readable reasons the proposal is not `ok` (empty when `ok`). */
|
|
95
|
+
reasons: string[];
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Run an LLM chart proposal through the trust loop. Pure except for any side
|
|
99
|
+
* effects of an injected `render` function.
|
|
100
|
+
*/
|
|
101
|
+
export declare function prepareChart(input: PrepareChartInput, options?: PrepareChartOptions): PrepareChartResult;
|
|
102
|
+
/**
|
|
103
|
+
* A tool definition expressed as JSON Schema — the common denominator every
|
|
104
|
+
* agent framework accepts. Mirrors the MCP `renderChart` contract so an
|
|
105
|
+
* in-process tool and the MCP server speak the same shape.
|
|
106
|
+
*/
|
|
107
|
+
export interface ChartToolDefinition {
|
|
108
|
+
name: string;
|
|
109
|
+
description: string;
|
|
110
|
+
/** JSON Schema for the tool input. */
|
|
111
|
+
inputSchema: Record<string, unknown>;
|
|
112
|
+
}
|
|
113
|
+
export interface ChartToolOptions {
|
|
114
|
+
/** Override the tool name (default "render_semiotic_chart"). */
|
|
115
|
+
name?: string;
|
|
116
|
+
/** Restrict the component enum to this allow-list (default: the whole registry). */
|
|
117
|
+
components?: ReadonlyArray<string>;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Build a framework-agnostic tool definition for generating a Semiotic chart.
|
|
121
|
+
* Pass it (or a shaper's output) to your agent framework, and pair it with
|
|
122
|
+
* {@link createChartToolHandler} for the execute step.
|
|
123
|
+
*/
|
|
124
|
+
export declare function chartGenerationTool(options?: ChartToolOptions): ChartToolDefinition;
|
|
125
|
+
/** Shape a tool definition for the Anthropic Messages API `tools` array. */
|
|
126
|
+
export declare function toAnthropicTool(def: ChartToolDefinition): {
|
|
127
|
+
name: string;
|
|
128
|
+
description: string;
|
|
129
|
+
input_schema: Record<string, unknown>;
|
|
130
|
+
};
|
|
131
|
+
/** Shape a tool definition for the OpenAI / function-calling `tools` array. */
|
|
132
|
+
export declare function toOpenAITool(def: ChartToolDefinition): {
|
|
133
|
+
type: "function";
|
|
134
|
+
function: {
|
|
135
|
+
name: string;
|
|
136
|
+
description: string;
|
|
137
|
+
parameters: Record<string, unknown>;
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* Build the execute handler for the chart tool: it runs {@link prepareChart} on
|
|
142
|
+
* the tool input and returns the trust-loop result. Inject a `render` fn (from
|
|
143
|
+
* `semiotic/server`) and/or the `data` for fit checking via `optionsFor`.
|
|
144
|
+
*/
|
|
145
|
+
export declare function createChartToolHandler(optionsFor?: (input: PrepareChartInput) => PrepareChartOptions): (input: PrepareChartInput) => PrepareChartResult;
|
|
@@ -22,11 +22,24 @@ export interface NetworkCustomChartProps<TNode extends Datum = Datum, TEdge exte
|
|
|
22
22
|
/** Color scheme threaded into the layout's `resolveColor` helper. */
|
|
23
23
|
colorScheme?: string | string[];
|
|
24
24
|
enableHover?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Annotations rendered over the chart. A custom network layout's marks are
|
|
27
|
+
* anchorable by id: emit a scene node with `id: <foo>` and an annotation with
|
|
28
|
+
* `pointId: "<foo>"` resolves to that mark's center (the editorial-callout
|
|
29
|
+
* story, now unified with the built-in network charts). Data-coordinate
|
|
30
|
+
* anchoring doesn't apply — custom layouts own their own geometry — so anchor
|
|
31
|
+
* by `pointId`, or draw bespoke callouts with the recipe chrome kit's
|
|
32
|
+
* `markCallout`.
|
|
33
|
+
*/
|
|
34
|
+
annotations?: StreamNetworkFrameProps["annotations"];
|
|
35
|
+
/** Collision-avoiding auto-placement for the annotations above. */
|
|
36
|
+
autoPlaceAnnotations?: StreamNetworkFrameProps["autoPlaceAnnotations"];
|
|
25
37
|
/**
|
|
26
38
|
* Custom layouts own their own color resolution (the layout function
|
|
27
39
|
* decides what each node looks like), so the auto-legend infrastructure
|
|
28
40
|
* the built-in network HOCs use can't run. To render a legend, build a
|
|
29
|
-
* `legendGroups` array yourself and pass it through
|
|
41
|
+
* `legendGroups` array yourself (see `legendGroupsFrom`) and pass it through
|
|
42
|
+
* `frameProps.legend`.
|
|
30
43
|
*/
|
|
31
44
|
/** Additional StreamNetworkFrame props for advanced customization. */
|
|
32
45
|
frameProps?: Partial<Omit<StreamNetworkFrameProps, "nodes" | "edges" | "chartType" | "size" | "customNetworkLayout" | "layoutConfig" | "layoutSelection">>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Datum } from "../shared/datumTypes";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import type { StreamOrdinalFrameProps } from "../../stream/ordinalTypes";
|
|
4
|
+
import type { SymbolName } from "../../stream/symbolPath";
|
|
4
5
|
import type { LegendInteractionMode, LegendPosition } from "../shared/hooks";
|
|
5
6
|
import type { BaseChartProps, ChartAccessor, CategoryFormatFn } from "../shared/types";
|
|
6
7
|
import { type TooltipProp } from "../../Tooltip/Tooltip";
|
|
@@ -17,6 +18,12 @@ export interface SwarmPlotProps<TDatum extends Datum = Datum> extends BaseChartP
|
|
|
17
18
|
colorScheme?: string | string[];
|
|
18
19
|
sizeBy?: ChartAccessor<TDatum, number>;
|
|
19
20
|
sizeRange?: [number, number];
|
|
21
|
+
/** Field name or function → glyph **shape**: each point renders as a d3-shape
|
|
22
|
+
* glyph instead of a circle. Pair with `symbolMap` for stable, legend-matchable
|
|
23
|
+
* shapes; unmapped categories auto-assign. Size still tracks `sizeBy`/`pointRadius`. */
|
|
24
|
+
symbolBy?: ChartAccessor<TDatum, string>;
|
|
25
|
+
/** Explicit `{category → shape}` map for `symbolBy`; unmapped auto-assign. */
|
|
26
|
+
symbolMap?: Record<string, SymbolName>;
|
|
20
27
|
pointRadius?: number;
|
|
21
28
|
pointOpacity?: number;
|
|
22
29
|
categoryPadding?: number;
|
|
@@ -7,6 +7,8 @@ import type { ChartMode, ChartAccessor, SelectionConfig } from "../shared/types"
|
|
|
7
7
|
import type { OnObservationCallback } from "../../store/ObservationStore";
|
|
8
8
|
import type { Datum } from "../shared/datumTypes";
|
|
9
9
|
import type { AutoPlaceAnnotations } from "../../recipes/annotationLayout";
|
|
10
|
+
import { type AggregateConfig } from "./aggregate";
|
|
11
|
+
import { type EventTimeConfig } from "./eventTime";
|
|
10
12
|
export interface RealtimeLineChartProps<TDatum extends Datum = Datum> {
|
|
11
13
|
/** Display mode: "primary" (full chrome), "context" (compact), "sparkline" (inline) */
|
|
12
14
|
mode?: ChartMode;
|
|
@@ -106,6 +108,25 @@ export interface RealtimeLineChartProps<TDatum extends Datum = Datum> {
|
|
|
106
108
|
legendInteraction?: LegendInteractionMode;
|
|
107
109
|
/** ID accessor for remove()/update() on the push API */
|
|
108
110
|
pointIdAccessor?: string | ((d: Datum) => string);
|
|
111
|
+
/**
|
|
112
|
+
* Opt-in windowed aggregation over event-time. When set, pushed
|
|
113
|
+
* events are reduced into tumbling/hopping/session windows and the
|
|
114
|
+
* chart draws one mark per window (mean/sum/min/max/count) plus an
|
|
115
|
+
* optional ±σ or min–max band — render cost scales with the number of
|
|
116
|
+
* visible windows, not the arrival rate. This is the **aggregation
|
|
117
|
+
* window**, distinct from `windowMode`'s RingBuffer eviction.
|
|
118
|
+
*/
|
|
119
|
+
aggregate?: AggregateConfig;
|
|
120
|
+
/**
|
|
121
|
+
* Opt-in event-time ingestion. Buffers pushed events for a bounded
|
|
122
|
+
* lateness/grace window and releases them to the chart in event-time
|
|
123
|
+
* order, so out-of-order or merged multi-source streams render
|
|
124
|
+
* monotonically instead of zigzagging. Late events (older than
|
|
125
|
+
* `watermark − lateness`) are dropped or kept per policy and surfaced
|
|
126
|
+
* via `onObservation` as `"late-data"`. Default-off; when unset the
|
|
127
|
+
* push path is byte-for-byte unchanged.
|
|
128
|
+
*/
|
|
129
|
+
eventTime?: EventTimeConfig;
|
|
109
130
|
}
|
|
110
131
|
/**
|
|
111
132
|
* RealtimeLineChart - Simplified wrapper for streaming line charts.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { WindowAccumulator, type WindowType, type AggregateStat, type AggregateBand } from "../../realtime/WindowAccumulator";
|
|
2
|
+
import type { Datum } from "../shared/datumTypes";
|
|
3
|
+
/**
|
|
4
|
+
* Opt-in windowed-aggregation transform for realtime XY charts. With it
|
|
5
|
+
* set, pushed events are reduced into event-time windows and the chart
|
|
6
|
+
* draws one mark per window (mean / sum / min / max / count) plus an
|
|
7
|
+
* optional ±σ or min–max envelope — bounded render cost regardless of
|
|
8
|
+
* arrival rate.
|
|
9
|
+
*/
|
|
10
|
+
export interface AggregateConfig {
|
|
11
|
+
/** Window kind. @default "tumbling" */
|
|
12
|
+
window?: WindowType;
|
|
13
|
+
/** Window width — ms or a duration string (`"1m"`, `"10s"`, `"500ms"`). */
|
|
14
|
+
size: number | string;
|
|
15
|
+
/** Hop between hopping windows — ms or duration string. @default = size */
|
|
16
|
+
hop?: number | string;
|
|
17
|
+
/** Session inactivity gap — ms or duration string (session windows only). */
|
|
18
|
+
gap?: number | string;
|
|
19
|
+
/** Statistic rendered as the primary series. @default "mean" */
|
|
20
|
+
stat?: AggregateStat;
|
|
21
|
+
/** Envelope drawn around the series. @default "none" */
|
|
22
|
+
band?: AggregateBand;
|
|
23
|
+
/** Multiplier for the `stddev` band (drawn as value ± sigma·σ). @default 1 */
|
|
24
|
+
sigma?: number;
|
|
25
|
+
/** Keep at most this many most-recent windows. @default unbounded */
|
|
26
|
+
retain?: number;
|
|
27
|
+
}
|
|
28
|
+
export declare const AGG_TIME = "time";
|
|
29
|
+
export declare const AGG_VALUE = "value";
|
|
30
|
+
export declare const AGG_LOWER = "__aggLower";
|
|
31
|
+
export declare const AGG_UPPER = "__aggUpper";
|
|
32
|
+
export declare const AGG_PARTIAL = "__aggPartial";
|
|
33
|
+
export declare const AGG_COUNT = "count";
|
|
34
|
+
export declare const AGG_START = "__aggStart";
|
|
35
|
+
export declare const AGG_END = "__aggEnd";
|
|
36
|
+
/**
|
|
37
|
+
* Build a `WindowAccumulator` from a config, parsing duration strings.
|
|
38
|
+
* Returns `null` when the window width is unparseable, so the caller can
|
|
39
|
+
* skip aggregation rather than bucket on a zero-width window.
|
|
40
|
+
*/
|
|
41
|
+
export declare function createAccumulator(config: AggregateConfig): WindowAccumulator | null;
|
|
42
|
+
/**
|
|
43
|
+
* Snapshot the accumulator into frame-ready rows. Each row carries the
|
|
44
|
+
* primary stat at `value`, the window midpoint at `time`, the band
|
|
45
|
+
* bounds (when a band is configured), and provenance fields (`count`,
|
|
46
|
+
* partial flag, raw start/end) for tooltips and partial-window styling.
|
|
47
|
+
*/
|
|
48
|
+
export declare function aggregatedRows(acc: WindowAccumulator, config: AggregateConfig): Datum[];
|
|
49
|
+
/** Whether a config requests a band envelope. */
|
|
50
|
+
export declare function hasBand(config: AggregateConfig): boolean;
|
|
51
|
+
export type { AggregateStat, AggregateBand, WindowType };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ReorderBuffer, type LatePolicy } from "../../realtime/ReorderBuffer";
|
|
2
|
+
import type { Datum } from "../shared/datumTypes";
|
|
3
|
+
/**
|
|
4
|
+
* Opt-in event-time ingestion for realtime XY charts. Reorders pushed
|
|
5
|
+
* events within a bounded grace window so out-of-order arrivals render
|
|
6
|
+
* in event-time order, at the cost of delaying display by `lateness`.
|
|
7
|
+
*/
|
|
8
|
+
export interface EventTimeConfig {
|
|
9
|
+
/**
|
|
10
|
+
* Grace window — ms or a duration string (`"2s"`, `"500ms"`). Events
|
|
11
|
+
* whose time is older than `watermark − lateness` are late.
|
|
12
|
+
*/
|
|
13
|
+
lateness: number | string;
|
|
14
|
+
/**
|
|
15
|
+
* What to do with a late event:
|
|
16
|
+
* - `"drop"` (default): discard it (still counted + surfaced).
|
|
17
|
+
* - `"keep"`: release it immediately, out of order (still counted).
|
|
18
|
+
*/
|
|
19
|
+
latePolicy?: LatePolicy;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Build a `ReorderBuffer` from a config and a time accessor, parsing the
|
|
23
|
+
* lateness duration. Returns `null` when the lateness is unparseable so
|
|
24
|
+
* the caller can fall back to plain (in-order) ingestion.
|
|
25
|
+
*/
|
|
26
|
+
export declare function createReorderBuffer(config: EventTimeConfig, getTime: (d: Datum) => number): ReorderBuffer<Datum> | null;
|
|
@@ -53,6 +53,8 @@ export declare const interpolateInferno: (t: number) => string;
|
|
|
53
53
|
export declare const interpolateMagma: (t: number) => string;
|
|
54
54
|
export declare const interpolateCividis: (t: number) => string;
|
|
55
55
|
export declare const interpolateTurbo: (t: number) => string;
|
|
56
|
+
export declare const SEQUENTIAL_INTERPOLATORS: Record<string, (t: number) => string>;
|
|
57
|
+
export declare function getSequentialInterpolator(scheme: string | undefined): (t: number) => string;
|
|
56
58
|
export declare const interpolateRdBu: (t: number) => string;
|
|
57
59
|
export declare const interpolatePiYG: (t: number) => string;
|
|
58
60
|
export declare const interpolatePRGn: (t: number) => string;
|
|
@@ -2,18 +2,7 @@ import type { Datum } from "./datumTypes";
|
|
|
2
2
|
/**
|
|
3
3
|
* Predefined color schemes
|
|
4
4
|
*/
|
|
5
|
-
export declare const COLOR_SCHEMES:
|
|
6
|
-
category10: readonly string[];
|
|
7
|
-
tableau10: readonly string[];
|
|
8
|
-
set3: readonly string[];
|
|
9
|
-
blues: (t: number) => string;
|
|
10
|
-
reds: (t: number) => string;
|
|
11
|
-
greens: (t: number) => string;
|
|
12
|
-
oranges: (t: number) => string;
|
|
13
|
-
purples: (t: number) => string;
|
|
14
|
-
viridis: (t: number) => string;
|
|
15
|
-
plasma: (t: number) => string;
|
|
16
|
-
};
|
|
5
|
+
export declare const COLOR_SCHEMES: Record<string, readonly string[] | ((t: number) => string)>;
|
|
17
6
|
/**
|
|
18
7
|
* Default colors for charts
|
|
19
8
|
*/
|
|
@@ -1,21 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* radialGeometry — pure math helpers for radial chart authoring.
|
|
3
|
-
*
|
|
4
|
-
* The original consumer is `GaugeChart`, which needs to:
|
|
5
|
-
* - Convert a sweep angle (degrees) into start-angle + radian
|
|
6
|
-
* forms that align with the convention pieScene.ts uses
|
|
7
|
-
* (0° = 12 o'clock, positive = clockwise, gap centered at the
|
|
8
|
-
* 6 o'clock position).
|
|
9
|
-
* - Map a value in `[min, max]` to its angle along the arc.
|
|
10
|
-
* - Compute the arc's visible bounding box in unit-circle coords
|
|
11
|
-
* so a container can fit the arc and pick a maximum radius.
|
|
12
|
-
*
|
|
13
|
-
* Custom radial chart authors using `XYCustomChart` or building a
|
|
14
|
-
* bespoke radial layout can reach for the same primitives without
|
|
15
|
-
* reimplementing the trigonometry. Surface intentionally tight —
|
|
16
|
-
* each function is a few lines of math with a documented input
|
|
17
|
-
* convention.
|
|
18
|
-
*/
|
|
19
1
|
/** Result of `sweepToAngles`. All angles are in the
|
|
20
2
|
* 12-o'clock-zero, clockwise-positive convention used by pieScene
|
|
21
3
|
* and the underlying gauge implementation. */
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Datum } from "./datumTypes";
|
|
2
|
+
export interface SmartTooltipEntry {
|
|
3
|
+
key: string;
|
|
4
|
+
value: unknown;
|
|
5
|
+
}
|
|
6
|
+
export interface SmartTooltipResult {
|
|
7
|
+
/** The key the title came from, if any. */
|
|
8
|
+
titleKey?: string;
|
|
9
|
+
/** The display title (a name/label/title/id). */
|
|
10
|
+
title?: unknown;
|
|
11
|
+
/** Ordered rows to show beneath the title (type → value → rest). */
|
|
12
|
+
entries: SmartTooltipEntry[];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Choose a title + ordered, de-noised rows from an arbitrary datum. Pure.
|
|
16
|
+
*
|
|
17
|
+
* - Skips `_`/`__`-prefixed keys, `data`, positional/topology keys, and
|
|
18
|
+
* non-primitive values (nested objects/arrays).
|
|
19
|
+
* - Title: the first `name`/`label`/`title` field, else `id`, else the first
|
|
20
|
+
* string field. When a real name is used, `id` is dropped as redundant.
|
|
21
|
+
* - Rows: one type-family field, then one value-family field, then the rest in
|
|
22
|
+
* insertion order (capped at `maxEntries`).
|
|
23
|
+
*/
|
|
24
|
+
export declare function smartTooltipEntries(raw: Datum | null | undefined, options?: {
|
|
25
|
+
maxEntries?: number;
|
|
26
|
+
skipPositional?: boolean;
|
|
27
|
+
}): SmartTooltipResult;
|
|
@@ -48,6 +48,27 @@ export interface ForecastConfig {
|
|
|
48
48
|
trainOpacity?: number;
|
|
49
49
|
/** Stroke opacity for the forecast line segment (0–1). Default: 1 */
|
|
50
50
|
forecastOpacity?: number;
|
|
51
|
+
/**
|
|
52
|
+
* Ramp each forecast point's opacity by its uncertainty — wider
|
|
53
|
+
* prediction interval (longer horizon) renders fainter, fusing
|
|
54
|
+
* confidence into the encoding instead of a single flat opacity.
|
|
55
|
+
* `true` ramps across `[0.15, 1]`; pass `{ min, max }` to bound the
|
|
56
|
+
* range. Honored by `createSegmentLineStyle`; overrides
|
|
57
|
+
* `forecastOpacity` per point. Mutually exclusive with
|
|
58
|
+
* `confidenceAccessor` (which wins if both are set).
|
|
59
|
+
*/
|
|
60
|
+
uncertaintyOpacity?: boolean | {
|
|
61
|
+
min?: number;
|
|
62
|
+
max?: number;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Externally-supplied per-point confidence in `[0, 1]` (field name or
|
|
66
|
+
* function). When set, each forecast point's opacity is interpolated
|
|
67
|
+
* across the `uncertaintyOpacity` range (or `[0.15, 1]`) by its
|
|
68
|
+
* confidence — higher confidence, more opaque. Use when the consumer's
|
|
69
|
+
* model emits a confidence rather than a prediction interval.
|
|
70
|
+
*/
|
|
71
|
+
confidenceAccessor?: string | ((d: Datum) => number);
|
|
51
72
|
/**
|
|
52
73
|
* Training line stroke color.
|
|
53
74
|
* - `"darken"`: auto-darken the line's own color by 50% (hex colors only —
|
|
@@ -97,6 +118,20 @@ export interface ForecastConfig {
|
|
|
97
118
|
/** Internal segment marker added to each datum */
|
|
98
119
|
export declare const SEGMENT_FIELD: "__forecastSegment";
|
|
99
120
|
export type SegmentType = "training" | "training-base" | "observed" | "forecast";
|
|
121
|
+
/** Internal per-point opacity stamped by the uncertainty ramp. */
|
|
122
|
+
export declare const FORECAST_OPACITY_FIELD: "__forecastOpacity";
|
|
123
|
+
/**
|
|
124
|
+
* Stamp `__forecastOpacity` on forecast points so `createSegmentLineStyle`
|
|
125
|
+
* can fade each by its uncertainty. Two sources, confidence wins:
|
|
126
|
+
*
|
|
127
|
+
* - `confidenceAccessor` — opacity = lerp(min, max, confidence∈[0,1]).
|
|
128
|
+
* - `uncertaintyOpacity` — opacity ramped by prediction-interval width
|
|
129
|
+
* (narrowest → max, widest → min), normalized across the given points.
|
|
130
|
+
*
|
|
131
|
+
* Mutates the supplied point objects in place; no-op when neither source
|
|
132
|
+
* is configured. Pure otherwise (only reads via the passed accessors).
|
|
133
|
+
*/
|
|
134
|
+
export declare function stampForecastOpacity(points: Datum[], config: ForecastConfig, getUpper: (d: Datum) => number | undefined, getLower: (d: Datum) => number | undefined): void;
|
|
100
135
|
export declare function buildAnomalyAnnotations(config: AnomalyConfig): Datum[];
|
|
101
136
|
export interface ForecastResult {
|
|
102
137
|
processedData: Datum[];
|
|
@@ -21,6 +21,8 @@ export interface TooltipFieldConfig {
|
|
|
21
21
|
export declare function accessorName(acc: string | ((...args: any[]) => any)): string;
|
|
22
22
|
export declare function formatVal(v: unknown): string;
|
|
23
23
|
export declare function resolveValue(d: Datum, acc: string | ((d: Datum) => any)): unknown;
|
|
24
|
+
export { smartTooltipEntries } from "./smartTooltip";
|
|
25
|
+
export type { SmartTooltipEntry, SmartTooltipResult } from "./smartTooltip";
|
|
24
26
|
/**
|
|
25
27
|
* Build TooltipFieldConfig rows for a `band` prop config so the default
|
|
26
28
|
* tooltip surfaces envelope values automatically. Reads from the
|