semiotic 3.5.4 → 3.7.0
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 +196 -175
- package/README.md +52 -15
- package/ai/cli.js +41 -0
- package/ai/componentMetadata.cjs +11 -2
- package/ai/dist/mcp-server.js +454 -4
- package/ai/examples.md +98 -0
- package/ai/schema.json +614 -9
- package/ai/system-prompt.md +5 -2
- package/dist/components/AccessibleNavTree.d.ts +25 -0
- package/dist/components/Annotation.d.ts +40 -14
- package/dist/components/ChartContainer.d.ts +32 -2
- package/dist/components/ai/annotationProvenance.d.ts +349 -0
- package/dist/components/ai/audienceProfile.d.ts +147 -0
- package/dist/components/ai/audiences.d.ts +31 -0
- package/dist/components/ai/chartCapabilities.d.ts +55 -0
- package/dist/components/ai/chartCapabilityTypes.d.ts +254 -0
- package/dist/components/ai/chartRoles.d.ts +27 -0
- package/dist/components/ai/conversationArc.d.ts +379 -0
- package/dist/components/ai/dataScaleProfile.d.ts +320 -0
- package/dist/components/ai/describeChart.d.ts +114 -0
- package/dist/components/ai/diffProfile.d.ts +51 -0
- package/dist/components/ai/inferIntent.d.ts +24 -0
- package/dist/components/ai/intents.d.ts +34 -0
- package/dist/components/ai/navigationTree.d.ts +45 -0
- package/dist/components/ai/profileData.d.ts +16 -0
- package/dist/components/ai/qualityFixtures.d.ts +2 -0
- package/dist/components/ai/qualityScorecard.d.ts +82 -0
- package/dist/components/ai/readerGrounding.d.ts +70 -0
- package/dist/components/ai/repairChartConfig.d.ts +73 -0
- package/dist/components/ai/streamingTypes.d.ts +64 -0
- package/dist/components/ai/suggestCharts.d.ts +109 -0
- package/dist/components/ai/suggestDashboard.d.ts +92 -0
- package/dist/components/ai/suggestStreamCharts.d.ts +34 -0
- package/dist/components/ai/suggestStretchCharts.d.ts +60 -0
- package/dist/components/ai/useChartSuggestions.d.ts +22 -0
- package/dist/components/ai/useConversationArc.d.ts +89 -0
- package/dist/components/ai/useNavigationSync.d.ts +61 -0
- package/dist/components/ai/variantDiscovery.d.ts +168 -0
- package/dist/components/charts/geo/ChoroplethMap.capability.d.ts +2 -0
- package/dist/components/charts/geo/DistanceCartogram.capability.d.ts +2 -0
- package/dist/components/charts/geo/FlowMap.capability.d.ts +2 -0
- package/dist/components/charts/geo/ProportionalSymbolMap.capability.d.ts +2 -0
- package/dist/components/charts/index.d.ts +1 -1
- package/dist/components/charts/network/ChordDiagram.capability.d.ts +2 -0
- package/dist/components/charts/network/CirclePack.capability.d.ts +2 -0
- package/dist/components/charts/network/ForceDirectedGraph.capability.d.ts +2 -0
- package/dist/components/charts/network/OrbitDiagram.capability.d.ts +2 -0
- package/dist/components/charts/network/ProcessSankey.capability.d.ts +2 -0
- package/dist/components/charts/network/SankeyDiagram.capability.d.ts +2 -0
- package/dist/components/charts/network/TreeDiagram.capability.d.ts +2 -0
- package/dist/components/charts/network/Treemap.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/BarChart.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/BoxPlot.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/DonutChart.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/DotPlot.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/FunnelChart.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/GaugeChart.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/GroupedBarChart.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/Histogram.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/Histogram.d.ts +4 -2
- package/dist/components/charts/ordinal/LikertChart.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/LikertChart.d.ts +1 -1
- package/dist/components/charts/ordinal/LikertChart.defaults.d.ts +1 -0
- package/dist/components/charts/ordinal/PieChart.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/RidgelinePlot.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/StackedBarChart.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/SwarmPlot.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/SwimlaneChart.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/ViolinPlot.capability.d.ts +2 -0
- package/dist/components/charts/realtime/RealtimeHeatmap.capability.d.ts +2 -0
- package/dist/components/charts/realtime/RealtimeHeatmap.d.ts +3 -0
- package/dist/components/charts/realtime/RealtimeHistogram.capability.d.ts +2 -0
- package/dist/components/charts/realtime/RealtimeHistogram.d.ts +3 -0
- package/dist/components/charts/realtime/RealtimeLineChart.capability.d.ts +2 -0
- package/dist/components/charts/realtime/RealtimeLineChart.d.ts +3 -0
- package/dist/components/charts/realtime/RealtimeSwarmChart.capability.d.ts +2 -0
- package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +3 -0
- package/dist/components/charts/realtime/RealtimeWaterfallChart.capability.d.ts +2 -0
- package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +3 -0
- package/dist/components/charts/realtime/TemporalHistogram.capability.d.ts +7 -0
- package/dist/components/charts/shared/annotationHierarchy.d.ts +42 -0
- package/dist/components/charts/shared/annotationResolvers.d.ts +3 -2
- package/dist/components/charts/shared/annotationRules.d.ts +16 -0
- package/dist/components/charts/shared/annotationTypes.d.ts +14 -0
- package/dist/components/charts/shared/auditAccessibility.d.ts +90 -0
- package/dist/components/charts/shared/chartSpecs.d.ts +2 -37
- package/dist/components/charts/shared/diagnoseConfig.d.ts +4 -6
- package/dist/components/charts/shared/selectionUtils.d.ts +5 -2
- package/dist/components/charts/shared/streamPropsHelpers.d.ts +2 -0
- package/dist/components/charts/shared/types.d.ts +5 -1
- package/dist/components/charts/value/BigNumber.capability.d.ts +13 -0
- package/dist/components/charts/value/BigNumber.d.ts +14 -0
- package/dist/components/charts/value/formatting.d.ts +40 -0
- package/dist/components/charts/value/thresholdSparkline.d.ts +40 -0
- package/dist/components/charts/value/types.d.ts +292 -0
- package/dist/components/charts/xy/AreaChart.capability.d.ts +10 -0
- package/dist/components/charts/xy/BubbleChart.capability.d.ts +2 -0
- package/dist/components/charts/xy/CandlestickChart.capability.d.ts +2 -0
- package/dist/components/charts/xy/ConnectedScatterplot.capability.d.ts +2 -0
- package/dist/components/charts/xy/DifferenceChart.capability.d.ts +8 -0
- package/dist/components/charts/xy/Heatmap.capability.d.ts +9 -0
- package/dist/components/charts/xy/LineChart.capability.d.ts +9 -0
- package/dist/components/charts/xy/MinimapChart.capability.d.ts +2 -0
- package/dist/components/charts/xy/MultiAxisLineChart.capability.d.ts +2 -0
- package/dist/components/charts/xy/QuadrantChart.capability.d.ts +2 -0
- package/dist/components/charts/xy/QuadrantChart.d.ts +5 -2
- package/dist/components/charts/xy/QuadrantChart.defaults.d.ts +2 -0
- package/dist/components/charts/xy/Scatterplot.capability.d.ts +2 -0
- package/dist/components/charts/xy/StackedAreaChart.capability.d.ts +2 -0
- package/dist/components/data/DataSummarizer.d.ts +45 -0
- package/dist/components/realtime/lifecycleBands.d.ts +44 -0
- package/dist/components/realtime/types.d.ts +23 -8
- package/dist/components/recipes/annotationDensity.d.ts +69 -0
- package/dist/components/recipes/annotationLayout.d.ts +93 -0
- package/dist/components/semiotic-ai.d.ts +58 -0
- package/dist/components/semiotic-realtime.d.ts +2 -0
- package/dist/components/semiotic-recipes.d.ts +4 -0
- package/dist/components/semiotic-utils.d.ts +8 -0
- package/dist/components/semiotic-value.d.ts +55 -0
- package/dist/components/semiotic-xy.d.ts +1 -1
- package/dist/components/semiotic.d.ts +8 -1
- package/dist/components/server/staticAnnotations.d.ts +2 -0
- package/dist/components/store/useChartFocus.d.ts +43 -0
- package/dist/components/store/useChartInterrogation.d.ts +141 -0
- package/dist/components/stream/AccessibleDataTable.d.ts +10 -1
- package/dist/components/stream/NetworkSVGOverlay.d.ts +11 -5
- package/dist/components/stream/OrdinalSVGOverlay.d.ts +2 -0
- package/dist/components/stream/SVGOverlay.d.ts +2 -0
- package/dist/components/stream/geoTypes.d.ts +3 -0
- package/dist/components/stream/networkTypes.d.ts +2 -0
- package/dist/components/stream/ordinalTypes.d.ts +2 -0
- package/dist/components/stream/types.d.ts +2 -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.d.ts +58 -0
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-realtime.d.ts +2 -0
- package/dist/semiotic-recipes.d.ts +4 -0
- package/dist/semiotic-recipes.min.js +1 -1
- package/dist/semiotic-recipes.module.min.js +1 -1
- package/dist/semiotic-themes.min.js +1 -1
- package/dist/semiotic-themes.module.min.js +1 -1
- package/dist/semiotic-utils.d.ts +8 -0
- package/dist/semiotic-utils.min.js +1 -1
- package/dist/semiotic-utils.module.min.js +1 -1
- package/dist/semiotic-value.d.ts +55 -0
- package/dist/semiotic-value.min.js +2 -0
- package/dist/semiotic-value.module.min.js +2 -0
- package/dist/semiotic-xy.d.ts +1 -1
- package/dist/semiotic.d.ts +8 -1
- 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.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +28 -5
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { AudienceProfile } from "./audienceProfile";
|
|
2
|
+
/**
|
|
3
|
+
* Three example AudienceProfile shapes. Not authoritative — these are
|
|
4
|
+
* sketches based on rough industry stereotypes, useful for documentation,
|
|
5
|
+
* demos, and as starting points consumers can fork.
|
|
6
|
+
*
|
|
7
|
+
* To use one in production, copy it and tune to your audience's actual
|
|
8
|
+
* survey/telemetry data. Do not assume these defaults represent your team.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Executive audience — high familiarity with bar/line/pie/gauge,
|
|
12
|
+
* limited tolerance for unfamiliar chart shapes. Most likely to encounter
|
|
13
|
+
* dashboards built by analysts; not building their own.
|
|
14
|
+
*/
|
|
15
|
+
export declare const executivePersona: AudienceProfile;
|
|
16
|
+
/**
|
|
17
|
+
* Analyst audience — broader chart vocabulary, comfortable with
|
|
18
|
+
* distribution-shape and matrix-shape charts. Building dashboards for
|
|
19
|
+
* others; can read most things on first encounter.
|
|
20
|
+
*/
|
|
21
|
+
export declare const analystPersona: AudienceProfile;
|
|
22
|
+
/**
|
|
23
|
+
* Data scientist audience — comfortable with the full distribution-chart
|
|
24
|
+
* family, regression overlays, and density encodings. Will accept most
|
|
25
|
+
* exotic shapes if they're more honest about the data.
|
|
26
|
+
*/
|
|
27
|
+
export declare const dataScientistPersona: AudienceProfile;
|
|
28
|
+
/**
|
|
29
|
+
* Convenience map for consumers loading audience by name (e.g. from a config string).
|
|
30
|
+
*/
|
|
31
|
+
export declare const BUILT_IN_AUDIENCES: Record<string, AudienceProfile>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { ChartCapability } from "./chartCapabilityTypes";
|
|
2
|
+
import { LineChartCapability } from "../charts/xy/LineChart.capability";
|
|
3
|
+
import { AreaChartCapability } from "../charts/xy/AreaChart.capability";
|
|
4
|
+
import { StackedAreaChartCapability } from "../charts/xy/StackedAreaChart.capability";
|
|
5
|
+
import { ScatterplotCapability } from "../charts/xy/Scatterplot.capability";
|
|
6
|
+
import { ConnectedScatterplotCapability } from "../charts/xy/ConnectedScatterplot.capability";
|
|
7
|
+
import { BubbleChartCapability } from "../charts/xy/BubbleChart.capability";
|
|
8
|
+
import { QuadrantChartCapability } from "../charts/xy/QuadrantChart.capability";
|
|
9
|
+
import { MultiAxisLineChartCapability } from "../charts/xy/MultiAxisLineChart.capability";
|
|
10
|
+
import { MinimapChartCapability } from "../charts/xy/MinimapChart.capability";
|
|
11
|
+
import { DifferenceChartCapability } from "../charts/xy/DifferenceChart.capability";
|
|
12
|
+
import { CandlestickChartCapability } from "../charts/xy/CandlestickChart.capability";
|
|
13
|
+
import { HeatmapCapability } from "../charts/xy/Heatmap.capability";
|
|
14
|
+
import { BarChartCapability } from "../charts/ordinal/BarChart.capability";
|
|
15
|
+
import { GroupedBarChartCapability } from "../charts/ordinal/GroupedBarChart.capability";
|
|
16
|
+
import { StackedBarChartCapability } from "../charts/ordinal/StackedBarChart.capability";
|
|
17
|
+
import { DotPlotCapability } from "../charts/ordinal/DotPlot.capability";
|
|
18
|
+
import { PieChartCapability } from "../charts/ordinal/PieChart.capability";
|
|
19
|
+
import { DonutChartCapability } from "../charts/ordinal/DonutChart.capability";
|
|
20
|
+
import { FunnelChartCapability } from "../charts/ordinal/FunnelChart.capability";
|
|
21
|
+
import { GaugeChartCapability } from "../charts/ordinal/GaugeChart.capability";
|
|
22
|
+
import { LikertChartCapability } from "../charts/ordinal/LikertChart.capability";
|
|
23
|
+
import { SwimlaneChartCapability } from "../charts/ordinal/SwimlaneChart.capability";
|
|
24
|
+
import { HistogramCapability } from "../charts/ordinal/Histogram.capability";
|
|
25
|
+
import { BoxPlotCapability } from "../charts/ordinal/BoxPlot.capability";
|
|
26
|
+
import { SwarmPlotCapability } from "../charts/ordinal/SwarmPlot.capability";
|
|
27
|
+
import { ViolinPlotCapability } from "../charts/ordinal/ViolinPlot.capability";
|
|
28
|
+
import { RidgelinePlotCapability } from "../charts/ordinal/RidgelinePlot.capability";
|
|
29
|
+
import { ForceDirectedGraphCapability } from "../charts/network/ForceDirectedGraph.capability";
|
|
30
|
+
import { SankeyDiagramCapability } from "../charts/network/SankeyDiagram.capability";
|
|
31
|
+
import { ChordDiagramCapability } from "../charts/network/ChordDiagram.capability";
|
|
32
|
+
import { ProcessSankeyCapability } from "../charts/network/ProcessSankey.capability";
|
|
33
|
+
import { TreeDiagramCapability } from "../charts/network/TreeDiagram.capability";
|
|
34
|
+
import { TreemapCapability } from "../charts/network/Treemap.capability";
|
|
35
|
+
import { CirclePackCapability } from "../charts/network/CirclePack.capability";
|
|
36
|
+
import { OrbitDiagramCapability } from "../charts/network/OrbitDiagram.capability";
|
|
37
|
+
import { ChoroplethMapCapability } from "../charts/geo/ChoroplethMap.capability";
|
|
38
|
+
import { ProportionalSymbolMapCapability } from "../charts/geo/ProportionalSymbolMap.capability";
|
|
39
|
+
import { FlowMapCapability } from "../charts/geo/FlowMap.capability";
|
|
40
|
+
import { DistanceCartogramCapability } from "../charts/geo/DistanceCartogram.capability";
|
|
41
|
+
/**
|
|
42
|
+
* Register a capability for a chart (built-in or third-party). Re-registering by
|
|
43
|
+
* component name replaces the previous descriptor — useful for overriding defaults.
|
|
44
|
+
*/
|
|
45
|
+
export declare function registerChartCapability(capability: ChartCapability): void;
|
|
46
|
+
/** Remove a previously-registered capability. Does not affect built-ins. */
|
|
47
|
+
export declare function unregisterChartCapability(component: string): void;
|
|
48
|
+
/**
|
|
49
|
+
* Current capability list — built-ins, then user-registered, with user-registered
|
|
50
|
+
* overriding built-ins by component name.
|
|
51
|
+
*/
|
|
52
|
+
export declare function getCapabilities(): ReadonlyArray<ChartCapability>;
|
|
53
|
+
/** Look up a capability by component name. */
|
|
54
|
+
export declare function getCapability(component: string): ChartCapability | undefined;
|
|
55
|
+
export { LineChartCapability, AreaChartCapability, StackedAreaChartCapability, ScatterplotCapability, ConnectedScatterplotCapability, BubbleChartCapability, QuadrantChartCapability, MultiAxisLineChartCapability, MinimapChartCapability, DifferenceChartCapability, CandlestickChartCapability, HeatmapCapability, BarChartCapability, GroupedBarChartCapability, StackedBarChartCapability, DotPlotCapability, PieChartCapability, DonutChartCapability, FunnelChartCapability, GaugeChartCapability, LikertChartCapability, SwimlaneChartCapability, HistogramCapability, BoxPlotCapability, SwarmPlotCapability, ViolinPlotCapability, RidgelinePlotCapability, ForceDirectedGraphCapability, SankeyDiagramCapability, ChordDiagramCapability, ProcessSankeyCapability, TreeDiagramCapability, TreemapCapability, CirclePackCapability, OrbitDiagramCapability, ChoroplethMapCapability, ProportionalSymbolMapCapability, FlowMapCapability, DistanceCartogramCapability, };
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import type { Datum } from "../charts/shared/datumTypes";
|
|
2
|
+
import type { DataSummary } from "../data/DataSummarizer";
|
|
3
|
+
import type { IntentId } from "./intents";
|
|
4
|
+
import type { ScaleFitFn, QualityFitFn, ScaleBand, CardinalityBand, EffectiveScale } from "./dataScaleProfile";
|
|
5
|
+
/**
|
|
6
|
+
* Chart family — high-level taxonomy used for filtering and intent matching.
|
|
7
|
+
*/
|
|
8
|
+
export type ChartFamily = "time-series" | "categorical" | "distribution" | "relationship" | "flow" | "network" | "hierarchy" | "geo" | "realtime" | "value" | "custom";
|
|
9
|
+
/**
|
|
10
|
+
* Where a chart is imported from. Used by generators to emit correct import paths.
|
|
11
|
+
*/
|
|
12
|
+
export type ChartImportPath = "semiotic/xy" | "semiotic/ordinal" | "semiotic/network" | "semiotic/geo" | "semiotic/realtime" | "semiotic/value" | "semiotic/ai" | "semiotic";
|
|
13
|
+
/**
|
|
14
|
+
* Familiarity/accuracy/precision rubric (1-5 each).
|
|
15
|
+
* Familiarity = how well-known the chart is to a general audience.
|
|
16
|
+
* Accuracy = how faithfully it represents the underlying data.
|
|
17
|
+
* Precision = how readable individual values are.
|
|
18
|
+
*/
|
|
19
|
+
export interface ChartRubric {
|
|
20
|
+
familiarity: number;
|
|
21
|
+
accuracy: number;
|
|
22
|
+
precision: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The kind of value a field holds, used for axis fitness.
|
|
26
|
+
*/
|
|
27
|
+
export type FieldKind = "numeric" | "categorical" | "date" | "boolean" | "unknown";
|
|
28
|
+
/**
|
|
29
|
+
* A candidate field for a given role (x, y, series, etc.), with a quality score.
|
|
30
|
+
*/
|
|
31
|
+
export interface FieldCandidate {
|
|
32
|
+
field: string;
|
|
33
|
+
kind: FieldKind;
|
|
34
|
+
/** 0..1 — how good this field is for the role being considered. */
|
|
35
|
+
quality: number;
|
|
36
|
+
/** Field-level stats for downstream scorers. */
|
|
37
|
+
distinctCount?: number;
|
|
38
|
+
/** True if the field's values are strictly increasing in row order. */
|
|
39
|
+
monotonic?: boolean;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Profile of a dataset for chart-fitness scoring. Extends DataSummary with
|
|
43
|
+
* shape inference (axis candidates, structure detection, primary roles).
|
|
44
|
+
*/
|
|
45
|
+
export interface ChartDataProfile extends DataSummary {
|
|
46
|
+
/** Original rows (read-only); used by capabilities to compute their own stats. */
|
|
47
|
+
data: ReadonlyArray<Datum>;
|
|
48
|
+
/** Candidate fields per role, sorted best-first. */
|
|
49
|
+
candidates: {
|
|
50
|
+
x: FieldCandidate[];
|
|
51
|
+
y: FieldCandidate[];
|
|
52
|
+
size: FieldCandidate[];
|
|
53
|
+
category: FieldCandidate[];
|
|
54
|
+
series: FieldCandidate[];
|
|
55
|
+
time: FieldCandidate[];
|
|
56
|
+
};
|
|
57
|
+
/** Best-guess primary assignment per role (the top candidate, if any). */
|
|
58
|
+
primary: {
|
|
59
|
+
x?: string;
|
|
60
|
+
y?: string;
|
|
61
|
+
size?: string;
|
|
62
|
+
category?: string;
|
|
63
|
+
series?: string;
|
|
64
|
+
time?: string;
|
|
65
|
+
};
|
|
66
|
+
/** Distinct count of the primary category field, if any. */
|
|
67
|
+
categoryCount?: number;
|
|
68
|
+
/** Distinct count of the primary series field, if any. */
|
|
69
|
+
seriesCount?: number;
|
|
70
|
+
/** Distinct count of the primary x field, if any. */
|
|
71
|
+
uniqueXCount?: number;
|
|
72
|
+
/** True when some x value appears in more than one row (suggests aggregation). */
|
|
73
|
+
hasRepeatedX: boolean;
|
|
74
|
+
/** True when the primary x candidate is monotonic. */
|
|
75
|
+
monotonicX: boolean;
|
|
76
|
+
/** True when there is at least one date-typed candidate. */
|
|
77
|
+
hasTimeAxis: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* How the primary x role was inferred. Capabilities can use this to detect
|
|
80
|
+
* the "scatter fallback" case (x picked only because there were 2+ numerics,
|
|
81
|
+
* not because the field is genuinely an x-axis) and decline to recommend
|
|
82
|
+
* themselves for trend-shaped intents.
|
|
83
|
+
*
|
|
84
|
+
* • "time" — explicit date/time field
|
|
85
|
+
* • "named" — numeric whose name matches an x-pattern (month, year, index, …)
|
|
86
|
+
* • "scatter"— filled in via the two-numeric scatter fallback; weak signal
|
|
87
|
+
* • "none" — no x role inferred
|
|
88
|
+
*/
|
|
89
|
+
xProvenance: "time" | "named" | "scatter" | "none";
|
|
90
|
+
/** Source dataset looks like a hierarchy (had a `children` array at root). */
|
|
91
|
+
hasHierarchy: boolean;
|
|
92
|
+
/** Source dataset looks like a node/edge graph. */
|
|
93
|
+
hasNetwork: boolean;
|
|
94
|
+
/** Source dataset looks like GeoJSON (FeatureCollection). */
|
|
95
|
+
hasGeo: boolean;
|
|
96
|
+
/** Extracted network payload when hasNetwork is true. */
|
|
97
|
+
network?: {
|
|
98
|
+
nodes: ReadonlyArray<Datum>;
|
|
99
|
+
edges: ReadonlyArray<Datum>;
|
|
100
|
+
};
|
|
101
|
+
/** Extracted hierarchy root when hasHierarchy is true. */
|
|
102
|
+
hierarchy?: Datum;
|
|
103
|
+
/** Extracted GeoJSON FeatureCollection when hasGeo is true. */
|
|
104
|
+
geo?: {
|
|
105
|
+
features: ReadonlyArray<Datum>;
|
|
106
|
+
points?: ReadonlyArray<Datum>;
|
|
107
|
+
flows?: ReadonlyArray<Datum>;
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* An intent scorer is either a static 0..5 score or a function evaluated against the profile.
|
|
112
|
+
*/
|
|
113
|
+
export type IntentScorer = number | ((profile: ChartDataProfile) => number);
|
|
114
|
+
/**
|
|
115
|
+
* Variant — a configuration of the chart that meaningfully changes what it's good for.
|
|
116
|
+
*
|
|
117
|
+
* Variants compose into suggestions. The `intentDeltas` are additive against the
|
|
118
|
+
* base capability's intent scores (clamped to 0..5 by the engine).
|
|
119
|
+
*/
|
|
120
|
+
export interface ChartVariant {
|
|
121
|
+
key: string;
|
|
122
|
+
label: string;
|
|
123
|
+
description?: string;
|
|
124
|
+
/** Props to merge into the base chart props. */
|
|
125
|
+
props: Record<string, unknown>;
|
|
126
|
+
/** Style/role tags (used by consumers like vizmart for filtering). */
|
|
127
|
+
tags?: ReadonlyArray<string>;
|
|
128
|
+
/** Per-intent additive score deltas (e.g. {"trend": +1, "outlier-detection": -2}). */
|
|
129
|
+
intentDeltas?: Partial<Record<IntentId, number>>;
|
|
130
|
+
/** Rubric deltas — usually small, e.g. smoothing trades precision for familiarity. */
|
|
131
|
+
rubricDeltas?: Partial<ChartRubric>;
|
|
132
|
+
/** Caveats specific to this variant — surfaced in suggestion.caveats. */
|
|
133
|
+
caveats?: ReadonlyArray<string>;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Result of a capability's `fits()` gate. `null` means the chart fits. A string
|
|
137
|
+
* is the human-readable reason it doesn't, used for diagnostics and reasoning.
|
|
138
|
+
*/
|
|
139
|
+
export type FitResult = null | string;
|
|
140
|
+
/**
|
|
141
|
+
* The capability descriptor each chart ships alongside itself.
|
|
142
|
+
*
|
|
143
|
+
* Charts that declare a capability participate in `suggestCharts`, `useChartSuggestions`,
|
|
144
|
+
* and the `interrogateChart` MCP tool's recommendation surface.
|
|
145
|
+
*/
|
|
146
|
+
export interface ChartCapability {
|
|
147
|
+
component: string;
|
|
148
|
+
family: ChartFamily;
|
|
149
|
+
importPath: ChartImportPath;
|
|
150
|
+
/** Base rubric, before variant/profile adjustments. */
|
|
151
|
+
rubric: ChartRubric;
|
|
152
|
+
/**
|
|
153
|
+
* Hard requirements gate. Return null if the chart can render this profile,
|
|
154
|
+
* or a human-readable string explaining why not (e.g. "no numeric y candidate").
|
|
155
|
+
*/
|
|
156
|
+
fits: (profile: ChartDataProfile) => FitResult;
|
|
157
|
+
/**
|
|
158
|
+
* Per-intent suitability score (0..5). Missing intents default to 0.
|
|
159
|
+
* Values may be functions for profile-aware scoring.
|
|
160
|
+
*/
|
|
161
|
+
intentScores: Partial<Record<IntentId, IntentScorer>>;
|
|
162
|
+
/**
|
|
163
|
+
* Variants — different settings that change what the chart is useful for.
|
|
164
|
+
* Suggestion engine emits one suggestion per (capability × variant) pair.
|
|
165
|
+
* If empty, the engine still emits a base suggestion.
|
|
166
|
+
*/
|
|
167
|
+
variants?: ReadonlyArray<ChartVariant>;
|
|
168
|
+
/** Caveats independent of variants (e.g. "log scale skipped for negative values"). */
|
|
169
|
+
caveats?: (profile: ChartDataProfile) => ReadonlyArray<string>;
|
|
170
|
+
/**
|
|
171
|
+
* Build the props you'd pass to this chart for this dataset. Should produce
|
|
172
|
+
* a runnable config (accessor names, etc.) so consumers can `<Component {...props}>`.
|
|
173
|
+
*/
|
|
174
|
+
buildProps: (profile: ChartDataProfile, variant?: ChartVariant) => Record<string, unknown>;
|
|
175
|
+
/**
|
|
176
|
+
* Optional declaration of this chart's sweet spot under scale. Receives the
|
|
177
|
+
* effective scale (declared `DataScaleProfile` merged with measured profile)
|
|
178
|
+
* and returns a score delta plus optional caveats. Use `scaleHints(...)` from
|
|
179
|
+
* `dataScaleProfile.ts` for the common declarative shape.
|
|
180
|
+
*
|
|
181
|
+
* When omitted, the engine assumes the chart is scale-agnostic and applies
|
|
182
|
+
* no scale bias beyond what `intentScores` already encodes in `profile`.
|
|
183
|
+
*/
|
|
184
|
+
scaleFit?: ScaleFitFn;
|
|
185
|
+
/**
|
|
186
|
+
* Optional declaration of this chart's response to data quality (missingness,
|
|
187
|
+
* outliers, type heterogeneity). Returns a score delta plus caveats. When
|
|
188
|
+
* omitted, the engine applies a default heuristic that adds caveats for
|
|
189
|
+
* low completeness on the primary y field.
|
|
190
|
+
*/
|
|
191
|
+
qualityFit?: QualityFitFn;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Effective scale range tag on a suggestion. Lets callers group suggestions
|
|
195
|
+
* by their scale sweet spot, detect threshold crossings as data grows, and
|
|
196
|
+
* narrate why a recommendation changed.
|
|
197
|
+
*/
|
|
198
|
+
export interface SuggestionScaleRange {
|
|
199
|
+
/** Band classification of the row count this suggestion was evaluated against. */
|
|
200
|
+
band: ScaleBand;
|
|
201
|
+
/** Cardinality band, if known. */
|
|
202
|
+
cardinalityBand?: CardinalityBand;
|
|
203
|
+
/** Effective row count the engine reasoned over (declared or measured). */
|
|
204
|
+
rows: number;
|
|
205
|
+
/** Whether the row count came from a user-declared profile or the measured data. */
|
|
206
|
+
rowsSource: "declared" | "measured";
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* One suggestion produced by `suggestCharts`. Consumers render this as a card,
|
|
210
|
+
* pass it to an LLM for re-ranking, or hand the props straight to the chart.
|
|
211
|
+
*/
|
|
212
|
+
export interface Suggestion {
|
|
213
|
+
component: string;
|
|
214
|
+
family: ChartFamily;
|
|
215
|
+
importPath: ChartImportPath;
|
|
216
|
+
variant?: ChartVariant;
|
|
217
|
+
/** Composite score for the ranking intent(s), 0..5. */
|
|
218
|
+
score: number;
|
|
219
|
+
/** Per-intent scores after variant deltas. */
|
|
220
|
+
intentScores: Partial<Record<IntentId, number>>;
|
|
221
|
+
/** Rubric after variant/profile adjustments. */
|
|
222
|
+
rubric: ChartRubric;
|
|
223
|
+
/** Narrative reasons this chart fits — suitable for tooltips or LLM context. */
|
|
224
|
+
reasons: ReadonlyArray<string>;
|
|
225
|
+
/** Gotchas / things to be careful about. */
|
|
226
|
+
caveats: ReadonlyArray<string>;
|
|
227
|
+
/** Ready-to-spread props. */
|
|
228
|
+
props: Record<string, unknown>;
|
|
229
|
+
/**
|
|
230
|
+
* Scale tag — present when scale/quality information is available, either
|
|
231
|
+
* through declared `DataScaleProfile` or through the measured profile.
|
|
232
|
+
* Surfaces what band this chart was scored at so consumers can group by
|
|
233
|
+
* scale, detect threshold crossings, or narrate "the chart for now → at 10×."
|
|
234
|
+
*/
|
|
235
|
+
scaleRange?: SuggestionScaleRange;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Multi-tier grouping of suggestions by scale band. Returned by
|
|
239
|
+
* `suggestChartsGrouped()`.
|
|
240
|
+
*
|
|
241
|
+
* Each tier is a ranked list of suggestions whose `scaleRange.band` falls in
|
|
242
|
+
* that tier. A single chart can appear in multiple tiers when its sweet-spot
|
|
243
|
+
* range spans them — that's the "graduation of views" surface: the same data
|
|
244
|
+
* gets a different chart depending on which scale you're optimizing for.
|
|
245
|
+
*/
|
|
246
|
+
export interface ScaledSuggestionGroups {
|
|
247
|
+
tiny: Suggestion[];
|
|
248
|
+
small: Suggestion[];
|
|
249
|
+
medium: Suggestion[];
|
|
250
|
+
large: Suggestion[];
|
|
251
|
+
huge: Suggestion[];
|
|
252
|
+
/** The effective scale view the engine reasoned over. */
|
|
253
|
+
effective: EffectiveScale;
|
|
254
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Datum } from "../charts/shared/datumTypes";
|
|
2
|
+
/**
|
|
3
|
+
* Shared chart-family classification + measure/dimension role resolution.
|
|
4
|
+
*
|
|
5
|
+
* `describeChart` (prose) and `buildNavigationTree` (structure) both need to
|
|
6
|
+
* know which family a component belongs to and which props carry its measure
|
|
7
|
+
* (quantitative) and dimension (categorical/ordered) accessors. This is the
|
|
8
|
+
* single source of truth so the two surfaces can't drift apart.
|
|
9
|
+
*
|
|
10
|
+
* Pure, dependency-light (types only).
|
|
11
|
+
*/
|
|
12
|
+
export declare const XY_FAMILY: Set<string>;
|
|
13
|
+
export declare const BAR_FAMILY: Set<string>;
|
|
14
|
+
export declare const PART_TO_WHOLE: Set<string>;
|
|
15
|
+
export declare const DISTRIBUTION: Set<string>;
|
|
16
|
+
export interface ChartRoles {
|
|
17
|
+
measure?: string;
|
|
18
|
+
measureFallback: string;
|
|
19
|
+
dimension?: string;
|
|
20
|
+
dimensionFallback: string;
|
|
21
|
+
}
|
|
22
|
+
/** The measure (quantitative) and dimension (categorical/ordered) accessors, by family. */
|
|
23
|
+
export declare function roles(component: string, props: Datum): ChartRoles;
|
|
24
|
+
/** First string-valued series-splitting accessor among the known channels, if any. */
|
|
25
|
+
export declare function seriesField(props: Datum): string | undefined;
|
|
26
|
+
/** Format a dimension value (the label at an extremum) — dates as ISO day, numbers compactly. */
|
|
27
|
+
export declare function fmtDim(v: unknown, fmtNum: (n: number) => string): string;
|