semiotic 3.5.3 → 3.6.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 +62 -4
- package/README.md +19 -12
- package/ai/componentMetadata.cjs +9 -2
- package/ai/dist/mcp-server.js +253 -3
- package/ai/examples.md +27 -0
- package/ai/schema.json +319 -49
- package/ai/system-prompt.md +1 -1
- package/dist/components/ai/audienceProfile.d.ts +90 -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 +196 -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/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/repairChartConfig.d.ts +73 -0
- package/dist/components/ai/streamingTypes.d.ts +64 -0
- package/dist/components/ai/suggestCharts.d.ts +76 -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/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 +4 -4
- 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/network/Treemap.d.ts +8 -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/GaugeChart.d.ts +10 -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/RealtimeHistogram.capability.d.ts +2 -0
- package/dist/components/charts/realtime/RealtimeHistogram.d.ts +22 -0
- package/dist/components/charts/realtime/RealtimeLineChart.capability.d.ts +2 -0
- package/dist/components/charts/realtime/RealtimeSwarmChart.capability.d.ts +2 -0
- package/dist/components/charts/realtime/RealtimeWaterfallChart.capability.d.ts +2 -0
- package/dist/components/charts/realtime/TemporalHistogram.capability.d.ts +7 -0
- package/dist/components/charts/shared/chartSpecs.d.ts +0 -34
- package/dist/components/charts/shared/gaugeGradient.d.ts +62 -0
- package/dist/components/charts/shared/hooks.d.ts +2 -2
- package/dist/components/charts/shared/streamPropsHelpers.d.ts +2 -2
- package/dist/components/charts/shared/types.d.ts +11 -2
- package/dist/components/charts/shared/useChartSetup.d.ts +2 -2
- package/dist/components/charts/shared/useCustomChartSetup.d.ts +1 -1
- package/dist/components/charts/xy/AreaChart.capability.d.ts +10 -0
- package/dist/components/charts/xy/AreaChart.d.ts +15 -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/semiotic-ai.d.ts +36 -1
- package/dist/components/semiotic-realtime.d.ts +3 -3
- package/dist/components/semiotic-server.d.ts +1 -0
- package/dist/components/semiotic-xy.d.ts +2 -2
- package/dist/components/semiotic.d.ts +5 -4
- package/dist/components/server/renderToStaticSVG.d.ts +2 -0
- package/dist/components/server/staticLegend.d.ts +35 -0
- package/dist/components/store/ThemeStore.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/NetworkSVGOverlay.d.ts +2 -1
- package/dist/components/stream/OrdinalSVGOverlay.d.ts +2 -1
- package/dist/components/stream/SVGOverlay.d.ts +2 -1
- package/dist/components/stream/SceneToSVG.d.ts +1 -1
- package/dist/components/stream/geoTypes.d.ts +2 -1
- package/dist/components/stream/hoverUtils.d.ts +1 -0
- package/dist/components/stream/legendRenderer.d.ts +2 -1
- package/dist/components/stream/networkTypes.d.ts +2 -1
- package/dist/components/stream/ordinalTypes.d.ts +16 -2
- package/dist/components/stream/renderers/wedgePathBuilder.d.ts +31 -0
- package/dist/components/stream/types.d.ts +2 -1
- package/dist/components/types/legendTypes.d.ts +15 -0
- package/dist/components/types/marginType.d.ts +17 -3
- 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 +36 -1
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-realtime.d.ts +3 -3
- package/dist/semiotic-server.d.ts +1 -0
- package/dist/semiotic-utils.min.js +1 -1
- package/dist/semiotic-utils.module.min.js +1 -1
- package/dist/semiotic-xy.d.ts +2 -2
- package/dist/semiotic.d.ts +5 -4
- 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 +25 -24
|
@@ -7,6 +7,21 @@
|
|
|
7
7
|
import * as React from "react";
|
|
8
8
|
import type { SemioticTheme } from "../store/ThemeStore";
|
|
9
9
|
import type { Datum } from "../charts/shared/datumTypes";
|
|
10
|
+
import type { GradientLegendConfig, LegendGroup, LegendLayout } from "../types/legendTypes";
|
|
11
|
+
interface LegendItemLayout {
|
|
12
|
+
category: string;
|
|
13
|
+
width: number;
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
}
|
|
17
|
+
interface StaticLegendMetrics {
|
|
18
|
+
items: LegendItemLayout[];
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
swatchSize: number;
|
|
22
|
+
labelOffset: number;
|
|
23
|
+
swatchRadius: number;
|
|
24
|
+
}
|
|
10
25
|
export interface StaticLegendConfig {
|
|
11
26
|
/** Category labels to show in legend */
|
|
12
27
|
categories: string[];
|
|
@@ -28,13 +43,33 @@ export interface StaticLegendConfig {
|
|
|
28
43
|
};
|
|
29
44
|
/** Title presence (affects top-position offset) */
|
|
30
45
|
hasTitle?: boolean;
|
|
46
|
+
/** SSR legend layout controls */
|
|
47
|
+
legendLayout?: LegendLayout;
|
|
48
|
+
/** Optional id namespace used for generated SVG ids */
|
|
49
|
+
idPrefix?: string;
|
|
50
|
+
}
|
|
51
|
+
export interface StaticLegendGroupsConfig extends Omit<StaticLegendConfig, "categories" | "colorScheme"> {
|
|
52
|
+
legendGroups: LegendGroup[];
|
|
53
|
+
}
|
|
54
|
+
export interface StaticGradientLegendConfig extends Omit<StaticLegendConfig, "categories" | "colorScheme"> {
|
|
55
|
+
gradient: GradientLegendConfig;
|
|
31
56
|
}
|
|
57
|
+
export declare function measureStaticLegend(config: StaticLegendConfig): Omit<StaticLegendMetrics, "items" | "labelOffset" | "swatchRadius">;
|
|
58
|
+
export declare function measureStaticLegendGroups(config: StaticLegendGroupsConfig): Omit<StaticLegendMetrics, "items" | "labelOffset" | "swatchRadius">;
|
|
59
|
+
export declare function measureStaticGradientLegend(config: StaticGradientLegendConfig): {
|
|
60
|
+
width: number;
|
|
61
|
+
height: number;
|
|
62
|
+
swatchSize: number;
|
|
63
|
+
};
|
|
32
64
|
/**
|
|
33
65
|
* Render a static legend as SVG elements.
|
|
34
66
|
* Returns null if no categories to show.
|
|
35
67
|
*/
|
|
36
68
|
export declare function renderStaticLegend(config: StaticLegendConfig): React.ReactNode;
|
|
69
|
+
export declare function renderStaticLegendGroups(config: StaticLegendGroupsConfig): React.ReactNode;
|
|
70
|
+
export declare function renderStaticGradientLegend(config: StaticGradientLegendConfig): React.ReactNode;
|
|
37
71
|
/**
|
|
38
72
|
* Extract unique categories from data using an accessor.
|
|
39
73
|
*/
|
|
40
74
|
export declare function extractCategories(data: any[], accessor: string | ((d: Datum) => string) | undefined): string[];
|
|
75
|
+
export {};
|
|
@@ -34,6 +34,8 @@ export interface SemioticTheme {
|
|
|
34
34
|
textSecondary: string;
|
|
35
35
|
grid: string;
|
|
36
36
|
border: string;
|
|
37
|
+
/** Separator/border color for cell-like marks such as treemap tiles and heatmap cells. Falls back to `border`. */
|
|
38
|
+
cellBorder?: string;
|
|
37
39
|
focus?: string;
|
|
38
40
|
/** Linked hover/selection highlight color */
|
|
39
41
|
selection?: string;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ChartObservation } from "./ObservationStore";
|
|
2
|
+
import type { InterrogationFocus } from "./useChartInterrogation";
|
|
3
|
+
export interface UseChartFocusOptions {
|
|
4
|
+
/** Limit attention to a specific chart instance. Required when the page has more than one. */
|
|
5
|
+
chartId?: string;
|
|
6
|
+
/**
|
|
7
|
+
* Which observation types count as "focused." Default is hover + click +
|
|
8
|
+
* selection — anything that signals user attention. Set to ["click"] for
|
|
9
|
+
* sticky-focus UIs where hover doesn't change the AI's reference point.
|
|
10
|
+
*/
|
|
11
|
+
types?: ChartObservation["type"][];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Convenience hook: returns the latest `InterrogationFocus` for use with
|
|
15
|
+
* `useChartInterrogation`'s `focus` option. Internally subscribes to the
|
|
16
|
+
* observation store and converts the latest matching observation into the
|
|
17
|
+
* focus shape.
|
|
18
|
+
*
|
|
19
|
+
* Pair with `<Chart onObservation={…} chartId="myChart" />` and an
|
|
20
|
+
* `<ObservationProvider>` ancestor.
|
|
21
|
+
*
|
|
22
|
+
* Returns `null` when no qualifying observation has fired yet.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* function ChartWithChat({ data }) {
|
|
26
|
+
* const focus = useChartFocus({ chartId: "sales" })
|
|
27
|
+
* const { ask, history, annotations } = useChartInterrogation({
|
|
28
|
+
* data,
|
|
29
|
+
* focus, // ← latest hovered/clicked datum threads in
|
|
30
|
+
* onQuery: async (q, ctx) => {
|
|
31
|
+
* // ctx.focus is the same `focus` value passed above
|
|
32
|
+
* return askLLM({ question: q, focus: ctx.focus, summary: ctx.summary })
|
|
33
|
+
* },
|
|
34
|
+
* })
|
|
35
|
+
* return (
|
|
36
|
+
* <>
|
|
37
|
+
* <LineChart data={data} chartId="sales" annotations={annotations} />
|
|
38
|
+
* <YourChatUI history={history} onAsk={ask} />
|
|
39
|
+
* </>
|
|
40
|
+
* )
|
|
41
|
+
* }
|
|
42
|
+
*/
|
|
43
|
+
export declare function useChartFocus(options?: UseChartFocusOptions): InterrogationFocus | null;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import type { Datum } from "../charts/shared/datumTypes";
|
|
2
|
+
import { type DataSummary } from "../data/DataSummarizer";
|
|
3
|
+
import type { ChartDataProfile, Suggestion } from "../ai/chartCapabilityTypes";
|
|
4
|
+
import type { IntentId } from "../ai/intents";
|
|
5
|
+
/**
|
|
6
|
+
* Identifies a single point of interest on the chart — typically the datum
|
|
7
|
+
* the user is currently hovering, clicked, or otherwise focused on. When
|
|
8
|
+
* provided, the LLM gets the explicit signal that the user is asking
|
|
9
|
+
* "about *this specific point*" rather than the chart at large.
|
|
10
|
+
*/
|
|
11
|
+
export interface InterrogationFocus {
|
|
12
|
+
/** The row the user is focused on. */
|
|
13
|
+
datum: Datum;
|
|
14
|
+
/** Pixel x coordinate, when known. Useful for anchoring response annotations. */
|
|
15
|
+
x?: number;
|
|
16
|
+
/** Pixel y coordinate, when known. */
|
|
17
|
+
y?: number;
|
|
18
|
+
/** Optional source label — "hover" / "click" / "selection". Surfaces in the LLM prompt. */
|
|
19
|
+
source?: "hover" | "click" | "selection" | "manual";
|
|
20
|
+
}
|
|
21
|
+
export interface InterrogationContext {
|
|
22
|
+
/** The data extracted from the chart (or whatever caller passed in). */
|
|
23
|
+
data: ReadonlyArray<Datum>;
|
|
24
|
+
/** Statistical summary, ready to send to an LLM. */
|
|
25
|
+
summary: DataSummary;
|
|
26
|
+
/** Shape profile — present when `includeProfile` or `includeSuggestions` is enabled. */
|
|
27
|
+
profile?: ChartDataProfile;
|
|
28
|
+
/** Heuristic chart suggestions — present when `includeSuggestions` is enabled. */
|
|
29
|
+
suggestions?: ReadonlyArray<Suggestion>;
|
|
30
|
+
/** Optional caller-supplied chart component name (e.g. "LineChart"). */
|
|
31
|
+
componentName?: string;
|
|
32
|
+
/** Optional caller-supplied chart props (accessor names, scales, etc.). */
|
|
33
|
+
props?: Record<string, unknown>;
|
|
34
|
+
/**
|
|
35
|
+
* The current focused datum — what the user is interactively pointing at.
|
|
36
|
+
* Lets the LLM tailor responses to a specific point ("why is *this* one
|
|
37
|
+
* higher than the rest?") and to anchor visual responses (callouts,
|
|
38
|
+
* comments) back at the same coordinates.
|
|
39
|
+
*/
|
|
40
|
+
focus?: InterrogationFocus;
|
|
41
|
+
}
|
|
42
|
+
export interface InterrogationResult {
|
|
43
|
+
/** Natural-language answer to display to the user. */
|
|
44
|
+
answer: string;
|
|
45
|
+
/** Optional Semiotic annotations to overlay on the chart. */
|
|
46
|
+
annotations?: ReadonlyArray<Datum>;
|
|
47
|
+
}
|
|
48
|
+
export type InterrogationQuery = (query: string, context: InterrogationContext) => Promise<InterrogationResult>;
|
|
49
|
+
export interface InterrogationMessage {
|
|
50
|
+
role: "user" | "assistant";
|
|
51
|
+
text: string;
|
|
52
|
+
}
|
|
53
|
+
export interface UseChartInterrogationOptions {
|
|
54
|
+
/** Data backing the chart. Use whatever shape the chart consumes (rows, nodes, etc.). */
|
|
55
|
+
data: ReadonlyArray<Datum> | null | undefined;
|
|
56
|
+
/** Async handler — typically calls your LLM with the query + summary. */
|
|
57
|
+
onQuery: InterrogationQuery;
|
|
58
|
+
/** Annotations to seed the merged set (e.g. existing chart annotations). */
|
|
59
|
+
initialAnnotations?: ReadonlyArray<Datum>;
|
|
60
|
+
/** Optional context passed through to onQuery for richer prompts. */
|
|
61
|
+
componentName?: string;
|
|
62
|
+
/** Optional context passed through to onQuery. */
|
|
63
|
+
props?: Record<string, unknown>;
|
|
64
|
+
/**
|
|
65
|
+
* Include the shape `profile` in the interrogation context. Required to let an LLM
|
|
66
|
+
* reason about candidate axes, distinct counts, hierarchy/network/geo detection, etc.
|
|
67
|
+
*/
|
|
68
|
+
includeProfile?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Include heuristic chart `suggestions` in the interrogation context. Implies `includeProfile`.
|
|
71
|
+
* Lets an LLM answer "would another chart show this better?" without re-deriving rules.
|
|
72
|
+
*/
|
|
73
|
+
includeSuggestions?: boolean;
|
|
74
|
+
/** When `includeSuggestions` is true, rank by this intent. */
|
|
75
|
+
suggestionsIntent?: IntentId | IntentId[];
|
|
76
|
+
/** When `includeSuggestions` is true, cap the suggestion list. Default 5. */
|
|
77
|
+
suggestionsMax?: number;
|
|
78
|
+
/**
|
|
79
|
+
* The point on the chart the user is currently focused on. Forwarded to
|
|
80
|
+
* onQuery so an LLM can answer "about this specific datum" rather than
|
|
81
|
+
* "about the chart in general." Typically wired from a chart's
|
|
82
|
+
* `onObservation` callback or the convenience `useChartFocus` hook.
|
|
83
|
+
*/
|
|
84
|
+
focus?: InterrogationFocus | null;
|
|
85
|
+
}
|
|
86
|
+
export interface UseChartInterrogationResult {
|
|
87
|
+
/** Ask a question. Updates history, annotations, loading, and error. */
|
|
88
|
+
ask: (query: string) => Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Append an AI-initiated message to the transcript without a user query.
|
|
91
|
+
*
|
|
92
|
+
* Use for proactive narration — a streaming watcher that detected an
|
|
93
|
+
* anomaly, a background analysis that surfaced an insight, an LLM that
|
|
94
|
+
* decided to volunteer information mid-session. Synchronous; no `onQuery`
|
|
95
|
+
* call. Annotations merge into the chart's `annotations` array like
|
|
96
|
+
* any other AI response.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* announce({
|
|
100
|
+
* text: "Spike detected at 14:32 — 3.2σ above rolling mean.",
|
|
101
|
+
* annotations: [{ type: "callout", ts: now, value: 850, note: "Slow query?" }],
|
|
102
|
+
* })
|
|
103
|
+
*/
|
|
104
|
+
announce: (message: {
|
|
105
|
+
text: string;
|
|
106
|
+
annotations?: ReadonlyArray<Datum>;
|
|
107
|
+
}) => void;
|
|
108
|
+
/** Conversation history, oldest first. */
|
|
109
|
+
history: ReadonlyArray<InterrogationMessage>;
|
|
110
|
+
/** Statistical summary of the data — memoized, safe to pass to a prompt. */
|
|
111
|
+
summary: DataSummary;
|
|
112
|
+
/** Merged annotations: initial + latest AI response. Pass to the chart's `annotations` prop. */
|
|
113
|
+
annotations: ReadonlyArray<Datum>;
|
|
114
|
+
/** True while onQuery is in flight. */
|
|
115
|
+
loading: boolean;
|
|
116
|
+
/** Last error from onQuery, if any. */
|
|
117
|
+
error: Error | null;
|
|
118
|
+
/** Clear history, AI annotations, and error. */
|
|
119
|
+
reset: () => void;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Headless interrogation hook — a sibling to `useChartObserver`.
|
|
123
|
+
*
|
|
124
|
+
* Generates an LLM-friendly statistical summary of your chart's data, runs queries through
|
|
125
|
+
* a caller-supplied `onQuery`, and merges any annotations the response returns so the chart
|
|
126
|
+
* can highlight what the model is talking about.
|
|
127
|
+
*
|
|
128
|
+
* The hook owns no UI. Render whatever input/transcript surface fits your product.
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* const { ask, history, annotations, loading } = useChartInterrogation({
|
|
132
|
+
* data,
|
|
133
|
+
* onQuery: async (q, ctx) => {
|
|
134
|
+
* const res = await fetch("/api/chat", { method: "POST", body: JSON.stringify({ q, summary: ctx.summary }) })
|
|
135
|
+
* return res.json()
|
|
136
|
+
* },
|
|
137
|
+
* })
|
|
138
|
+
*
|
|
139
|
+
* <LineChart data={data} annotations={annotations} ... />
|
|
140
|
+
*/
|
|
141
|
+
export declare function useChartInterrogation(options: UseChartInterrogationOptions): UseChartInterrogationResult;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Datum } from "../charts/shared/datumTypes";
|
|
2
2
|
import type { ReactNode } from "react";
|
|
3
3
|
import type { NetworkLabel } from "./networkTypes";
|
|
4
|
-
import type { LegendGroup, GradientLegendConfig } from "../types/legendTypes";
|
|
4
|
+
import type { LegendGroup, GradientLegendConfig, LegendLayout } from "../types/legendTypes";
|
|
5
5
|
type AnnotationAnchorNode = {
|
|
6
6
|
type: string;
|
|
7
7
|
datum: Datum | null;
|
|
@@ -43,6 +43,7 @@ export interface NetworkSVGOverlayProps {
|
|
|
43
43
|
legendHighlightedCategory?: string | null;
|
|
44
44
|
legendIsolatedCategories?: Set<string>;
|
|
45
45
|
legendPosition?: "right" | "left" | "top" | "bottom";
|
|
46
|
+
legendLayout?: LegendLayout;
|
|
46
47
|
/** User-provided SVG elements on top */
|
|
47
48
|
foregroundGraphics?: ReactNode;
|
|
48
49
|
/** Scene nodes for annotation positioning */
|
|
@@ -3,7 +3,7 @@ import * as React from "react";
|
|
|
3
3
|
import type { OrdinalScales } from "./ordinalTypes";
|
|
4
4
|
import type { AnnotationContext } from "../realtime/types";
|
|
5
5
|
import type { ReactNode } from "react";
|
|
6
|
-
import type { LegendGroup, GradientLegendConfig } from "../types/legendTypes";
|
|
6
|
+
import type { LegendGroup, GradientLegendConfig, LegendLayout } from "../types/legendTypes";
|
|
7
7
|
import { type AxisExtentMode } from "../charts/shared/axisExtent";
|
|
8
8
|
interface OrdinalSVGOverlayProps {
|
|
9
9
|
width: number;
|
|
@@ -49,6 +49,7 @@ interface OrdinalSVGOverlayProps {
|
|
|
49
49
|
legendHighlightedCategory?: string | null;
|
|
50
50
|
legendIsolatedCategories?: Set<string>;
|
|
51
51
|
legendPosition?: "right" | "left" | "top" | "bottom";
|
|
52
|
+
legendLayout?: LegendLayout;
|
|
52
53
|
foregroundGraphics?: ReactNode;
|
|
53
54
|
annotations?: Datum[];
|
|
54
55
|
svgAnnotationRules?: (annotation: Datum, index: number, context: AnnotationContext) => ReactNode;
|
|
@@ -2,7 +2,7 @@ import type { Datum } from "../charts/shared/datumTypes";
|
|
|
2
2
|
import type { StreamScales, MarginalGraphicsConfig, XYFrameAxisConfig } from "./types";
|
|
3
3
|
import type { AnnotationContext } from "../realtime/types";
|
|
4
4
|
import type { ReactNode } from "react";
|
|
5
|
-
import type { LegendGroup, GradientLegendConfig } from "../types/legendTypes";
|
|
5
|
+
import type { LegendGroup, GradientLegendConfig, LegendLayout } from "../types/legendTypes";
|
|
6
6
|
export type AxisConfig = XYFrameAxisConfig;
|
|
7
7
|
interface SVGOverlayProps {
|
|
8
8
|
width: number;
|
|
@@ -51,6 +51,7 @@ interface SVGOverlayProps {
|
|
|
51
51
|
legendIsolatedCategories?: Set<string>;
|
|
52
52
|
/** Legend position relative to chart area */
|
|
53
53
|
legendPosition?: "right" | "left" | "top" | "bottom";
|
|
54
|
+
legendLayout?: LegendLayout;
|
|
54
55
|
foregroundGraphics?: ReactNode;
|
|
55
56
|
marginalGraphics?: MarginalGraphicsConfig;
|
|
56
57
|
xValues?: number[];
|
|
@@ -13,7 +13,7 @@ export declare function xySceneNodeToSVG(node: SceneNode, i: number, idPrefix?:
|
|
|
13
13
|
export declare function networkSceneNodeToSVG(node: NetworkSceneNode, i: number): React.ReactNode;
|
|
14
14
|
export declare function networkSceneEdgeToSVG(edge: NetworkSceneEdge, i: number): React.ReactNode;
|
|
15
15
|
export declare function networkLabelToSVG(label: NetworkLabel, i: number): React.ReactNode;
|
|
16
|
-
export declare function ordinalSceneNodeToSVG(node: OrdinalSceneNode, i: number): React.ReactNode;
|
|
16
|
+
export declare function ordinalSceneNodeToSVG(node: OrdinalSceneNode, i: number, idPrefix?: string): React.ReactNode;
|
|
17
17
|
export declare function geoSceneNodeToSVG(node: GeoSceneNode, i: number): React.ReactNode;
|
|
18
18
|
/**
|
|
19
19
|
* Returns true when running in a true server/Node.js context where
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import type { GeoProjection, GeoPath, GeoPermissibleObjects } from "d3-geo";
|
|
3
|
-
import type { GradientLegendConfig, LegendGroup } from "../types/legendTypes";
|
|
3
|
+
import type { GradientLegendConfig, LegendGroup, LegendLayout } from "../types/legendTypes";
|
|
4
4
|
import type { Style, DecayConfig, PulseConfig, TransitionConfig, StalenessConfig, SceneDatum, PointSceneNode, ThemeSemanticColors } from "./types";
|
|
5
5
|
import type { AnimateProp } from "./pipelineTransitionUtils";
|
|
6
6
|
import type { HoverAnnotationConfig, HoverData } from "../realtime/types";
|
|
@@ -191,6 +191,7 @@ export interface StreamGeoFrameProps<T = Datum> {
|
|
|
191
191
|
gradient: GradientLegendConfig;
|
|
192
192
|
};
|
|
193
193
|
legendPosition?: "right" | "left" | "top" | "bottom";
|
|
194
|
+
legendLayout?: LegendLayout;
|
|
194
195
|
legendHoverBehavior?: (item: {
|
|
195
196
|
label: string;
|
|
196
197
|
} | null) => void;
|
|
@@ -19,6 +19,7 @@ export interface HoverPointerCoords {
|
|
|
19
19
|
clientX: number;
|
|
20
20
|
clientY: number;
|
|
21
21
|
}
|
|
22
|
+
export declare function normalizeHoverDatum(rawDatum: any): any;
|
|
22
23
|
/**
|
|
23
24
|
* Build a HoverData object from a raw datum and pixel coordinates.
|
|
24
25
|
* The raw datum is preserved as `hover.data` for tooltip / callback
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
-
import type { LegendGroup, GradientLegendConfig } from "../types/legendTypes";
|
|
2
|
+
import type { LegendGroup, GradientLegendConfig, LegendLayout } from "../types/legendTypes";
|
|
3
3
|
export interface LegendRenderConfig {
|
|
4
4
|
legend: ReactNode | {
|
|
5
5
|
legendGroups: LegendGroup[];
|
|
@@ -15,6 +15,7 @@ export interface LegendRenderConfig {
|
|
|
15
15
|
left: number;
|
|
16
16
|
};
|
|
17
17
|
legendPosition?: "right" | "left" | "top" | "bottom";
|
|
18
|
+
legendLayout?: LegendLayout;
|
|
18
19
|
title?: string | ReactNode;
|
|
19
20
|
legendHoverBehavior?: (item: {
|
|
20
21
|
label: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import type { OnObservationCallback } from "../store/ObservationStore";
|
|
3
3
|
import type { HoverData, AnnotationContext } from "../realtime/types";
|
|
4
|
-
import type { LegendGroup } from "../types/legendTypes";
|
|
4
|
+
import type { LegendGroup, LegendLayout } from "../types/legendTypes";
|
|
5
5
|
import type { Style, DecayConfig, PulseConfig, TransitionConfig, StalenessConfig, ThemeSemanticColors, SceneDatum } from "./types";
|
|
6
6
|
import type { AnimateProp } from "./pipelineTransitionUtils";
|
|
7
7
|
import type { Datum } from "../charts/shared/datumTypes";
|
|
@@ -523,6 +523,7 @@ export interface StreamNetworkFrameProps<T = Datum> {
|
|
|
523
523
|
legendGroups: LegendGroup[];
|
|
524
524
|
};
|
|
525
525
|
legendPosition?: "right" | "left" | "top" | "bottom";
|
|
526
|
+
legendLayout?: LegendLayout;
|
|
526
527
|
legendHoverBehavior?: (item: {
|
|
527
528
|
label: string;
|
|
528
529
|
} | null) => void;
|
|
@@ -3,7 +3,7 @@ import type { ScaleLinear, ScaleBand } from "d3-scale";
|
|
|
3
3
|
import type { WindowMode, HoverAnnotationConfig, HoverData, AnnotationContext } from "../realtime/types";
|
|
4
4
|
import type { Style, SceneDatum, DecayConfig, PulseConfig, TransitionConfig, StalenessConfig, ThemeSemanticColors } from "./types";
|
|
5
5
|
import type { AnimateProp } from "./pipelineTransitionUtils";
|
|
6
|
-
import type { LegendGroup } from "../types/legendTypes";
|
|
6
|
+
import type { GradientLegendConfig, LegendGroup, LegendLayout } from "../types/legendTypes";
|
|
7
7
|
import type { Datum } from "../charts/shared/datumTypes";
|
|
8
8
|
export type OrdinalChartType = "bar" | "clusterbar" | "point" | "swarm" | "pie" | "donut" | "boxplot" | "violin" | "histogram" | "ridgeline" | "timeline" | "funnel" | "bar-funnel" | "swimlane" | "custom";
|
|
9
9
|
export interface OrdinalScales {
|
|
@@ -37,6 +37,19 @@ export interface WedgeSceneNode {
|
|
|
37
37
|
start?: boolean;
|
|
38
38
|
end?: boolean;
|
|
39
39
|
};
|
|
40
|
+
/** Render the wedge's interior as N equal angular slices, each filled
|
|
41
|
+
* with the corresponding color from `colors`. The wedge's own shape
|
|
42
|
+
* (incl. `cornerRadius` + `roundedEnds`) is used as a clip mask so
|
|
43
|
+
* only the slice geometry shows through the rounded outline. Used by
|
|
44
|
+
* GaugeChart's gradient-fill mode: the band reads as one continuous
|
|
45
|
+
* rounded arc with a gradient sampled along its length, without any
|
|
46
|
+
* individual slice (which would be far too narrow to host its own
|
|
47
|
+
* rounded corners) needing to round. Slices are an internal
|
|
48
|
+
* rendering detail — they do not appear as separate scene nodes,
|
|
49
|
+
* participate in hit testing, or transition independently. */
|
|
50
|
+
_gradientBand?: {
|
|
51
|
+
colors: string[];
|
|
52
|
+
};
|
|
40
53
|
style: Style;
|
|
41
54
|
datum: SceneDatum;
|
|
42
55
|
category?: string;
|
|
@@ -373,7 +386,7 @@ export interface StreamOrdinalFrameProps<T = Datum> {
|
|
|
373
386
|
legend?: ReactNode | {
|
|
374
387
|
legendGroups: LegendGroup[];
|
|
375
388
|
} | {
|
|
376
|
-
gradient:
|
|
389
|
+
gradient: GradientLegendConfig;
|
|
377
390
|
};
|
|
378
391
|
legendHoverBehavior?: (item: {
|
|
379
392
|
label: string;
|
|
@@ -384,6 +397,7 @@ export interface StreamOrdinalFrameProps<T = Datum> {
|
|
|
384
397
|
legendHighlightedCategory?: string | null;
|
|
385
398
|
legendIsolatedCategories?: Set<string>;
|
|
386
399
|
legendPosition?: "right" | "left" | "top" | "bottom";
|
|
400
|
+
legendLayout?: LegendLayout;
|
|
387
401
|
/** Accessor used to report the current legend category domain in push mode. */
|
|
388
402
|
legendCategoryAccessor?: string | ((d: T) => string);
|
|
389
403
|
/** Fires when the current legend category domain changes after scene rebuilds. */
|
|
@@ -54,3 +54,34 @@ export interface AnnularPathOptions {
|
|
|
54
54
|
* unrounded so the path stays well-formed.
|
|
55
55
|
*/
|
|
56
56
|
export declare function annularSectorPath(opts: AnnularPathOptions): string;
|
|
57
|
+
/**
|
|
58
|
+
* Build the clip outline + slice paths for a gauge gradient band.
|
|
59
|
+
*
|
|
60
|
+
* The band is rendered as one rounded annular sector used as a clip
|
|
61
|
+
* mask, with N unrounded slice sectors painted inside. Each slice
|
|
62
|
+
* extends from its own start angle out to the band's full end angle,
|
|
63
|
+
* so adjacent colors overpaint each other's trailing edge — eliminates
|
|
64
|
+
* subpixel AA gaps between slices without an explicit overlap epsilon
|
|
65
|
+
* and means the staircase reveals one color per `sliceAngle` of arc.
|
|
66
|
+
*
|
|
67
|
+
* Canvas and SVG renderers both consume this: canvas builds Path2D
|
|
68
|
+
* objects from the strings, SVG drops them straight into `<path d="…"/>`.
|
|
69
|
+
*/
|
|
70
|
+
export interface GaugeGradientGeometryOptions {
|
|
71
|
+
innerRadius: number;
|
|
72
|
+
outerRadius: number;
|
|
73
|
+
startAngle: number;
|
|
74
|
+
endAngle: number;
|
|
75
|
+
cornerRadius?: number;
|
|
76
|
+
roundStart?: boolean;
|
|
77
|
+
roundEnd?: boolean;
|
|
78
|
+
colors: string[];
|
|
79
|
+
}
|
|
80
|
+
export interface GaugeGradientGeometry {
|
|
81
|
+
clipPath: string;
|
|
82
|
+
slices: {
|
|
83
|
+
d: string;
|
|
84
|
+
color: string;
|
|
85
|
+
}[];
|
|
86
|
+
}
|
|
87
|
+
export declare function buildGaugeGradientGeometry(opts: GaugeGradientGeometryOptions): GaugeGradientGeometry;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import type { ScaleLinear } from "d3-scale";
|
|
3
3
|
import type { AnimateProp } from "./pipelineTransitionUtils";
|
|
4
|
-
import type { LegendGroup, GradientLegendConfig } from "../types/legendTypes";
|
|
4
|
+
import type { LegendGroup, GradientLegendConfig, LegendLayout } from "../types/legendTypes";
|
|
5
5
|
import type { ArrowOfTime, WindowMode, LineStyle, BarStyle, WaterfallStyle, SwarmStyle, HoverAnnotationConfig, HoverData, AnnotationContext, AnnotationAnchorMode } from "../realtime/types";
|
|
6
6
|
import type { Datum } from "../charts/shared/datumTypes";
|
|
7
7
|
import type { CoercibleNumber } from "./accessorUtils";
|
|
@@ -651,6 +651,7 @@ export interface StreamXYFrameProps<T = Datum> {
|
|
|
651
651
|
legendHighlightedCategory?: string | null;
|
|
652
652
|
legendIsolatedCategories?: Set<string>;
|
|
653
653
|
legendPosition?: "right" | "left" | "top" | "bottom";
|
|
654
|
+
legendLayout?: LegendLayout;
|
|
654
655
|
/** Accessor used to report the current legend category domain in push mode. */
|
|
655
656
|
legendCategoryAccessor?: string | ((d: T) => string);
|
|
656
657
|
/** Fires when the current legend category domain changes after scene rebuilds. */
|
|
@@ -31,6 +31,20 @@ export declare function isLegendConfig(value: unknown): value is {
|
|
|
31
31
|
export declare function isGradientLegendConfig(value: unknown): value is {
|
|
32
32
|
gradient: GradientLegendConfig;
|
|
33
33
|
};
|
|
34
|
+
export interface LegendLayout {
|
|
35
|
+
/** Horizontal alignment for top/bottom legends within the plot width */
|
|
36
|
+
align?: "start" | "center" | "end" | "left" | "right";
|
|
37
|
+
/** Width/height of categorical swatches in pixels */
|
|
38
|
+
swatchSize?: number;
|
|
39
|
+
/** Gap between a swatch and its label in pixels */
|
|
40
|
+
labelGap?: number;
|
|
41
|
+
/** Gap between horizontal legend items in pixels */
|
|
42
|
+
itemGap?: number;
|
|
43
|
+
/** Vertical row height for stacked legend items in pixels */
|
|
44
|
+
rowHeight?: number;
|
|
45
|
+
/** Override the alignment width used for top/bottom legends */
|
|
46
|
+
maxWidth?: number;
|
|
47
|
+
}
|
|
34
48
|
export interface LegendProps {
|
|
35
49
|
legendGroups?: LegendGroup[];
|
|
36
50
|
customClickBehavior?: (item: LegendItem) => void;
|
|
@@ -46,4 +60,5 @@ export interface LegendProps {
|
|
|
46
60
|
height?: number;
|
|
47
61
|
orientation?: string;
|
|
48
62
|
position?: "left" | "right";
|
|
63
|
+
legendLayout?: LegendLayout;
|
|
49
64
|
}
|
|
@@ -8,8 +8,22 @@ export interface MarginType {
|
|
|
8
8
|
left: number;
|
|
9
9
|
right: number;
|
|
10
10
|
}
|
|
11
|
+
/** Public margin side value. Numbers pin a side to an exact pixel value.
|
|
12
|
+
* `"auto"` and `null` explicitly leave that side to chart defaults plus
|
|
13
|
+
* auto-reservation such as legends. */
|
|
14
|
+
export type MarginSide = number | "auto" | null | undefined;
|
|
11
15
|
/** Public-API margin shape. Users can pass any subset of sides (`{ left: 120 }`
|
|
12
16
|
* for wide y-axis labels is a common pattern) or a single number as shorthand
|
|
13
|
-
* for "same on all sides".
|
|
14
|
-
*
|
|
15
|
-
|
|
17
|
+
* for "same on all sides". Pass a side as `"auto"` or `null` to explicitly
|
|
18
|
+
* opt back into chart auto-reservation for that side, e.g.
|
|
19
|
+
* `{ right: "auto" }` with a right-side legend. The frame fills missing/auto
|
|
20
|
+
* sides from chart-mode defaults before handing a fully-resolved
|
|
21
|
+
* `MarginType` to the layout code. */
|
|
22
|
+
export type PartialMargin = number | {
|
|
23
|
+
top?: MarginSide;
|
|
24
|
+
right?: MarginSide;
|
|
25
|
+
bottom?: MarginSide;
|
|
26
|
+
left?: MarginSide;
|
|
27
|
+
};
|
|
28
|
+
export declare function resolveMarginSide(value: MarginSide, fallback: number): number;
|
|
29
|
+
export declare function normalizePartialMargin(m: PartialMargin | undefined): Partial<MarginType> | undefined;
|