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,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse a window duration to milliseconds.
|
|
3
|
+
*
|
|
4
|
+
* - A finite number is returned as-is (already milliseconds).
|
|
5
|
+
* - A string is parsed as one or more `<number><unit>` terms summed
|
|
6
|
+
* together: `"1m"`, `"500ms"`, `"1m30s"`.
|
|
7
|
+
*
|
|
8
|
+
* Returns `null` for unparseable input (empty string, unknown unit,
|
|
9
|
+
* non-positive result, non-finite number) so callers can fall back to
|
|
10
|
+
* a default rather than silently bucketing on a zero-width window.
|
|
11
|
+
*/
|
|
12
|
+
export declare function parseWindowDuration(spec: number | string): number | null;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface CustomTooltipEntry {
|
|
2
|
+
key: string;
|
|
3
|
+
label: string;
|
|
4
|
+
value: unknown;
|
|
5
|
+
formatted: string;
|
|
6
|
+
}
|
|
7
|
+
export interface CustomTooltipEntryOptions {
|
|
8
|
+
/** Maximum number of rows to return. @default 8 */
|
|
9
|
+
maxEntries?: number;
|
|
10
|
+
/** Extra keys to omit in addition to underscore-prefixed internals. */
|
|
11
|
+
excludeKeys?: readonly string[] | Set<string>;
|
|
12
|
+
/** Include underscore-prefixed keys. @default false */
|
|
13
|
+
includeInternal?: boolean;
|
|
14
|
+
/** Include null, undefined, and empty-string values. @default false */
|
|
15
|
+
includeEmpty?: boolean;
|
|
16
|
+
/** Optional display labels by key. */
|
|
17
|
+
labels?: Record<string, string> | ((key: string) => string);
|
|
18
|
+
/** Optional value formatter. */
|
|
19
|
+
valueFormat?: (value: unknown, key: string, datum: Record<string, unknown>) => string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Extract the user-facing datum from Semiotic hover/observation payloads.
|
|
23
|
+
*
|
|
24
|
+
* Custom charts can surface hover payloads as `hover.datum`,
|
|
25
|
+
* `hover.datum.data`, `hover.data`, or `hover.data.data` depending on the
|
|
26
|
+
* frame family and scene node type. This helper normalizes those shapes and
|
|
27
|
+
* drops internal/function fields so tooltips do not render empty chrome.
|
|
28
|
+
*/
|
|
29
|
+
export declare function extractTooltipDatum(payload: unknown): Record<string, unknown> | null;
|
|
30
|
+
export declare function buildTooltipEntries(payload: unknown, options?: CustomTooltipEntryOptions): CustomTooltipEntry[];
|
|
31
|
+
export declare function formatTooltipValue(value: unknown): string;
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
import type { CustomLayout, LayoutContext } from "../stream/customLayout";
|
|
4
|
+
import type { NetworkCustomLayout } from "../stream/networkCustomLayout";
|
|
5
|
+
import type { Datum } from "../charts/shared/datumTypes";
|
|
6
|
+
import type { Style } from "../stream/types";
|
|
7
|
+
import type { BezierPoint } from "../stream/networkTypes";
|
|
8
|
+
export type GofishGlyphMark = {
|
|
9
|
+
kind: "rect";
|
|
10
|
+
id: string;
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
style?: Style;
|
|
16
|
+
datum?: Datum;
|
|
17
|
+
group?: string;
|
|
18
|
+
interactive?: boolean;
|
|
19
|
+
rx?: number;
|
|
20
|
+
/** Clip this mark to an SVG path (pixel coords) — e.g. a fill to a silhouette. */
|
|
21
|
+
clipPath?: string;
|
|
22
|
+
} | {
|
|
23
|
+
kind: "image";
|
|
24
|
+
id: string;
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
width: number;
|
|
28
|
+
height: number;
|
|
29
|
+
href: string;
|
|
30
|
+
/** @default "none" — stretch to the box; "xMidYMid meet" to letterbox. */
|
|
31
|
+
preserveAspectRatio?: string;
|
|
32
|
+
opacity?: number;
|
|
33
|
+
/** Clip the image to an SVG path (pixel coords). */
|
|
34
|
+
clipPath?: string;
|
|
35
|
+
} | {
|
|
36
|
+
kind: "circle";
|
|
37
|
+
id: string;
|
|
38
|
+
cx: number;
|
|
39
|
+
cy: number;
|
|
40
|
+
r: number;
|
|
41
|
+
style?: Style;
|
|
42
|
+
datum?: Datum;
|
|
43
|
+
group?: string;
|
|
44
|
+
interactive?: boolean;
|
|
45
|
+
} | {
|
|
46
|
+
kind: "area";
|
|
47
|
+
id: string;
|
|
48
|
+
topPath: [number, number][];
|
|
49
|
+
bottomPath: [number, number][];
|
|
50
|
+
style?: Style;
|
|
51
|
+
datum?: Datum[];
|
|
52
|
+
group?: string;
|
|
53
|
+
} | {
|
|
54
|
+
kind: "path";
|
|
55
|
+
id: string;
|
|
56
|
+
d: string;
|
|
57
|
+
style?: Style;
|
|
58
|
+
datum?: Datum;
|
|
59
|
+
group?: string;
|
|
60
|
+
clipPath?: string;
|
|
61
|
+
} | {
|
|
62
|
+
kind: "line";
|
|
63
|
+
id: string;
|
|
64
|
+
x1: number;
|
|
65
|
+
y1: number;
|
|
66
|
+
x2: number;
|
|
67
|
+
y2: number;
|
|
68
|
+
style?: Style;
|
|
69
|
+
} | {
|
|
70
|
+
kind: "text";
|
|
71
|
+
id: string;
|
|
72
|
+
x: number;
|
|
73
|
+
y: number;
|
|
74
|
+
text: ReactNode;
|
|
75
|
+
style?: Style;
|
|
76
|
+
fontSize?: number;
|
|
77
|
+
fontWeight?: number | string;
|
|
78
|
+
textAnchor?: "start" | "middle" | "end";
|
|
79
|
+
dominantBaseline?: React.SVGProps<SVGTextElement>["dominantBaseline"];
|
|
80
|
+
transform?: string;
|
|
81
|
+
};
|
|
82
|
+
export interface GofishGlyphLayer {
|
|
83
|
+
marks: GofishGlyphMark[];
|
|
84
|
+
overlays?: ReactNode;
|
|
85
|
+
}
|
|
86
|
+
export interface HitRectForGlyphOptions {
|
|
87
|
+
id: string;
|
|
88
|
+
x: number;
|
|
89
|
+
y: number;
|
|
90
|
+
width: number;
|
|
91
|
+
height: number;
|
|
92
|
+
datum?: Datum;
|
|
93
|
+
group?: string;
|
|
94
|
+
style?: Style;
|
|
95
|
+
rx?: number;
|
|
96
|
+
}
|
|
97
|
+
export type GofishGlyphSolver<C extends object> = (ctx: LayoutContext<C>) => GofishGlyphLayer;
|
|
98
|
+
export declare function hitRectForGlyph(options: HitRectForGlyphOptions): GofishGlyphMark;
|
|
99
|
+
export declare function overlayGroup(children: ReactNode, className?: string): ReactNode;
|
|
100
|
+
/**
|
|
101
|
+
* Compile a small GoFish-style mark vocabulary to a Semiotic custom layout.
|
|
102
|
+
*
|
|
103
|
+
* Rects, circles, and areas become normal scene nodes when interactive is not
|
|
104
|
+
* false, so Semiotic owns hit testing, transitions, decay, SSR evidence, and
|
|
105
|
+
* tooltips. Rich glyph chrome such as petal paths, labels, bottle silhouettes,
|
|
106
|
+
* and arrows is rendered as pointer-events-none SVG overlay content.
|
|
107
|
+
*/
|
|
108
|
+
export declare function createGofishGlyphLayout<C extends object>(solve: GofishGlyphSolver<C>): CustomLayout<C>;
|
|
109
|
+
export interface GofishFlowerConfig {
|
|
110
|
+
lakeAccessor?: string | ((d: Datum) => string);
|
|
111
|
+
speciesAccessor?: string | ((d: Datum) => string);
|
|
112
|
+
countAccessor?: string | ((d: Datum) => number);
|
|
113
|
+
xAccessor?: string | ((d: Datum) => number);
|
|
114
|
+
flowerRadius?: number;
|
|
115
|
+
stemWidth?: number;
|
|
116
|
+
}
|
|
117
|
+
export interface GofishBottleConfig {
|
|
118
|
+
categoryAccessor?: string | ((d: Datum) => string);
|
|
119
|
+
amountAccessor?: string | ((d: Datum) => number);
|
|
120
|
+
bottleWidth?: number;
|
|
121
|
+
bottleHeight?: number;
|
|
122
|
+
}
|
|
123
|
+
export interface GofishPolarRibbonConfig {
|
|
124
|
+
lakeAccessor?: string | ((d: Datum) => string);
|
|
125
|
+
speciesAccessor?: string | ((d: Datum) => string);
|
|
126
|
+
countAccessor?: string | ((d: Datum) => number);
|
|
127
|
+
innerRadius?: number;
|
|
128
|
+
outerRadius?: number;
|
|
129
|
+
}
|
|
130
|
+
export interface GofishTitanicCircleTreemapConfig {
|
|
131
|
+
classAccessor?: string | ((d: Datum) => string | number);
|
|
132
|
+
survivedAccessor?: string | ((d: Datum) => string | number | boolean);
|
|
133
|
+
fareAccessor?: string | ((d: Datum) => number);
|
|
134
|
+
padding?: number;
|
|
135
|
+
}
|
|
136
|
+
export interface PythonTutorPointer {
|
|
137
|
+
pointer: number;
|
|
138
|
+
}
|
|
139
|
+
export interface PythonTutorBinding {
|
|
140
|
+
name: string;
|
|
141
|
+
value: string | PythonTutorPointer;
|
|
142
|
+
}
|
|
143
|
+
export interface PythonTutorTuple {
|
|
144
|
+
values: Array<string | PythonTutorPointer>;
|
|
145
|
+
}
|
|
146
|
+
export interface PythonTutorDiagram {
|
|
147
|
+
stack: PythonTutorBinding[];
|
|
148
|
+
heap: PythonTutorTuple[];
|
|
149
|
+
heapArrangement: Array<Array<number | null>>;
|
|
150
|
+
}
|
|
151
|
+
export interface GofishPythonTutorConfig {
|
|
152
|
+
diagram?: PythonTutorDiagram;
|
|
153
|
+
cellWidth?: number;
|
|
154
|
+
cellHeight?: number;
|
|
155
|
+
heapGap?: number;
|
|
156
|
+
}
|
|
157
|
+
export interface PythonTutorMemoryGraph {
|
|
158
|
+
nodes: Datum[];
|
|
159
|
+
edges: Datum[];
|
|
160
|
+
}
|
|
161
|
+
export declare function buildPythonTutorMemoryGraph(diagram: PythonTutorDiagram): PythonTutorMemoryGraph;
|
|
162
|
+
export declare const gofishFlowerLayout: CustomLayout<GofishFlowerConfig>;
|
|
163
|
+
export declare const gofishBottleFillLayout: CustomLayout<GofishBottleConfig>;
|
|
164
|
+
export declare const gofishPolarRibbonLayout: CustomLayout<GofishPolarRibbonConfig>;
|
|
165
|
+
export declare const gofishTitanicCircleTreemapLayout: CustomLayout<GofishTitanicCircleTreemapConfig>;
|
|
166
|
+
export declare const gofishPythonTutorLayout: CustomLayout<GofishPythonTutorConfig>;
|
|
167
|
+
export declare const gofishPythonTutorNetworkLayout: NetworkCustomLayout<GofishPythonTutorConfig>;
|
|
168
|
+
export declare function pointerCurve(start: [number, number], end: [number, number]): {
|
|
169
|
+
d: string;
|
|
170
|
+
points: [BezierPoint, BezierPoint, BezierPoint, BezierPoint];
|
|
171
|
+
};
|
|
172
|
+
interface TreemapStripRegion<T> {
|
|
173
|
+
id: string;
|
|
174
|
+
rows: T[];
|
|
175
|
+
value: number;
|
|
176
|
+
x: number;
|
|
177
|
+
y: number;
|
|
178
|
+
width: number;
|
|
179
|
+
height: number;
|
|
180
|
+
}
|
|
181
|
+
interface PackedCircle<T> {
|
|
182
|
+
row: T;
|
|
183
|
+
index: number;
|
|
184
|
+
x: number;
|
|
185
|
+
y: number;
|
|
186
|
+
r: number;
|
|
187
|
+
}
|
|
188
|
+
export declare function layoutTreemapStrip<T>(entries: Array<{
|
|
189
|
+
id: string;
|
|
190
|
+
rows: T[];
|
|
191
|
+
value: number;
|
|
192
|
+
heightValue?: number;
|
|
193
|
+
}>, bounds: {
|
|
194
|
+
x: number;
|
|
195
|
+
y: number;
|
|
196
|
+
width: number;
|
|
197
|
+
height: number;
|
|
198
|
+
}, gap: number): Array<TreemapStripRegion<T>>;
|
|
199
|
+
export declare function packCirclesInRect<T>(rows: T[], region: TreemapStripRegion<T>, value: (row: T) => number, gap: number): Array<PackedCircle<T>>;
|
|
200
|
+
export declare function datumFromFields(fields: Record<string, unknown>): Datum;
|
|
201
|
+
export declare function stableGlyphId(value: string): string;
|
|
202
|
+
export declare function polarPoint(cx: number, cy: number, r: number, angle: number): [number, number];
|
|
203
|
+
export declare function petalPath(cx: number, cy: number, innerR: number, outerR: number, start: number, end: number): string;
|
|
204
|
+
export declare function polarBandPath(cx: number, cy: number, innerR: number, outerR: number, start: number, end: number): string;
|
|
205
|
+
export declare function smoothClosedPath(points: [number, number][]): string;
|
|
206
|
+
export declare function bottlePath(x: number, y: number, w: number, h: number): string;
|
|
207
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { OrdinalCustomLayout } from "../stream/ordinalCustomLayout";
|
|
2
|
+
import type { Datum } from "../charts/shared/datumTypes";
|
|
3
|
+
export interface GofishBobaConfig {
|
|
4
|
+
/** Category — one cup per distinct value. @default "name" */
|
|
5
|
+
categoryAccessor?: string | ((d: Datum) => string);
|
|
6
|
+
/** Tea volume (cm³). @default field "teaVolume" → 450 */
|
|
7
|
+
teaVolumeAccessor?: string | ((d: Datum) => number);
|
|
8
|
+
/** Tapioca-pearl volume (cm³); pearl count derived from it. @default field "bobaVolume" → 110 */
|
|
9
|
+
bobaVolumeAccessor?: string | ((d: Datum) => number);
|
|
10
|
+
/** Ice volume (cm³); cube count derived from it. @default field "iceVolume" → 135 */
|
|
11
|
+
iceVolumeAccessor?: string | ((d: Datum) => number);
|
|
12
|
+
/** Cup height (cm). @default field "cupHeight" → 15.5 */
|
|
13
|
+
cupHeightAccessor?: string | ((d: Datum) => number);
|
|
14
|
+
/** Cup top radius (cm). @default field "cupTopRadius" → 4.75 */
|
|
15
|
+
cupTopRadiusAccessor?: string | ((d: Datum) => number);
|
|
16
|
+
/** Cup bottom radius (cm). @default field "cupBottomRadius" → 3.75 */
|
|
17
|
+
cupBottomRadiusAccessor?: string | ((d: Datum) => number);
|
|
18
|
+
/** Pearl radius (cm). @default field "bobaRadius" → 0.6 */
|
|
19
|
+
bobaRadiusAccessor?: string | ((d: Datum) => number);
|
|
20
|
+
/** Fraction of each band the cup glyph may occupy. @default 0.82 */
|
|
21
|
+
cupWidthRatio?: number;
|
|
22
|
+
}
|
|
23
|
+
export declare const gofishBobaLayout: OrdinalCustomLayout<GofishBobaConfig>;
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import type { Datum } from "../charts/shared/datumTypes";
|
|
2
|
+
import type { CustomLayout } from "../stream/customLayout";
|
|
3
|
+
import type { NetworkCustomLayout } from "../stream/networkCustomLayout";
|
|
4
|
+
import type { OrdinalCustomLayout } from "../stream/ordinalCustomLayout";
|
|
5
|
+
import type { GofishLambda } from "./gofishLambdas";
|
|
6
|
+
/**
|
|
7
|
+
* Experimental GoFish Frontend IR → Semiotic custom-layout adapter.
|
|
8
|
+
*
|
|
9
|
+
* This is the GoFish analogue of `fromVegaLite`. Where `fromVegaLite` maps a
|
|
10
|
+
* Vega-Lite spec onto a built-in HOC component + props, `unstable_fromGofishIR` maps a
|
|
11
|
+
* GoFish *Frontend IR* document (the JSON artifact GoFish's `to_ir` /
|
|
12
|
+
* serialization frontend emits — see the `gofish-ir` package) onto Semiotic's
|
|
13
|
+
* custom-layout surface.
|
|
14
|
+
*
|
|
15
|
+
* Unlike a recognizer, this *interprets* the spec: `unstable_fromGofishIR` picks a
|
|
16
|
+
* frame family, then hands the IR to `interpretGofishIR` (see
|
|
17
|
+
* `gofishInterpreter.ts`), which walks `data → operators → mark` and executes
|
|
18
|
+
* `group`/`spread`/`stack`/`scatter`/`treemap`/`layer`, the `polar`/`unit`
|
|
19
|
+
* coordinate transforms, mark channels through scales, and `connect`/`ref`/
|
|
20
|
+
* `arrow` relations. The two sanctioned non-grammar paths — `derive` and
|
|
21
|
+
* `mark-fn` — resolve through the lambda registry. Any spec built from the
|
|
22
|
+
* supported grammar renders; it is not limited to known archetypes.
|
|
23
|
+
*
|
|
24
|
+
* Frame family (hybrid): `arrow`/pointer specs → network; the boba volume
|
|
25
|
+
* signature → ordinal (Semiotic owns the category axis, the interpreter owns
|
|
26
|
+
* the within-cup composition); everything else → XY. The Python Tutor memory
|
|
27
|
+
* diagram is a genuinely bespoke diagram beyond the grammar, so it stays a
|
|
28
|
+
* chart-level escape hatch rendered by `gofishPythonTutorNetworkLayout`.
|
|
29
|
+
*
|
|
30
|
+
* Scope: GoFish Frontend IR v0. This is a PR-preview adapter named
|
|
31
|
+
* `unstable-gofish-ir-adapter`, not a release API commitment. Constructs outside the interpreter's
|
|
32
|
+
* allocation model (`table`, `cut`, `mask`, free-form `.constrain`, …) record
|
|
33
|
+
* a warning and fall back rather than silently mis-rendering.
|
|
34
|
+
*/
|
|
35
|
+
export declare const EXPERIMENTAL_GOFISH_ADAPTER_NAME = "unstable-gofish-ir-adapter";
|
|
36
|
+
/** Explicit field-accessor channel form, emitted by `field(name)`. */
|
|
37
|
+
export interface GofishFieldAccessor {
|
|
38
|
+
type: "field";
|
|
39
|
+
name: string;
|
|
40
|
+
measure?: string;
|
|
41
|
+
}
|
|
42
|
+
/** A data-driven channel value, emitted by `datum(v)` / `v(...)`. */
|
|
43
|
+
export interface GofishDatumValue {
|
|
44
|
+
type: "datum";
|
|
45
|
+
datum?: unknown;
|
|
46
|
+
offset?: number;
|
|
47
|
+
[key: string]: unknown;
|
|
48
|
+
}
|
|
49
|
+
/** The right-hand side of a mark or operator channel (`h: …`, `fill: …`). */
|
|
50
|
+
export type GofishChannelValue = string | number | boolean | null | GofishFieldAccessor | GofishDatumValue | {
|
|
51
|
+
__gofish_lambda: string;
|
|
52
|
+
};
|
|
53
|
+
export interface GofishOperatorIR {
|
|
54
|
+
type: string;
|
|
55
|
+
by?: string;
|
|
56
|
+
dir?: "x" | "y";
|
|
57
|
+
x?: GofishChannelValue;
|
|
58
|
+
y?: GofishChannelValue;
|
|
59
|
+
spacing?: number | [number, number];
|
|
60
|
+
[key: string]: unknown;
|
|
61
|
+
}
|
|
62
|
+
export interface GofishMarkIR {
|
|
63
|
+
type: string;
|
|
64
|
+
__combinator?: true;
|
|
65
|
+
children?: GofishMarkIR[];
|
|
66
|
+
source?: GofishMarkIR;
|
|
67
|
+
options?: Record<string, unknown>;
|
|
68
|
+
origin?: {
|
|
69
|
+
name?: string;
|
|
70
|
+
};
|
|
71
|
+
name?: string;
|
|
72
|
+
[key: string]: unknown;
|
|
73
|
+
}
|
|
74
|
+
export interface GofishChartIR {
|
|
75
|
+
type: "chart";
|
|
76
|
+
data?: GofishDataIR | null;
|
|
77
|
+
operators?: GofishOperatorIR[];
|
|
78
|
+
mark: GofishMarkIR;
|
|
79
|
+
options?: Record<string, unknown>;
|
|
80
|
+
connect?: GofishMarkIR;
|
|
81
|
+
name?: string;
|
|
82
|
+
}
|
|
83
|
+
export interface GofishLayerIR {
|
|
84
|
+
type: "layer";
|
|
85
|
+
charts: GofishChartIR[];
|
|
86
|
+
options?: Record<string, unknown>;
|
|
87
|
+
}
|
|
88
|
+
export interface GofishRawMarkIR {
|
|
89
|
+
type: "raw-mark";
|
|
90
|
+
mark: GofishMarkIR;
|
|
91
|
+
options?: Record<string, unknown>;
|
|
92
|
+
}
|
|
93
|
+
export type GofishDataIR = {
|
|
94
|
+
type: "inline";
|
|
95
|
+
rows: Array<Record<string, unknown>>;
|
|
96
|
+
} | {
|
|
97
|
+
type: "select";
|
|
98
|
+
layer: string;
|
|
99
|
+
mode?: "one" | "all";
|
|
100
|
+
} | {
|
|
101
|
+
type: "external";
|
|
102
|
+
id?: string;
|
|
103
|
+
};
|
|
104
|
+
export type GofishRootIR = GofishChartIR | GofishLayerIR | GofishRawMarkIR;
|
|
105
|
+
export interface GofishIRDocument {
|
|
106
|
+
irVersion: number;
|
|
107
|
+
ir: string;
|
|
108
|
+
$schema?: string;
|
|
109
|
+
root: GofishRootIR;
|
|
110
|
+
}
|
|
111
|
+
export type GofishChartFamily = "xy" | "network" | "ordinal";
|
|
112
|
+
export type GofishRecipeName =
|
|
113
|
+
/** XY / ordinal charts are produced by the IR interpreter, not a named recipe. */
|
|
114
|
+
"gofishInterpreter"
|
|
115
|
+
/** The Python Tutor memory diagram is a bespoke network glyph (chart-level escape hatch). */
|
|
116
|
+
| "gofishPythonTutorNetworkLayout";
|
|
117
|
+
/**
|
|
118
|
+
* The translated chart, spreadable into `XYCustomChart` / `NetworkCustomChart`.
|
|
119
|
+
* Mirrors `fromVegaLite`'s `{ component, props, warnings }` for the
|
|
120
|
+
* custom-layout surface.
|
|
121
|
+
*/
|
|
122
|
+
export interface GofishChartConfig {
|
|
123
|
+
family: GofishChartFamily;
|
|
124
|
+
/** Which `gofish.tsx` recipe the IR resolved to. */
|
|
125
|
+
recipe: GofishRecipeName;
|
|
126
|
+
/** Layout function to pass as `layout` on `XYCustomChart` — null otherwise. */
|
|
127
|
+
layout: CustomLayout<Record<string, unknown>> | null;
|
|
128
|
+
/** Layout function to pass as `layout` on `NetworkCustomChart` — null otherwise. */
|
|
129
|
+
networkLayout: NetworkCustomLayout<Record<string, unknown>> | null;
|
|
130
|
+
/** Layout function to pass as `layout` on `OrdinalCustomChart` — null otherwise. */
|
|
131
|
+
ordinalLayout: OrdinalCustomLayout<Record<string, unknown>> | null;
|
|
132
|
+
/** Accessor config derived from the IR; pass as `layoutConfig`. */
|
|
133
|
+
layoutConfig: Record<string, unknown>;
|
|
134
|
+
/** Category accessor for ordinal charts (the frame builds the o-scale from it). */
|
|
135
|
+
categoryAccessor?: string;
|
|
136
|
+
/** Value accessor for ordinal charts (the frame builds the r-scale from it). */
|
|
137
|
+
valueAccessor?: string;
|
|
138
|
+
/** Inline data to seed the chart (`data` / `pushMany`). Empty for network. */
|
|
139
|
+
data: Datum[];
|
|
140
|
+
/** Node/edge graph for `NetworkCustomChart` (memory diagram only). */
|
|
141
|
+
graph: {
|
|
142
|
+
nodes: Datum[];
|
|
143
|
+
edges: Datum[];
|
|
144
|
+
} | null;
|
|
145
|
+
irVersion: number;
|
|
146
|
+
warnings?: string[];
|
|
147
|
+
}
|
|
148
|
+
export interface FromGofishIROptions {
|
|
149
|
+
/** Force a frame family instead of inferring it. */
|
|
150
|
+
family?: GofishChartFamily;
|
|
151
|
+
/** Per-call `derive`/`mark-fn` lambda overrides (merged over the registry). */
|
|
152
|
+
lambdas?: Record<string, GofishLambda>;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Translate a GoFish Frontend IR document into a Semiotic custom-layout config
|
|
156
|
+
* by *interpreting* the spec.
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```tsx
|
|
160
|
+
* import { unstable_fromGofishIR } from "semiotic/experimental"
|
|
161
|
+
* import { XYCustomChart } from "semiotic/xy"
|
|
162
|
+
*
|
|
163
|
+
* const cfg = unstable_fromGofishIR(flowerIR)
|
|
164
|
+
* <XYCustomChart data={cfg.data} layout={cfg.layout} />
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
export declare function unstable_fromGofishIR(doc: GofishIRDocument, options?: FromGofishIROptions): GofishChartConfig;
|
|
168
|
+
/** @deprecated Internal compatibility alias for the temporary GoFish PR preview. */
|
|
169
|
+
export declare const fromGofishIR: typeof unstable_fromGofishIR;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { GofishIRDocument } from "./gofishIR";
|
|
2
|
+
/** The Python Tutor heap/stack snapshot, inlined as a single IR data row. */
|
|
3
|
+
export declare const pythonTutorDiagramRow: {
|
|
4
|
+
kind: string;
|
|
5
|
+
stack: ({
|
|
6
|
+
name: string;
|
|
7
|
+
value: {
|
|
8
|
+
pointer: number;
|
|
9
|
+
};
|
|
10
|
+
} | {
|
|
11
|
+
name: string;
|
|
12
|
+
value: string;
|
|
13
|
+
})[];
|
|
14
|
+
heap: {
|
|
15
|
+
values: (string | {
|
|
16
|
+
pointer: number;
|
|
17
|
+
})[];
|
|
18
|
+
}[];
|
|
19
|
+
heapArrangement: (number | null)[][];
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Deterministic Titanic passenger sample (no RNG), mirroring the docs page so
|
|
23
|
+
* the IR document is self-contained. Kept modest per class so the inline rows
|
|
24
|
+
* stay reasonable to ship and display.
|
|
25
|
+
*/
|
|
26
|
+
export declare function buildTitanicSampleRows(): Array<Record<string, unknown>>;
|
|
27
|
+
/**
|
|
28
|
+
* A meadow: one green stem per lake (a `scatter` placing each lake's bar at its
|
|
29
|
+
* x), topped by a polar fan of species petals. Single-chart form so the
|
|
30
|
+
* interpreter renders it directly: `scatter(by:lake)` → per lake a `layer` of
|
|
31
|
+
* a stem `rect` (height = summed catch) and a `polar` `stack` of `petal`s
|
|
32
|
+
* around the angle axis.
|
|
33
|
+
*/
|
|
34
|
+
export declare const flowerIR: GofishIRDocument;
|
|
35
|
+
/**
|
|
36
|
+
* A row of pictorial bottles, one per category, each filled to its `amount`
|
|
37
|
+
* percentage. Grammar-first with one `derive`: `bottleGeometry` emits the
|
|
38
|
+
* per-bottle normalized geometry under `_b`; the marks render it with the
|
|
39
|
+
* reusable `image` + clip primitives — an `image` of the bottle silhouette, a
|
|
40
|
+
* green fill `rect` clipped to that silhouette, a fill line, a percentage
|
|
41
|
+
* label, a category label, and a transparent hit rect carrying the datum.
|
|
42
|
+
*/
|
|
43
|
+
export declare const bottleIR: GofishIRDocument;
|
|
44
|
+
/**
|
|
45
|
+
* Stacked species bars laid out radially per lake (polar coord), with one
|
|
46
|
+
* cross-lake ribbon per species connecting the matching segments.
|
|
47
|
+
*/
|
|
48
|
+
export declare const polarRibbonIR: GofishIRDocument;
|
|
49
|
+
/**
|
|
50
|
+
* A bar chart that's treemap-filled and circle-filled: a `spread` lays one
|
|
51
|
+
* equal-width bar per passenger class whose HEIGHT encodes the class's total
|
|
52
|
+
* fare (`sizeBy`), and that bar rectangle becomes a squarified `treemap` of its
|
|
53
|
+
* passengers — every fare-sized cell rendered as an inscribed circle coloured
|
|
54
|
+
* by survival.
|
|
55
|
+
*/
|
|
56
|
+
export declare const titanicCircleTreemapIR: GofishIRDocument;
|
|
57
|
+
/**
|
|
58
|
+
* A Python Tutor runtime memory diagram: a global frame of variable bindings
|
|
59
|
+
* whose pointers arrow into a heap of linked tuples. Encoded as a `layer` of a
|
|
60
|
+
* `spread` (frame + heap) plus `arrow` connectors over `ref`s; the snapshot
|
|
61
|
+
* itself travels as a single inline data row consumed by the network recipe.
|
|
62
|
+
*/
|
|
63
|
+
export declare const pythonMemoryIR: GofishIRDocument;
|
|
64
|
+
/**
|
|
65
|
+
* A boba-shop menu: four bubble-tea drinks spread along the category axis, each
|
|
66
|
+
* fully data-driven. Per drink, the tea + tapioca + ice volumes (plus the
|
|
67
|
+
* cup-size parameters) add up to a total volume that determines the drink
|
|
68
|
+
* height; the pearls stack at the bottom and the ice floats at the surface — so
|
|
69
|
+
* "Extra Boba" grows a taller pearl bed, "Light Ice" reads as mostly tea, and
|
|
70
|
+
* "Mega" is a bigger cup of everything.
|
|
71
|
+
*
|
|
72
|
+
* Grammar-first, per the "follow the spec as far as it can" rule: the cup, tea,
|
|
73
|
+
* straw, and lid are real `polygon`/`line` marks and the pearls/ice are real
|
|
74
|
+
* `circle`/`rect` marks. The one genuinely non-grammar step — the
|
|
75
|
+
* frustum-volume → drink-height solve and tapioca/ice packing — lives in a
|
|
76
|
+
* single `derive` lambda (`bobaGeometry`) that emits each cup's geometry the
|
|
77
|
+
* marks read (`_g.*`) plus a shared `_g.box` aspect for the `uniform` unit fit,
|
|
78
|
+
* so the cups sit on one shelf with aligned straws. Derived from Krist
|
|
79
|
+
* Wongsuphasawat's "Boba Science" notebook. Routed to the ordinal frame.
|
|
80
|
+
*/
|
|
81
|
+
export declare const bobaIR: GofishIRDocument;
|
|
82
|
+
export interface GofishIRExample {
|
|
83
|
+
key: "flower" | "bottle" | "polar" | "titanic" | "python" | "boba";
|
|
84
|
+
label: string;
|
|
85
|
+
doc: GofishIRDocument;
|
|
86
|
+
source: string;
|
|
87
|
+
}
|
|
88
|
+
/** All five examples, in gallery order. */
|
|
89
|
+
export declare const gofishIRExamples: readonly GofishIRExample[];
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { CustomLayout } from "../stream/customLayout";
|
|
2
|
+
import type { OrdinalCustomLayout } from "../stream/ordinalCustomLayout";
|
|
3
|
+
import type { GofishGlyphMark } from "./gofish";
|
|
4
|
+
import type { GofishLambda } from "./gofishLambdas";
|
|
5
|
+
import type { GofishRootIR } from "./gofishIR";
|
|
6
|
+
/**
|
|
7
|
+
* GoFish IR interpreter.
|
|
8
|
+
*
|
|
9
|
+
* Walks a `data → operators → mark` tree and *executes* the grammar —
|
|
10
|
+
* `group`/`spread`/`stack`/`scatter`/`treemap`/`layer`, the `polar`/`unit`
|
|
11
|
+
* coordinate transforms, mark channels through scales, and `connect`/`ref`/
|
|
12
|
+
* `arrow` relations — emitting positioned primitives. This is a real
|
|
13
|
+
* translator, not a recognizer: any spec built from these constructs renders.
|
|
14
|
+
*
|
|
15
|
+
* It is NOT GoFish's full constraint solver. GoFish elaborates `spread` to
|
|
16
|
+
* `layer + distribute + align` over a linear-system bbox; we implement the
|
|
17
|
+
* deterministic allocation/accumulation model the common acyclic specs reduce
|
|
18
|
+
* to. Constructs outside it (`table`, `cut`, `mask`, `over`/`inside`/`xor`,
|
|
19
|
+
* free-form `.constrain`) record a warning and fall back, never silently
|
|
20
|
+
* mis-render. The two sanctioned non-grammar paths — `derive` and `mark-fn`
|
|
21
|
+
* lambdas — resolve through the lambda registry.
|
|
22
|
+
*/
|
|
23
|
+
export interface InterpretOptions {
|
|
24
|
+
/** Per-call lambda overrides for `derive`/`mark-fn` (merged over the registry). */
|
|
25
|
+
lambdas?: Record<string, GofishLambda>;
|
|
26
|
+
/** Collected warnings for unsupported constructs / unresolved lambdas. */
|
|
27
|
+
warnings?: string[];
|
|
28
|
+
}
|
|
29
|
+
/** XY binding — the default for free-coordinate GoFish charts. */
|
|
30
|
+
export declare function interpretToXYLayout(root: GofishRootIR, options?: InterpretOptions): CustomLayout;
|
|
31
|
+
/**
|
|
32
|
+
* Ordinal binding — the top-level categorical `spread`/`group` maps to the
|
|
33
|
+
* frame's o-scale (one band per category); each category's subtree is
|
|
34
|
+
* interpreted within its full band column. A pictorial glyph that declares a
|
|
35
|
+
* `unit` coord with `fit: "uniform"` then scales aspect-correctly to fill the
|
|
36
|
+
* column (e.g. boba cups). Emits one data-bearing hit rect per category + the
|
|
37
|
+
* interpreted glyph as overlays.
|
|
38
|
+
*
|
|
39
|
+
* `config.glyphWidthRatio` (alias `cupWidthRatio`) insets the glyph column
|
|
40
|
+
* horizontally so neighboring glyphs breathe; default 0.9.
|
|
41
|
+
*/
|
|
42
|
+
export declare function interpretToOrdinalLayout(root: GofishRootIR, categoryAccessor: string, options?: InterpretOptions): OrdinalCustomLayout;
|
|
43
|
+
/** Interpret a root to raw marks (for tests / custom hosts). */
|
|
44
|
+
export declare function interpretToMarks(root: GofishRootIR, frame: {
|
|
45
|
+
x: number;
|
|
46
|
+
y: number;
|
|
47
|
+
width: number;
|
|
48
|
+
height: number;
|
|
49
|
+
}, resolveColor?: (key: string) => string, options?: InterpretOptions): {
|
|
50
|
+
marks: GofishGlyphMark[];
|
|
51
|
+
warnings: string[];
|
|
52
|
+
};
|