ggaction 0.0.1
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/CHANGELOG.md +27 -0
- package/LICENSE +21 -0
- package/README.md +108 -0
- package/package.json +84 -0
- package/src/AGENTS.md +119 -0
- package/src/ChartProgram.js +10 -0
- package/src/actions/boxPlots/components.js +88 -0
- package/src/actions/boxPlots/create.js +84 -0
- package/src/actions/boxPlots/index.js +10 -0
- package/src/actions/boxPlots/materialize.js +183 -0
- package/src/actions/boxPlots/options.js +147 -0
- package/src/actions/boxPlots/resolve.js +38 -0
- package/src/actions/canvas/actions.js +144 -0
- package/src/actions/canvas/index.js +6 -0
- package/src/actions/coordinates/actions.js +85 -0
- package/src/actions/coordinates/index.js +5 -0
- package/src/actions/data/box.js +40 -0
- package/src/actions/data/create.js +33 -0
- package/src/actions/data/density.js +62 -0
- package/src/actions/data/derived.js +52 -0
- package/src/actions/data/filter.js +168 -0
- package/src/actions/data/index.js +32 -0
- package/src/actions/data/interval.js +69 -0
- package/src/actions/data/regression.js +71 -0
- package/src/actions/data/shared.js +25 -0
- package/src/actions/encodings/appearance.js +243 -0
- package/src/actions/encodings/barWidth.js +60 -0
- package/src/actions/encodings/color.js +329 -0
- package/src/actions/encodings/density.js +225 -0
- package/src/actions/encodings/histogram.js +50 -0
- package/src/actions/encodings/index.js +23 -0
- package/src/actions/encodings/offset.js +104 -0
- package/src/actions/encodings/position/policies/area.js +24 -0
- package/src/actions/encodings/position/policies/bar.js +110 -0
- package/src/actions/encodings/position/policies/common.js +17 -0
- package/src/actions/encodings/position/policies/index.js +25 -0
- package/src/actions/encodings/position/policies/line.js +74 -0
- package/src/actions/encodings/position/policies/point.js +19 -0
- package/src/actions/encodings/position/policies/rule.js +17 -0
- package/src/actions/encodings/position/resolve.js +170 -0
- package/src/actions/encodings/position.js +176 -0
- package/src/actions/encodings/ranged.js +276 -0
- package/src/actions/encodings/ruleAppearance.js +47 -0
- package/src/actions/encodings/shared.js +164 -0
- package/src/actions/encodings/strokeDash.js +145 -0
- package/src/actions/errorBands/components.js +81 -0
- package/src/actions/errorBands/create.js +159 -0
- package/src/actions/errorBands/index.js +7 -0
- package/src/actions/errorBands/resolve.js +28 -0
- package/src/actions/errorBars/components.js +62 -0
- package/src/actions/errorBars/create.js +144 -0
- package/src/actions/errorBars/index.js +7 -0
- package/src/actions/errorBars/resolve.js +25 -0
- package/src/actions/guides/axes/axes.js +204 -0
- package/src/actions/guides/axes/axis.js +131 -0
- package/src/actions/guides/axes/index.js +17 -0
- package/src/actions/guides/axes/labels.js +231 -0
- package/src/actions/guides/axes/lines.js +149 -0
- package/src/actions/guides/axes/policy.js +155 -0
- package/src/actions/guides/axes/tickGroups.js +149 -0
- package/src/actions/guides/axes/ticks.js +179 -0
- package/src/actions/guides/axes/titles.js +264 -0
- package/src/actions/guides/grids/grid.js +228 -0
- package/src/actions/guides/grids/index.js +1 -0
- package/src/actions/guides/grids/resolve.js +258 -0
- package/src/actions/guides/guides.js +138 -0
- package/src/actions/guides/index.js +11 -0
- package/src/actions/guides/legends/categorical/actions.js +329 -0
- package/src/actions/guides/legends/categorical/components.js +140 -0
- package/src/actions/guides/legends/categorical/index.js +49 -0
- package/src/actions/guides/legends/categorical/layout.js +445 -0
- package/src/actions/guides/legends/categorical/options.js +188 -0
- package/src/actions/guides/legends/categorical/recipes.js +120 -0
- package/src/actions/guides/legends/categorical/resolve.js +131 -0
- package/src/actions/guides/legends/categorical/symbols.js +280 -0
- package/src/actions/guides/legends/categorical/validation.js +27 -0
- package/src/actions/guides/legends/continuous/common.js +273 -0
- package/src/actions/guides/legends/continuous/gradient.js +363 -0
- package/src/actions/guides/legends/continuous/index.js +25 -0
- package/src/actions/guides/legends/continuous/interval.js +234 -0
- package/src/actions/guides/legends/continuous/opacity.js +382 -0
- package/src/actions/guides/legends/edit.js +314 -0
- package/src/actions/guides/legends/index.js +9 -0
- package/src/actions/guides/legends/size.js +220 -0
- package/src/actions/guides/tickValues.js +84 -0
- package/src/actions/index.js +31 -0
- package/src/actions/intervals/resolve.js +352 -0
- package/src/actions/marks/area.js +369 -0
- package/src/actions/marks/bar/create.js +46 -0
- package/src/actions/marks/bar/edit.js +90 -0
- package/src/actions/marks/bar/index.js +9 -0
- package/src/actions/marks/bar/materialize.js +130 -0
- package/src/actions/marks/index.js +13 -0
- package/src/actions/marks/line.js +248 -0
- package/src/actions/marks/point.js +420 -0
- package/src/actions/marks/rule.js +287 -0
- package/src/actions/marks/shared.js +112 -0
- package/src/actions/primitives/createGraphics.js +163 -0
- package/src/actions/primitives/editGraphics.js +208 -0
- package/src/actions/primitives/index.js +9 -0
- package/src/actions/primitives/semantic.js +168 -0
- package/src/actions/primitives/semanticValue.js +182 -0
- package/src/actions/regression/components.js +216 -0
- package/src/actions/regression/create.js +102 -0
- package/src/actions/regression/index.js +23 -0
- package/src/actions/regression/resolve.js +57 -0
- package/src/actions/scales/consumers.js +283 -0
- package/src/actions/scales/create.js +148 -0
- package/src/actions/scales/definitions.js +319 -0
- package/src/actions/scales/edit.js +290 -0
- package/src/actions/scales/index.js +11 -0
- package/src/actions/scales/materialize.js +466 -0
- package/src/actions/scales/quantitativeColor.js +45 -0
- package/src/actions/selection/actions.js +384 -0
- package/src/actions/selection/index.js +23 -0
- package/src/actions/titles/actions.js +235 -0
- package/src/actions/titles/index.js +19 -0
- package/src/actions/titles/resolve.js +321 -0
- package/src/core/ChartProgram.js +316 -0
- package/src/core/action.js +120 -0
- package/src/core/identifiers.js +28 -0
- package/src/core/immutable.js +94 -0
- package/src/core/specs.js +29 -0
- package/src/core/textMetrics.js +23 -0
- package/src/core/validation.js +54 -0
- package/src/core/vocabulary.js +58 -0
- package/src/extension.js +2 -0
- package/src/grammar/aggregate.js +259 -0
- package/src/grammar/areaSeries.js +217 -0
- package/src/grammar/bars/aggregate.js +98 -0
- package/src/grammar/bars/geometry.js +54 -0
- package/src/grammar/bars/policy.js +90 -0
- package/src/grammar/boxPlot.js +140 -0
- package/src/grammar/coordinates.js +25 -0
- package/src/grammar/curveCommands.js +356 -0
- package/src/grammar/density.js +296 -0
- package/src/grammar/filter.js +169 -0
- package/src/grammar/histogram.js +332 -0
- package/src/grammar/interval.js +343 -0
- package/src/grammar/lineSeries.js +197 -0
- package/src/grammar/markFilter.js +46 -0
- package/src/grammar/markSelection.js +326 -0
- package/src/grammar/palettes.js +208 -0
- package/src/grammar/pathCommands.js +86 -0
- package/src/grammar/pointShapes.js +164 -0
- package/src/grammar/positionCompatibility.js +32 -0
- package/src/grammar/regression.js +578 -0
- package/src/grammar/ruleAppearance.js +12 -0
- package/src/grammar/rules.js +90 -0
- package/src/grammar/scales/appearance.js +185 -0
- package/src/grammar/scales/color.js +349 -0
- package/src/grammar/scales/continuous.js +111 -0
- package/src/grammar/scales/definition.js +153 -0
- package/src/grammar/scales/discretized.js +159 -0
- package/src/grammar/scales/fields.js +133 -0
- package/src/grammar/scales/index.js +12 -0
- package/src/grammar/scales/mapping.js +27 -0
- package/src/grammar/scales/ordinal.js +221 -0
- package/src/grammar/scales/policies.js +50 -0
- package/src/grammar/scales/temporal.js +53 -0
- package/src/grammar/scales/transformed.js +236 -0
- package/src/grammar/scales/types.js +102 -0
- package/src/grammar/scales/validation.js +66 -0
- package/src/grammar/scales.js +1 -0
- package/src/grammar/schemas/concreteGraphic.js +73 -0
- package/src/grammar/schemas/graphic.js +131 -0
- package/src/grammar/schemas/graphicBounds.js +146 -0
- package/src/grammar/schemas/graphicTree.js +133 -0
- package/src/grammar/schemas/mark.js +4 -0
- package/src/grammar/schemas/semanticPath.js +174 -0
- package/src/grammar/seriesLayout.js +76 -0
- package/src/grammar/ticks.js +149 -0
- package/src/grammar/transforms.js +37 -0
- package/src/index.js +2 -0
- package/src/layout/canvas.js +114 -0
- package/src/layout/grid.js +17 -0
- package/src/layout/legend.js +51 -0
- package/src/layout/text.js +62 -0
- package/src/layout/title.js +107 -0
- package/src/materialization/bars/aggregate.js +184 -0
- package/src/materialization/bars/grouped.js +117 -0
- package/src/materialization/bars/histogram.js +163 -0
- package/src/materialization/bars/ranged.js +53 -0
- package/src/materialization/bars/resolve.js +56 -0
- package/src/materialization/dataProvenance.js +15 -0
- package/src/materialization/density.js +29 -0
- package/src/materialization/dependencies.js +134 -0
- package/src/materialization/encodings.js +50 -0
- package/src/materialization/graphicHierarchy.js +104 -0
- package/src/materialization/legends.js +20 -0
- package/src/materialization/marks.js +110 -0
- package/src/materialization/planner.js +38 -0
- package/src/materialization/selection/filter.js +40 -0
- package/src/materialization/selection/items.js +503 -0
- package/src/materialization/selection/path.js +37 -0
- package/src/materialization/selection/point.js +118 -0
- package/src/materialization/selection/policies/area.js +10 -0
- package/src/materialization/selection/policies/bar.js +10 -0
- package/src/materialization/selection/policies/index.js +40 -0
- package/src/materialization/selection/policies/line.js +10 -0
- package/src/materialization/selection/policies/point.js +10 -0
- package/src/materialization/selection/policies/rule.js +10 -0
- package/src/materialization/selection/state.js +67 -0
- package/src/materialization/selection/styles.js +183 -0
- package/src/renderers/canvas/circle.js +62 -0
- package/src/renderers/canvas/index.js +132 -0
- package/src/renderers/canvas/line.js +54 -0
- package/src/renderers/canvas/path.js +98 -0
- package/src/renderers/canvas/rect.js +57 -0
- package/src/renderers/canvas/text.js +96 -0
- package/src/renderers/canvas/validation.js +23 -0
- package/src/renderers/png.js +29 -0
- package/src/selectors/coordinates.js +13 -0
- package/src/selectors/datasets.js +13 -0
- package/src/selectors/index.js +4 -0
- package/src/selectors/layers.js +32 -0
- package/src/selectors/scales.js +21 -0
- package/src/theme/defaults.js +13 -0
- package/types/extension.d.ts +14 -0
- package/types/index.d.ts +81 -0
- package/types/png.d.ts +14 -0
- package/types/program.d.ts +1096 -0
|
@@ -0,0 +1,1096 @@
|
|
|
1
|
+
export type FieldType = "quantitative" | "temporal" | "ordinal" | "nominal";
|
|
2
|
+
export type GraphicType =
|
|
3
|
+
| "canvas"
|
|
4
|
+
| "collection"
|
|
5
|
+
| "circle"
|
|
6
|
+
| "rect"
|
|
7
|
+
| "line"
|
|
8
|
+
| "text"
|
|
9
|
+
| "path";
|
|
10
|
+
export type ConcretePathCommand =
|
|
11
|
+
| { readonly op: "M"; readonly x: number; readonly y: number }
|
|
12
|
+
| { readonly op: "L"; readonly x: number; readonly y: number }
|
|
13
|
+
| {
|
|
14
|
+
readonly op: "C";
|
|
15
|
+
readonly x1: number;
|
|
16
|
+
readonly y1: number;
|
|
17
|
+
readonly x2: number;
|
|
18
|
+
readonly y2: number;
|
|
19
|
+
readonly x: number;
|
|
20
|
+
readonly y: number;
|
|
21
|
+
}
|
|
22
|
+
| { readonly op: "Z" };
|
|
23
|
+
export type CurveInterpolation =
|
|
24
|
+
| "linear"
|
|
25
|
+
| "step"
|
|
26
|
+
| "step-before"
|
|
27
|
+
| "step-after"
|
|
28
|
+
| "basis"
|
|
29
|
+
| "cardinal"
|
|
30
|
+
| "monotone"
|
|
31
|
+
| "natural";
|
|
32
|
+
export type DashStyle = "solid" | "dashed" | "dotted" | "dashdot";
|
|
33
|
+
export type DashPattern = readonly number[];
|
|
34
|
+
export type ScaleType =
|
|
35
|
+
| "linear"
|
|
36
|
+
| "log"
|
|
37
|
+
| "pow"
|
|
38
|
+
| "sqrt"
|
|
39
|
+
| "symlog"
|
|
40
|
+
| "time"
|
|
41
|
+
| "band"
|
|
42
|
+
| "point"
|
|
43
|
+
| "ordinal"
|
|
44
|
+
| "sequential"
|
|
45
|
+
| "quantize"
|
|
46
|
+
| "quantile"
|
|
47
|
+
| "threshold";
|
|
48
|
+
export type StackMode = "zero" | "normalize" | null;
|
|
49
|
+
export type DensityKernel =
|
|
50
|
+
| "gaussian"
|
|
51
|
+
| "epanechnikov"
|
|
52
|
+
| "uniform"
|
|
53
|
+
| "triangular";
|
|
54
|
+
export type DensityNormalization = "unit" | "count";
|
|
55
|
+
export type FilterComparison =
|
|
56
|
+
| { op: "eq" | "neq"; value: unknown }
|
|
57
|
+
| { op: "lt" | "lte" | "gt" | "gte"; value: number | string };
|
|
58
|
+
export type FilterRange = {
|
|
59
|
+
min: number | string;
|
|
60
|
+
max: number | string;
|
|
61
|
+
inclusive?: boolean;
|
|
62
|
+
};
|
|
63
|
+
export type FilterModeOptions =
|
|
64
|
+
| { oneOf: readonly unknown[]; predicate?: never; range?: never }
|
|
65
|
+
| { oneOf?: never; predicate: FilterComparison; range?: never }
|
|
66
|
+
| { oneOf?: never; predicate?: never; range: FilterRange };
|
|
67
|
+
export type FilterDataOptions = {
|
|
68
|
+
id: string;
|
|
69
|
+
source?: string;
|
|
70
|
+
field: string;
|
|
71
|
+
} & FilterModeOptions;
|
|
72
|
+
export type MarkGraphicProperty =
|
|
73
|
+
| "x" | "y" | "width" | "height" | "radius"
|
|
74
|
+
| "x1" | "y1" | "x2" | "y2"
|
|
75
|
+
| "fill" | "stroke" | "strokeWidth" | "opacity";
|
|
76
|
+
export type MarkSelector = {
|
|
77
|
+
grain?: "item" | "stack";
|
|
78
|
+
} & (
|
|
79
|
+
| { field: string; channel?: never; property?: never }
|
|
80
|
+
| { channel: "x" | "y" | "x2" | "y2" | "xOffset" | "theta" | "radius" | "color" | "strokeDash" | "size" | "shape" | "group" | "opacity"; field?: never; property?: never }
|
|
81
|
+
| { property: MarkGraphicProperty; field?: never; channel?: never }
|
|
82
|
+
) & (
|
|
83
|
+
| { op: "eq" | "neq" | "gt" | "gte" | "lt" | "lte"; value: unknown }
|
|
84
|
+
| { op: "oneOf"; values: readonly unknown[] }
|
|
85
|
+
| {
|
|
86
|
+
op: "range";
|
|
87
|
+
min: number | string;
|
|
88
|
+
max: number | string;
|
|
89
|
+
inclusive?: boolean;
|
|
90
|
+
}
|
|
91
|
+
| {
|
|
92
|
+
op: "min" | "max";
|
|
93
|
+
count?: number;
|
|
94
|
+
groupBy?: string | readonly string[];
|
|
95
|
+
ties?: "first" | "all";
|
|
96
|
+
}
|
|
97
|
+
);
|
|
98
|
+
export type SelectMarksOptions = {
|
|
99
|
+
id?: string;
|
|
100
|
+
target?: string;
|
|
101
|
+
} & MarkSelector;
|
|
102
|
+
export type FilterMarksOptions = {
|
|
103
|
+
target?: string;
|
|
104
|
+
} & MarkSelector;
|
|
105
|
+
export interface HighlightMarksOptions {
|
|
106
|
+
id?: string;
|
|
107
|
+
target?: string;
|
|
108
|
+
select?: MarkSelector;
|
|
109
|
+
selection?: string;
|
|
110
|
+
color?: string;
|
|
111
|
+
opacity?: number;
|
|
112
|
+
fill?: string;
|
|
113
|
+
stroke?: string;
|
|
114
|
+
strokeWidth?: number;
|
|
115
|
+
strokeDash?: DashStyle | DashPattern;
|
|
116
|
+
shape?: PointShape;
|
|
117
|
+
size?: number;
|
|
118
|
+
offset?: { x?: number; y?: number };
|
|
119
|
+
dimOthers?: boolean | { opacity?: number };
|
|
120
|
+
bringToFront?: boolean;
|
|
121
|
+
}
|
|
122
|
+
export type ColorLayout =
|
|
123
|
+
| "stack"
|
|
124
|
+
| "fill"
|
|
125
|
+
| "group"
|
|
126
|
+
| "overlay"
|
|
127
|
+
| "diverging";
|
|
128
|
+
export type ScalarAggregateOperation =
|
|
129
|
+
| "count" | "sum" | "mean" | "median" | "min" | "max"
|
|
130
|
+
| "distinct" | "valid" | "missing"
|
|
131
|
+
| "variance" | "varianceP" | "stdev" | "stdevP" | "stderr"
|
|
132
|
+
| "q1" | "q3" | "ciLower" | "ciUpper";
|
|
133
|
+
export type ParameterizedAggregateOperation =
|
|
134
|
+
| { op: "quantile"; probability: number }
|
|
135
|
+
| {
|
|
136
|
+
op: "first" | "last";
|
|
137
|
+
orderBy: string;
|
|
138
|
+
order?: "ascending" | "descending";
|
|
139
|
+
};
|
|
140
|
+
export type AggregateOperation =
|
|
141
|
+
| ScalarAggregateOperation
|
|
142
|
+
| ParameterizedAggregateOperation;
|
|
143
|
+
export type ContinuousColorInterpolation =
|
|
144
|
+
| "rgb"
|
|
145
|
+
| "hsl"
|
|
146
|
+
| "hsl-long"
|
|
147
|
+
| "lab"
|
|
148
|
+
| "hcl"
|
|
149
|
+
| "hcl-long"
|
|
150
|
+
| "cubehelix"
|
|
151
|
+
| "cubehelix-long";
|
|
152
|
+
export type PointShape =
|
|
153
|
+
| "circle"
|
|
154
|
+
| "square"
|
|
155
|
+
| "diamond"
|
|
156
|
+
| "triangle-up"
|
|
157
|
+
| "triangle-down"
|
|
158
|
+
| "triangle-left"
|
|
159
|
+
| "triangle-right"
|
|
160
|
+
| "plus"
|
|
161
|
+
| "cross"
|
|
162
|
+
| "star"
|
|
163
|
+
| "hexagon"
|
|
164
|
+
| "wye";
|
|
165
|
+
export type PaletteName =
|
|
166
|
+
| "accent"
|
|
167
|
+
| "category10" | "category20" | "category20b" | "category20c"
|
|
168
|
+
| "observable10"
|
|
169
|
+
| "dark2" | "paired" | "pastel1" | "pastel2"
|
|
170
|
+
| "set1" | "set2" | "set3"
|
|
171
|
+
| "tableau10" | "tableau20"
|
|
172
|
+
| "blues" | "tealblues" | "teals" | "greens" | "browns"
|
|
173
|
+
| "oranges" | "reds" | "purples" | "warmgreys" | "greys"
|
|
174
|
+
| "viridis" | "magma" | "inferno" | "plasma" | "cividis" | "turbo"
|
|
175
|
+
| "bluegreen" | "bluepurple"
|
|
176
|
+
| "goldgreen" | "goldorange" | "goldred"
|
|
177
|
+
| "greenblue" | "orangered"
|
|
178
|
+
| "purplebluegreen" | "purpleblue" | "purplered" | "redpurple"
|
|
179
|
+
| "yellowgreenblue" | "yellowgreen" | "yelloworangebrown" | "yelloworangered"
|
|
180
|
+
| "darkblue" | "darkgold" | "darkgreen" | "darkmulti" | "darkred"
|
|
181
|
+
| "lightgreyred" | "lightgreyteal" | "lightmulti" | "lightorange" | "lighttealblue"
|
|
182
|
+
| "blueorange" | "brownbluegreen" | "purplegreen" | "pinkyellowgreen"
|
|
183
|
+
| "purpleorange" | "redblue" | "redgrey"
|
|
184
|
+
| "redyellowblue" | "redyellowgreen" | "spectral"
|
|
185
|
+
| "rainbow" | "sinebow";
|
|
186
|
+
export type Palette = PaletteName | {
|
|
187
|
+
name: PaletteName;
|
|
188
|
+
count?: number;
|
|
189
|
+
extent?: readonly [number, number];
|
|
190
|
+
};
|
|
191
|
+
export type ScaleRange = "auto" | readonly unknown[] | {
|
|
192
|
+
readonly palette: Palette;
|
|
193
|
+
};
|
|
194
|
+
export type ActionOptions = Record<string, unknown>;
|
|
195
|
+
export type EditSemanticOptions =
|
|
196
|
+
| { property: string; value: unknown; remove?: false }
|
|
197
|
+
| { property: string; remove: true; value?: never };
|
|
198
|
+
export type EditGraphicsOptions =
|
|
199
|
+
| { target: string; property: string; value: unknown; remove?: false }
|
|
200
|
+
| { target: string; remove: true; property?: never; value?: never };
|
|
201
|
+
|
|
202
|
+
export interface TraceNode {
|
|
203
|
+
readonly id: string;
|
|
204
|
+
readonly op: string;
|
|
205
|
+
readonly description: string;
|
|
206
|
+
readonly args: Readonly<Record<string, unknown>>;
|
|
207
|
+
readonly children: readonly TraceNode[];
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export interface SemanticSpec {
|
|
211
|
+
readonly datasets: readonly Readonly<Record<string, unknown>>[];
|
|
212
|
+
readonly layers: readonly Readonly<Record<string, unknown>>[];
|
|
213
|
+
readonly scales: readonly Readonly<Record<string, unknown>>[];
|
|
214
|
+
readonly coordinates: readonly Readonly<Record<string, unknown>>[];
|
|
215
|
+
readonly guides: Readonly<Record<string, unknown>>;
|
|
216
|
+
readonly title: Readonly<Record<string, unknown>>;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export interface GraphicItem {
|
|
220
|
+
readonly id: string;
|
|
221
|
+
readonly type?: Exclude<GraphicType, "canvas" | "collection">;
|
|
222
|
+
readonly properties: Readonly<Record<string, unknown>>;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export interface GraphicObject {
|
|
226
|
+
readonly type: GraphicType;
|
|
227
|
+
readonly properties?: Readonly<Record<string, unknown>>;
|
|
228
|
+
readonly items?: readonly GraphicItem[];
|
|
229
|
+
readonly children?: readonly string[];
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export interface GraphicSpec {
|
|
233
|
+
readonly objects: Readonly<Record<string, GraphicObject>>;
|
|
234
|
+
readonly order: readonly string[];
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export interface CanvasOptions {
|
|
238
|
+
width?: number;
|
|
239
|
+
height?: number;
|
|
240
|
+
background?: string;
|
|
241
|
+
margin?: number | Partial<Record<"top" | "right" | "bottom" | "left", number>>;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export type XAxisPosition = "bottom" | "top";
|
|
245
|
+
export type YAxisPosition = "left" | "right";
|
|
246
|
+
export type AxisFormatString =
|
|
247
|
+
| ".0f" | ".1f" | ".2f"
|
|
248
|
+
| ".0%" | ".1%" | ".2e"
|
|
249
|
+
| "%Y" | "%Y-%m" | "%Y-%m-%d";
|
|
250
|
+
export type AxisFormat =
|
|
251
|
+
| "auto"
|
|
252
|
+
| AxisFormatString
|
|
253
|
+
| { decimals: number };
|
|
254
|
+
export type AxisValue = string | boolean | number;
|
|
255
|
+
export interface AxisLineStyleOptions {
|
|
256
|
+
color?: string;
|
|
257
|
+
lineWidth?: number;
|
|
258
|
+
}
|
|
259
|
+
export interface AxisTickStyleOptions extends AxisLineStyleOptions {
|
|
260
|
+
length?: number;
|
|
261
|
+
}
|
|
262
|
+
export interface AxisLabelStyleOptions {
|
|
263
|
+
offset?: number;
|
|
264
|
+
format?: AxisFormat;
|
|
265
|
+
color?: string;
|
|
266
|
+
fontSize?: number;
|
|
267
|
+
fontFamily?: string;
|
|
268
|
+
fontWeight?: string | number;
|
|
269
|
+
}
|
|
270
|
+
export interface AxisTicksAndLabelsOptions<P extends string> {
|
|
271
|
+
scale?: string;
|
|
272
|
+
position?: P;
|
|
273
|
+
count?: number;
|
|
274
|
+
values?: readonly AxisValue[];
|
|
275
|
+
ticks?: AxisTickStyleOptions;
|
|
276
|
+
labels?: AxisLabelStyleOptions;
|
|
277
|
+
}
|
|
278
|
+
export interface AxisTitleOptions<P extends string> {
|
|
279
|
+
text?: string;
|
|
280
|
+
scale?: string;
|
|
281
|
+
position?: P;
|
|
282
|
+
at?: "start" | "center" | "end" | number;
|
|
283
|
+
offset?: number;
|
|
284
|
+
rotation?: number;
|
|
285
|
+
color?: string;
|
|
286
|
+
fontSize?: number;
|
|
287
|
+
fontFamily?: string;
|
|
288
|
+
fontWeight?: string | number;
|
|
289
|
+
}
|
|
290
|
+
export interface CompleteAxisOptions<P extends string> {
|
|
291
|
+
scale?: string;
|
|
292
|
+
coordinate?: string;
|
|
293
|
+
position?: P;
|
|
294
|
+
line?: AxisLineStyleOptions;
|
|
295
|
+
ticksAndLabels?: Omit<AxisTicksAndLabelsOptions<P>, "scale" | "position">;
|
|
296
|
+
title?: Omit<AxisTitleOptions<P>, "scale" | "position">;
|
|
297
|
+
}
|
|
298
|
+
export interface CreateAxesOptions {
|
|
299
|
+
coordinate?: {
|
|
300
|
+
id?: string;
|
|
301
|
+
type?: "auto" | "cartesian" | "polar";
|
|
302
|
+
};
|
|
303
|
+
x?: false | CompleteAxisOptions<XAxisPosition>;
|
|
304
|
+
y?: false | CompleteAxisOptions<YAxisPosition>;
|
|
305
|
+
}
|
|
306
|
+
export interface AxisTickOptions<P extends string>
|
|
307
|
+
extends AxisTickStyleOptions {
|
|
308
|
+
scale?: string;
|
|
309
|
+
position?: P;
|
|
310
|
+
count?: number;
|
|
311
|
+
values?: readonly AxisValue[];
|
|
312
|
+
}
|
|
313
|
+
export interface AxisLabelOptions<P extends string>
|
|
314
|
+
extends AxisLabelStyleOptions {
|
|
315
|
+
scale?: string;
|
|
316
|
+
position?: P;
|
|
317
|
+
count?: number;
|
|
318
|
+
values?: readonly AxisValue[];
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
export interface GridDirectionOptions {
|
|
322
|
+
scale?: string;
|
|
323
|
+
coordinate?: string;
|
|
324
|
+
count?: number;
|
|
325
|
+
values?: readonly number[];
|
|
326
|
+
color?: string;
|
|
327
|
+
lineWidth?: number;
|
|
328
|
+
strokeDash?: readonly number[];
|
|
329
|
+
}
|
|
330
|
+
export interface EditGridOptions {
|
|
331
|
+
count?: number;
|
|
332
|
+
values?: readonly number[] | "auto";
|
|
333
|
+
color?: string;
|
|
334
|
+
lineWidth?: number;
|
|
335
|
+
strokeDash?: readonly number[];
|
|
336
|
+
}
|
|
337
|
+
export interface CreateGridOptions {
|
|
338
|
+
horizontal?: boolean | GridDirectionOptions;
|
|
339
|
+
vertical?: boolean | GridDirectionOptions;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
export interface ScaleOptions {
|
|
343
|
+
id?: string;
|
|
344
|
+
type?: ScaleType;
|
|
345
|
+
domain?: "auto" | readonly unknown[];
|
|
346
|
+
range?: ScaleRange;
|
|
347
|
+
nice?: boolean;
|
|
348
|
+
zero?: boolean;
|
|
349
|
+
clamp?: boolean;
|
|
350
|
+
reverse?: boolean;
|
|
351
|
+
base?: number;
|
|
352
|
+
exponent?: number;
|
|
353
|
+
constant?: number;
|
|
354
|
+
paddingInner?: number;
|
|
355
|
+
paddingOuter?: number;
|
|
356
|
+
padding?: number;
|
|
357
|
+
align?: number;
|
|
358
|
+
palette?: Palette;
|
|
359
|
+
interpolate?: ContinuousColorInterpolation;
|
|
360
|
+
unknown?: unknown;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
export interface EditScaleOptions {
|
|
364
|
+
id?: string;
|
|
365
|
+
type?: ScaleType;
|
|
366
|
+
domain?: "auto" | readonly unknown[];
|
|
367
|
+
range?: ScaleRange;
|
|
368
|
+
nice?: boolean;
|
|
369
|
+
zero?: boolean;
|
|
370
|
+
clamp?: boolean;
|
|
371
|
+
reverse?: boolean;
|
|
372
|
+
base?: number;
|
|
373
|
+
exponent?: number;
|
|
374
|
+
constant?: number;
|
|
375
|
+
paddingInner?: number;
|
|
376
|
+
paddingOuter?: number;
|
|
377
|
+
padding?: number;
|
|
378
|
+
align?: number;
|
|
379
|
+
interpolate?: ContinuousColorInterpolation;
|
|
380
|
+
unknown?: unknown;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
export interface PositionEncodingOptions {
|
|
384
|
+
field: string;
|
|
385
|
+
target?: string;
|
|
386
|
+
fieldType?: FieldType;
|
|
387
|
+
scale?: ScaleOptions;
|
|
388
|
+
coordinate?: string;
|
|
389
|
+
aggregate?: AggregateOperation;
|
|
390
|
+
bin?:
|
|
391
|
+
| { maxBins?: number; step?: never; boundaries?: never }
|
|
392
|
+
| { maxBins?: never; step: number; boundaries?: never }
|
|
393
|
+
| {
|
|
394
|
+
maxBins?: never;
|
|
395
|
+
step?: never;
|
|
396
|
+
boundaries: readonly [number, number, ...number[]];
|
|
397
|
+
};
|
|
398
|
+
stack?: StackMode;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
type RulePositionValue =
|
|
402
|
+
| { field: string; datum?: never }
|
|
403
|
+
| { field?: never; datum: unknown };
|
|
404
|
+
|
|
405
|
+
export type RulePositionEncodingOptions = RulePositionValue & {
|
|
406
|
+
target?: string;
|
|
407
|
+
fieldType: FieldType;
|
|
408
|
+
scale?: ScaleOptions;
|
|
409
|
+
coordinate?: string;
|
|
410
|
+
};
|
|
411
|
+
|
|
412
|
+
export type SecondaryPositionEncodingOptions =
|
|
413
|
+
| RulePositionEncodingOptions
|
|
414
|
+
| {
|
|
415
|
+
field: string;
|
|
416
|
+
datum?: never;
|
|
417
|
+
target?: string;
|
|
418
|
+
fieldType?: "quantitative";
|
|
419
|
+
scale?: { id?: string };
|
|
420
|
+
coordinate?: string;
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
export type HistogramEncodingOptions = {
|
|
424
|
+
field: string;
|
|
425
|
+
target?: string;
|
|
426
|
+
coordinate?: string;
|
|
427
|
+
stack?: StackMode;
|
|
428
|
+
xScale?: ScaleOptions;
|
|
429
|
+
yScale?: ScaleOptions;
|
|
430
|
+
} & (
|
|
431
|
+
| { maxBins?: number; binStep?: never; binBoundaries?: never }
|
|
432
|
+
| { maxBins?: never; binStep: number; binBoundaries?: never }
|
|
433
|
+
| {
|
|
434
|
+
maxBins?: never;
|
|
435
|
+
binStep?: never;
|
|
436
|
+
binBoundaries: readonly [number, number, ...number[]];
|
|
437
|
+
}
|
|
438
|
+
);
|
|
439
|
+
|
|
440
|
+
export interface CategoricalEncodingOptions {
|
|
441
|
+
field: string;
|
|
442
|
+
target?: string;
|
|
443
|
+
fieldType?: "nominal";
|
|
444
|
+
scale?: ScaleOptions;
|
|
445
|
+
layout?: ColorLayout;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
export interface DensityDataOptions {
|
|
449
|
+
id: string;
|
|
450
|
+
source?: string;
|
|
451
|
+
field: string;
|
|
452
|
+
groupBy?: string;
|
|
453
|
+
bandwidth?: "auto" | number;
|
|
454
|
+
extent?: "auto" | readonly [number, number];
|
|
455
|
+
steps?: number;
|
|
456
|
+
kernel?: DensityKernel;
|
|
457
|
+
normalization?: DensityNormalization;
|
|
458
|
+
as?: readonly [string, string];
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
export interface DensityEncodingOptions
|
|
462
|
+
extends Omit<DensityDataOptions, "id"> {
|
|
463
|
+
target?: string;
|
|
464
|
+
densityChannel?: "x" | "y";
|
|
465
|
+
coordinate?: string;
|
|
466
|
+
valueScale?: ScaleOptions;
|
|
467
|
+
densityScale?: ScaleOptions;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
export type IntervalCenter = "mean" | "median";
|
|
471
|
+
export type IntervalExtent = "stderr" | "stdev" | "ci" | "iqr";
|
|
472
|
+
|
|
473
|
+
export interface IntervalOutputFields {
|
|
474
|
+
center: string;
|
|
475
|
+
lower: string;
|
|
476
|
+
upper: string;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
export interface IntervalDataOptions {
|
|
480
|
+
id: string;
|
|
481
|
+
source?: string;
|
|
482
|
+
field: string;
|
|
483
|
+
groupBy?: string | readonly string[];
|
|
484
|
+
center?: IntervalCenter;
|
|
485
|
+
extent?: IntervalExtent;
|
|
486
|
+
level?: number;
|
|
487
|
+
as?: IntervalOutputFields;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
export interface ErrorBarPositionChannel {
|
|
491
|
+
field?: string;
|
|
492
|
+
fieldType?: "nominal" | "ordinal" | "temporal";
|
|
493
|
+
scale?: ScaleOptions;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
export interface ErrorBarStatisticalIntervalChannel {
|
|
497
|
+
field?: string;
|
|
498
|
+
center?: IntervalCenter;
|
|
499
|
+
extent?: IntervalExtent;
|
|
500
|
+
level?: number;
|
|
501
|
+
scale?: ScaleOptions;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
export interface ErrorBarExplicitIntervalChannel {
|
|
505
|
+
center: string;
|
|
506
|
+
lower: string;
|
|
507
|
+
upper: string;
|
|
508
|
+
scale?: ScaleOptions;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
export type ErrorBarIntervalChannel =
|
|
512
|
+
| ErrorBarStatisticalIntervalChannel
|
|
513
|
+
| ErrorBarExplicitIntervalChannel;
|
|
514
|
+
|
|
515
|
+
export interface ErrorBarOptions {
|
|
516
|
+
id?: string;
|
|
517
|
+
target?: string;
|
|
518
|
+
data?: string;
|
|
519
|
+
x?: ErrorBarPositionChannel | ErrorBarIntervalChannel;
|
|
520
|
+
y?: ErrorBarPositionChannel | ErrorBarIntervalChannel;
|
|
521
|
+
groupBy?: string;
|
|
522
|
+
coordinate?: string;
|
|
523
|
+
caps?: boolean;
|
|
524
|
+
capSize?: number;
|
|
525
|
+
stroke?: string;
|
|
526
|
+
strokeWidth?: number;
|
|
527
|
+
strokeDash?: DashStyle | DashPattern;
|
|
528
|
+
opacity?: number;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
export interface BoxPlotCategoryChannel {
|
|
532
|
+
field: string;
|
|
533
|
+
fieldType: "nominal" | "ordinal" | "temporal";
|
|
534
|
+
scale?: ScaleOptions;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
export interface BoxPlotMeasureChannel {
|
|
538
|
+
field: string;
|
|
539
|
+
fieldType?: "quantitative";
|
|
540
|
+
scale?: ScaleOptions;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
export type BoxPlotPositionChannel =
|
|
544
|
+
| BoxPlotCategoryChannel
|
|
545
|
+
| BoxPlotMeasureChannel;
|
|
546
|
+
|
|
547
|
+
export type BoxPlotWhisker =
|
|
548
|
+
| { type?: "tukey"; factor?: number }
|
|
549
|
+
| { type: "minmax"; factor?: never };
|
|
550
|
+
|
|
551
|
+
export interface BoxPlotOptions {
|
|
552
|
+
id?: string;
|
|
553
|
+
target?: string;
|
|
554
|
+
data?: string;
|
|
555
|
+
x?: BoxPlotPositionChannel;
|
|
556
|
+
y?: BoxPlotPositionChannel;
|
|
557
|
+
coordinate?: string;
|
|
558
|
+
whisker?: BoxPlotWhisker;
|
|
559
|
+
width?: { band?: number };
|
|
560
|
+
outliers?: boolean;
|
|
561
|
+
box?: {
|
|
562
|
+
fill?: string;
|
|
563
|
+
opacity?: number;
|
|
564
|
+
stroke?: string;
|
|
565
|
+
strokeWidth?: number;
|
|
566
|
+
};
|
|
567
|
+
median?: {
|
|
568
|
+
stroke?: string;
|
|
569
|
+
strokeWidth?: number;
|
|
570
|
+
};
|
|
571
|
+
outlier?: {
|
|
572
|
+
shape?: PointShape;
|
|
573
|
+
radius?: number;
|
|
574
|
+
opacity?: number;
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
export interface ErrorBandPositionChannel {
|
|
579
|
+
field?: string;
|
|
580
|
+
fieldType?: "quantitative" | "temporal";
|
|
581
|
+
scale?: ScaleOptions;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
export interface ErrorBandStatisticalIntervalChannel {
|
|
585
|
+
field?: string;
|
|
586
|
+
center?: IntervalCenter;
|
|
587
|
+
extent?: IntervalExtent;
|
|
588
|
+
level?: number;
|
|
589
|
+
scale?: ScaleOptions;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
export interface ErrorBandExplicitIntervalChannel {
|
|
593
|
+
center: string;
|
|
594
|
+
lower: string;
|
|
595
|
+
upper: string;
|
|
596
|
+
scale?: ScaleOptions;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
export type ErrorBandIntervalChannel =
|
|
600
|
+
| ErrorBandStatisticalIntervalChannel
|
|
601
|
+
| ErrorBandExplicitIntervalChannel;
|
|
602
|
+
|
|
603
|
+
export interface ErrorBandOptions {
|
|
604
|
+
id?: string;
|
|
605
|
+
target?: string;
|
|
606
|
+
data?: string;
|
|
607
|
+
x?: ErrorBandPositionChannel | ErrorBandIntervalChannel;
|
|
608
|
+
y?: ErrorBandPositionChannel | ErrorBandIntervalChannel;
|
|
609
|
+
groupBy?: string;
|
|
610
|
+
coordinate?: string;
|
|
611
|
+
fill?: string;
|
|
612
|
+
opacity?: number;
|
|
613
|
+
curve?: CurveInterpolation;
|
|
614
|
+
boundaries?: false | {
|
|
615
|
+
stroke?: string;
|
|
616
|
+
strokeWidth?: number;
|
|
617
|
+
strokeDash?: DashStyle | DashPattern;
|
|
618
|
+
opacity?: number;
|
|
619
|
+
curve?: CurveInterpolation;
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
export interface EditDensityOptions {
|
|
624
|
+
target?: string;
|
|
625
|
+
bandwidth?: "auto" | number;
|
|
626
|
+
extent?: "auto" | readonly [number, number];
|
|
627
|
+
steps?: number;
|
|
628
|
+
kernel?: DensityKernel;
|
|
629
|
+
normalization?: DensityNormalization;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
export interface OffsetScaleOptions {
|
|
633
|
+
id?: string;
|
|
634
|
+
type?: "ordinal";
|
|
635
|
+
domain?: "auto" | readonly unknown[];
|
|
636
|
+
range?: "auto" | readonly [number, number];
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
export interface XOffsetEncodingOptions {
|
|
640
|
+
field: string;
|
|
641
|
+
target?: string;
|
|
642
|
+
fieldType?: "nominal";
|
|
643
|
+
scale?: OffsetScaleOptions;
|
|
644
|
+
paddingInner?: number;
|
|
645
|
+
paddingOuter?: number;
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
export type BarWidthOptions = { target?: string } & (
|
|
649
|
+
| { band?: number; pixels?: never }
|
|
650
|
+
| { band?: never; pixels: number }
|
|
651
|
+
);
|
|
652
|
+
|
|
653
|
+
export interface DashScaleOptions {
|
|
654
|
+
id?: string;
|
|
655
|
+
type?: "ordinal";
|
|
656
|
+
domain?: "auto" | readonly unknown[];
|
|
657
|
+
range?: "auto" | readonly (DashStyle | DashPattern)[];
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
export type StrokeDashEncodingOptions =
|
|
661
|
+
| {
|
|
662
|
+
field: string;
|
|
663
|
+
value?: never;
|
|
664
|
+
target?: string;
|
|
665
|
+
fieldType?: "nominal";
|
|
666
|
+
scale?: DashScaleOptions;
|
|
667
|
+
}
|
|
668
|
+
| {
|
|
669
|
+
value: DashStyle | DashPattern;
|
|
670
|
+
field?: never;
|
|
671
|
+
target?: string;
|
|
672
|
+
fieldType?: never;
|
|
673
|
+
scale?: never;
|
|
674
|
+
};
|
|
675
|
+
|
|
676
|
+
export interface ContinuousColorScaleOptions {
|
|
677
|
+
id?: string;
|
|
678
|
+
type?: "sequential";
|
|
679
|
+
domain?: "auto" | readonly [unknown, unknown];
|
|
680
|
+
range?: "auto" | readonly [string, string, ...string[]];
|
|
681
|
+
palette?: PaletteName | {
|
|
682
|
+
name: PaletteName;
|
|
683
|
+
extent?: readonly [number, number];
|
|
684
|
+
};
|
|
685
|
+
interpolate?: ContinuousColorInterpolation;
|
|
686
|
+
clamp?: boolean;
|
|
687
|
+
reverse?: boolean;
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
export type DiscretizedColorScaleOptions =
|
|
691
|
+
| {
|
|
692
|
+
id?: string;
|
|
693
|
+
type: "quantize";
|
|
694
|
+
domain?: "auto" | readonly [number, number];
|
|
695
|
+
range?: "auto" | readonly [string, string, ...string[]];
|
|
696
|
+
palette?: PaletteName | { name: PaletteName; count?: number };
|
|
697
|
+
clamp?: boolean;
|
|
698
|
+
reverse?: boolean;
|
|
699
|
+
}
|
|
700
|
+
| {
|
|
701
|
+
id?: string;
|
|
702
|
+
type: "quantile";
|
|
703
|
+
domain?: "auto" | readonly number[];
|
|
704
|
+
range?: "auto" | readonly [string, string, ...string[]];
|
|
705
|
+
palette?: PaletteName | { name: PaletteName; count?: number };
|
|
706
|
+
reverse?: boolean;
|
|
707
|
+
}
|
|
708
|
+
| {
|
|
709
|
+
id?: string;
|
|
710
|
+
type: "threshold";
|
|
711
|
+
domain: readonly number[];
|
|
712
|
+
range?: "auto" | readonly [string, string, ...string[]];
|
|
713
|
+
palette?: PaletteName | { name: PaletteName; count?: number };
|
|
714
|
+
reverse?: boolean;
|
|
715
|
+
};
|
|
716
|
+
|
|
717
|
+
export type ColorEncodingOptions =
|
|
718
|
+
| CategoricalEncodingOptions
|
|
719
|
+
| {
|
|
720
|
+
field: string;
|
|
721
|
+
target?: string;
|
|
722
|
+
fieldType: "quantitative";
|
|
723
|
+
aggregate?: AggregateOperation;
|
|
724
|
+
scale?: ContinuousColorScaleOptions | DiscretizedColorScaleOptions;
|
|
725
|
+
layout?: never;
|
|
726
|
+
}
|
|
727
|
+
| {
|
|
728
|
+
field: string;
|
|
729
|
+
target?: string;
|
|
730
|
+
fieldType: "temporal";
|
|
731
|
+
aggregate?: never;
|
|
732
|
+
scale?: ContinuousColorScaleOptions;
|
|
733
|
+
layout?: never;
|
|
734
|
+
};
|
|
735
|
+
|
|
736
|
+
export interface OpacityScaleOptions {
|
|
737
|
+
id?: string;
|
|
738
|
+
type?: "linear";
|
|
739
|
+
domain?: "auto" | readonly [number, number];
|
|
740
|
+
range?: "auto" | readonly [number, number];
|
|
741
|
+
nice?: boolean;
|
|
742
|
+
zero?: boolean;
|
|
743
|
+
clamp?: boolean;
|
|
744
|
+
reverse?: boolean;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
export type OpacityEncodingOptions =
|
|
748
|
+
| { value: number; field?: never; target?: string }
|
|
749
|
+
| {
|
|
750
|
+
field: string;
|
|
751
|
+
value?: never;
|
|
752
|
+
target?: string;
|
|
753
|
+
fieldType?: "quantitative";
|
|
754
|
+
scale?: OpacityScaleOptions;
|
|
755
|
+
};
|
|
756
|
+
|
|
757
|
+
export type RegressionMethod = "linear" | "polynomial" | "loess";
|
|
758
|
+
export type RegressionInterval = "mean" | "prediction";
|
|
759
|
+
|
|
760
|
+
export interface RegressionBandOptions {
|
|
761
|
+
color?: string;
|
|
762
|
+
opacity?: number;
|
|
763
|
+
stroke?: string;
|
|
764
|
+
strokeWidth?: number;
|
|
765
|
+
curve?: CurveInterpolation;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
type RegressionParameterOptions =
|
|
769
|
+
| {
|
|
770
|
+
method?: "linear";
|
|
771
|
+
degree?: never;
|
|
772
|
+
span?: never;
|
|
773
|
+
confidence?: number;
|
|
774
|
+
interval?: RegressionInterval;
|
|
775
|
+
}
|
|
776
|
+
| {
|
|
777
|
+
method: "polynomial";
|
|
778
|
+
degree?: number;
|
|
779
|
+
span?: never;
|
|
780
|
+
confidence?: number;
|
|
781
|
+
interval?: RegressionInterval;
|
|
782
|
+
}
|
|
783
|
+
| {
|
|
784
|
+
method: "loess";
|
|
785
|
+
degree?: never;
|
|
786
|
+
span?: number;
|
|
787
|
+
confidence?: never;
|
|
788
|
+
interval?: never;
|
|
789
|
+
};
|
|
790
|
+
|
|
791
|
+
export type RegressionDataOptions = {
|
|
792
|
+
id: string;
|
|
793
|
+
source?: string;
|
|
794
|
+
x: string;
|
|
795
|
+
y: string;
|
|
796
|
+
groupBy?: string;
|
|
797
|
+
} & RegressionParameterOptions;
|
|
798
|
+
|
|
799
|
+
type RegressionCommonOptions = {
|
|
800
|
+
target?: string;
|
|
801
|
+
x?: string;
|
|
802
|
+
y?: string;
|
|
803
|
+
groupBy?: string;
|
|
804
|
+
line?: { strokeWidth?: number; curve?: CurveInterpolation };
|
|
805
|
+
};
|
|
806
|
+
|
|
807
|
+
export type RegressionOptions = RegressionCommonOptions & (
|
|
808
|
+
| (Extract<RegressionParameterOptions, { method?: "linear" }> & {
|
|
809
|
+
band?: false | RegressionBandOptions;
|
|
810
|
+
})
|
|
811
|
+
| (Extract<RegressionParameterOptions, { method: "polynomial" }> & {
|
|
812
|
+
band?: false | RegressionBandOptions;
|
|
813
|
+
})
|
|
814
|
+
| (Extract<RegressionParameterOptions, { method: "loess" }> & {
|
|
815
|
+
band?: false;
|
|
816
|
+
})
|
|
817
|
+
);
|
|
818
|
+
|
|
819
|
+
export interface LegendTextOptions {
|
|
820
|
+
offset?: number;
|
|
821
|
+
color?: string;
|
|
822
|
+
fontSize?: number;
|
|
823
|
+
fontFamily?: string;
|
|
824
|
+
fontWeight?: string | number;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
export interface LegendTitleStyleOptions {
|
|
828
|
+
color?: string;
|
|
829
|
+
fontSize?: number;
|
|
830
|
+
fontFamily?: string;
|
|
831
|
+
fontWeight?: string | number;
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
export type LegendSymbolLayer =
|
|
835
|
+
| { type: "line"; length?: number; lineWidth?: number }
|
|
836
|
+
| {
|
|
837
|
+
type: "point";
|
|
838
|
+
shape?: "circle";
|
|
839
|
+
size?: number;
|
|
840
|
+
fill?: string;
|
|
841
|
+
stroke?: string;
|
|
842
|
+
strokeWidth?: number;
|
|
843
|
+
}
|
|
844
|
+
| {
|
|
845
|
+
type: "swatch";
|
|
846
|
+
width?: number;
|
|
847
|
+
height?: number;
|
|
848
|
+
stroke?: string;
|
|
849
|
+
strokeWidth?: number;
|
|
850
|
+
};
|
|
851
|
+
|
|
852
|
+
export type LegendSymbolRecipe =
|
|
853
|
+
| "auto"
|
|
854
|
+
| { length?: number; lineWidth?: number }
|
|
855
|
+
| { width?: number; height?: number; stroke?: string; strokeWidth?: number }
|
|
856
|
+
| { layers: readonly LegendSymbolLayer[] };
|
|
857
|
+
|
|
858
|
+
export interface LegendBorderOptions {
|
|
859
|
+
color?: string;
|
|
860
|
+
lineWidth?: number;
|
|
861
|
+
padding?: number;
|
|
862
|
+
background?: string;
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
export interface LegendOptions {
|
|
866
|
+
target?: string;
|
|
867
|
+
channels?: readonly ("color" | "strokeDash" | "shape" | "opacity")[];
|
|
868
|
+
position?: "right" | "left" | "bottom" | "top";
|
|
869
|
+
align?: "left" | "center" | "right";
|
|
870
|
+
direction?: "horizontal" | "vertical";
|
|
871
|
+
columns?: number;
|
|
872
|
+
offset?: number;
|
|
873
|
+
titlePosition?: "top" | "left";
|
|
874
|
+
title?: string;
|
|
875
|
+
count?: number;
|
|
876
|
+
gradient?: { length?: number; thickness?: number };
|
|
877
|
+
symbol?: LegendSymbolRecipe;
|
|
878
|
+
labels?: LegendTextOptions;
|
|
879
|
+
titleStyle?: LegendTitleStyleOptions;
|
|
880
|
+
itemGap?: number;
|
|
881
|
+
border?: boolean | LegendBorderOptions;
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
export interface EditLegendOptions
|
|
885
|
+
extends Omit<LegendOptions, "channels" | "title"> {
|
|
886
|
+
title?: string | "auto" | false;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
export interface TitleTextStyleOptions {
|
|
890
|
+
color?: string;
|
|
891
|
+
fontSize?: number;
|
|
892
|
+
fontFamily?: string;
|
|
893
|
+
fontWeight?: string | number;
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
export interface TitleOptions {
|
|
897
|
+
text: string;
|
|
898
|
+
subtitle?: string;
|
|
899
|
+
position?: "top" | "bottom" | "left" | "right";
|
|
900
|
+
align?: "left" | "center" | "right";
|
|
901
|
+
offset?: number;
|
|
902
|
+
gap?: number;
|
|
903
|
+
maxWidth?: number;
|
|
904
|
+
wrap?: "word" | "character";
|
|
905
|
+
lineHeight?: number;
|
|
906
|
+
titleStyle?: TitleTextStyleOptions;
|
|
907
|
+
subtitleStyle?: TitleTextStyleOptions;
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
export interface EditTitleOptions
|
|
911
|
+
extends Omit<TitleOptions, "text" | "subtitle"> {
|
|
912
|
+
text?: string;
|
|
913
|
+
subtitle?: string | false;
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
export class ChartProgram {
|
|
917
|
+
constructor(state?: ActionOptions);
|
|
918
|
+
readonly semanticSpec: SemanticSpec;
|
|
919
|
+
readonly graphicSpec: GraphicSpec;
|
|
920
|
+
readonly resolvedScales: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
|
|
921
|
+
readonly materializationConfigs: Readonly<Record<string, unknown>>;
|
|
922
|
+
readonly context: Readonly<Record<string, unknown>>;
|
|
923
|
+
readonly trace: TraceNode;
|
|
924
|
+
readonly actionStack: readonly unknown[];
|
|
925
|
+
|
|
926
|
+
createCanvas(options?: CanvasOptions): ChartProgram;
|
|
927
|
+
editCanvas(options: CanvasOptions): ChartProgram;
|
|
928
|
+
createData(options: { id?: string; values: readonly unknown[] }): ChartProgram;
|
|
929
|
+
filterData(options: FilterDataOptions): ChartProgram;
|
|
930
|
+
filterMarks(options: FilterMarksOptions): ChartProgram;
|
|
931
|
+
selectMarks(options: SelectMarksOptions): ChartProgram;
|
|
932
|
+
highlightMarks(options: HighlightMarksOptions): ChartProgram;
|
|
933
|
+
createDensityData(options: DensityDataOptions): ChartProgram;
|
|
934
|
+
createRegressionData(options: RegressionDataOptions): ChartProgram;
|
|
935
|
+
createIntervalData(options: IntervalDataOptions): ChartProgram;
|
|
936
|
+
|
|
937
|
+
createPointMark(options?: { id?: string; data?: string; shape?: PointShape }): ChartProgram;
|
|
938
|
+
editPointMark(options: {
|
|
939
|
+
target?: string;
|
|
940
|
+
shape?: PointShape;
|
|
941
|
+
fill?: string;
|
|
942
|
+
opacity?: number;
|
|
943
|
+
stroke?: string;
|
|
944
|
+
strokeWidth?: number;
|
|
945
|
+
}): ChartProgram;
|
|
946
|
+
createLineMark(options?: {
|
|
947
|
+
id?: string;
|
|
948
|
+
data?: string;
|
|
949
|
+
strokeWidth?: number;
|
|
950
|
+
curve?: CurveInterpolation;
|
|
951
|
+
}): ChartProgram;
|
|
952
|
+
editLineMark(options: {
|
|
953
|
+
target?: string;
|
|
954
|
+
strokeWidth?: number;
|
|
955
|
+
curve?: CurveInterpolation;
|
|
956
|
+
}): ChartProgram;
|
|
957
|
+
createBarMark(options?: { id?: string; data?: string }): ChartProgram;
|
|
958
|
+
editBarMark(options: {
|
|
959
|
+
target?: string;
|
|
960
|
+
fill?: string;
|
|
961
|
+
opacity?: number;
|
|
962
|
+
stroke?: string | false;
|
|
963
|
+
strokeWidth?: number;
|
|
964
|
+
}): ChartProgram;
|
|
965
|
+
createAreaMark(options?: {
|
|
966
|
+
id?: string;
|
|
967
|
+
data?: string;
|
|
968
|
+
fill?: string;
|
|
969
|
+
opacity?: number;
|
|
970
|
+
stroke?: string;
|
|
971
|
+
strokeWidth?: number;
|
|
972
|
+
curve?: CurveInterpolation;
|
|
973
|
+
}): ChartProgram;
|
|
974
|
+
createRuleMark(options?: { id?: string; data?: string }): ChartProgram;
|
|
975
|
+
editAreaMark(options: {
|
|
976
|
+
target?: string;
|
|
977
|
+
fill?: string;
|
|
978
|
+
opacity?: number;
|
|
979
|
+
stroke?: string | false;
|
|
980
|
+
strokeWidth?: number;
|
|
981
|
+
curve?: CurveInterpolation;
|
|
982
|
+
}): ChartProgram;
|
|
983
|
+
|
|
984
|
+
encodeX(options: PositionEncodingOptions | RulePositionEncodingOptions): ChartProgram;
|
|
985
|
+
encodeY(options: PositionEncodingOptions | RulePositionEncodingOptions): ChartProgram;
|
|
986
|
+
encodeX2(options: SecondaryPositionEncodingOptions): ChartProgram;
|
|
987
|
+
encodeColor(options: ColorEncodingOptions): ChartProgram;
|
|
988
|
+
encodeStrokeDash(options: StrokeDashEncodingOptions): ChartProgram;
|
|
989
|
+
encodeSize(options: { field: string; target?: string; fieldType?: "quantitative"; scale?: ScaleOptions }): ChartProgram;
|
|
990
|
+
encodeShape(options: { field: string; target?: string; fieldType?: "nominal"; scale?: ScaleOptions }): ChartProgram;
|
|
991
|
+
encodeOpacity(options: OpacityEncodingOptions): ChartProgram;
|
|
992
|
+
encodeRadius(options: { value: number; target?: string }): ChartProgram;
|
|
993
|
+
encodeXOffset(options: XOffsetEncodingOptions): ChartProgram;
|
|
994
|
+
encodeY2(options: SecondaryPositionEncodingOptions): ChartProgram;
|
|
995
|
+
encodeYRange(options: {
|
|
996
|
+
lower: string;
|
|
997
|
+
upper: string;
|
|
998
|
+
target?: string;
|
|
999
|
+
fieldType?: "quantitative";
|
|
1000
|
+
coordinate?: string;
|
|
1001
|
+
scale?: ScaleOptions;
|
|
1002
|
+
}): ChartProgram;
|
|
1003
|
+
encodeXRange(options: {
|
|
1004
|
+
lower: string;
|
|
1005
|
+
upper: string;
|
|
1006
|
+
target?: string;
|
|
1007
|
+
fieldType?: "quantitative";
|
|
1008
|
+
coordinate?: string;
|
|
1009
|
+
scale?: ScaleOptions;
|
|
1010
|
+
}): ChartProgram;
|
|
1011
|
+
encodeGroup(options: { field: string; target?: string; fieldType?: "nominal" }): ChartProgram;
|
|
1012
|
+
encodeHistogram(options: HistogramEncodingOptions): ChartProgram;
|
|
1013
|
+
encodeDensity(options: DensityEncodingOptions): ChartProgram;
|
|
1014
|
+
editDensity(options: EditDensityOptions): ChartProgram;
|
|
1015
|
+
encodeBarWidth(options?: BarWidthOptions): ChartProgram;
|
|
1016
|
+
encodeStroke(options: { target?: string; value: string }): ChartProgram;
|
|
1017
|
+
encodeStrokeWidth(options: { target?: string; value: number }): ChartProgram;
|
|
1018
|
+
|
|
1019
|
+
createRegression(options?: RegressionOptions): ChartProgram;
|
|
1020
|
+
createErrorBar(options?: ErrorBarOptions): ChartProgram;
|
|
1021
|
+
createErrorBand(options?: ErrorBandOptions): ChartProgram;
|
|
1022
|
+
createBoxPlot(options?: BoxPlotOptions): ChartProgram;
|
|
1023
|
+
createAxes(options?: CreateAxesOptions): ChartProgram;
|
|
1024
|
+
createXAxis(options?: CompleteAxisOptions<XAxisPosition>): ChartProgram;
|
|
1025
|
+
createYAxis(options?: CompleteAxisOptions<YAxisPosition>): ChartProgram;
|
|
1026
|
+
createXAxisLine(options?: AxisLineStyleOptions & { scale?: string; position?: XAxisPosition }): ChartProgram;
|
|
1027
|
+
createYAxisLine(options?: AxisLineStyleOptions & { scale?: string; position?: YAxisPosition }): ChartProgram;
|
|
1028
|
+
editXAxisLine(options?: AxisLineStyleOptions & { position?: XAxisPosition }): ChartProgram;
|
|
1029
|
+
editYAxisLine(options?: AxisLineStyleOptions & { position?: YAxisPosition }): ChartProgram;
|
|
1030
|
+
createXAxisTicks(options?: AxisTickOptions<XAxisPosition>): ChartProgram;
|
|
1031
|
+
createYAxisTicks(options?: AxisTickOptions<YAxisPosition>): ChartProgram;
|
|
1032
|
+
editXAxisTicks(options?: Omit<AxisTickOptions<XAxisPosition>, "scale">): ChartProgram;
|
|
1033
|
+
editYAxisTicks(options?: Omit<AxisTickOptions<YAxisPosition>, "scale">): ChartProgram;
|
|
1034
|
+
createXAxisLabels(options?: AxisLabelOptions<XAxisPosition>): ChartProgram;
|
|
1035
|
+
createYAxisLabels(options?: AxisLabelOptions<YAxisPosition>): ChartProgram;
|
|
1036
|
+
editXAxisLabels(options?: Omit<AxisLabelOptions<XAxisPosition>, "scale">): ChartProgram;
|
|
1037
|
+
editYAxisLabels(options?: Omit<AxisLabelOptions<YAxisPosition>, "scale">): ChartProgram;
|
|
1038
|
+
createXAxisTicksAndLabels(options?: AxisTicksAndLabelsOptions<XAxisPosition>): ChartProgram;
|
|
1039
|
+
createYAxisTicksAndLabels(options?: AxisTicksAndLabelsOptions<YAxisPosition>): ChartProgram;
|
|
1040
|
+
editXAxisTicksAndLabels(options: Omit<AxisTicksAndLabelsOptions<XAxisPosition>, "scale">): ChartProgram;
|
|
1041
|
+
editYAxisTicksAndLabels(options: Omit<AxisTicksAndLabelsOptions<YAxisPosition>, "scale">): ChartProgram;
|
|
1042
|
+
createXAxisTitle(options?: AxisTitleOptions<XAxisPosition>): ChartProgram;
|
|
1043
|
+
createYAxisTitle(options?: AxisTitleOptions<YAxisPosition>): ChartProgram;
|
|
1044
|
+
editXAxisTitle(options?: Omit<AxisTitleOptions<XAxisPosition>, "scale">): ChartProgram;
|
|
1045
|
+
editYAxisTitle(options?: Omit<AxisTitleOptions<YAxisPosition>, "scale">): ChartProgram;
|
|
1046
|
+
createGrid(options?: CreateGridOptions): ChartProgram;
|
|
1047
|
+
createHorizontalGrid(options?: GridDirectionOptions): ChartProgram;
|
|
1048
|
+
createVerticalGrid(options?: GridDirectionOptions): ChartProgram;
|
|
1049
|
+
editHorizontalGrid(options: EditGridOptions): ChartProgram;
|
|
1050
|
+
editVerticalGrid(options: EditGridOptions): ChartProgram;
|
|
1051
|
+
createLegend(options?: LegendOptions): ChartProgram;
|
|
1052
|
+
editLegend(options: EditLegendOptions): ChartProgram;
|
|
1053
|
+
createGuides(options?: ActionOptions): ChartProgram;
|
|
1054
|
+
createTitle(options: TitleOptions): ChartProgram;
|
|
1055
|
+
editTitle(options: EditTitleOptions): ChartProgram;
|
|
1056
|
+
|
|
1057
|
+
createCoordinate(options?: ActionOptions): ChartProgram;
|
|
1058
|
+
createScale(options: ActionOptions & { id: string }): ChartProgram;
|
|
1059
|
+
editScale(options: EditScaleOptions): ChartProgram;
|
|
1060
|
+
createDerivedData(options: ActionOptions): ChartProgram;
|
|
1061
|
+
createRegressionBand(options: ActionOptions & {
|
|
1062
|
+
id: string;
|
|
1063
|
+
stroke?: string;
|
|
1064
|
+
strokeWidth?: number;
|
|
1065
|
+
curve?: CurveInterpolation;
|
|
1066
|
+
}): ChartProgram;
|
|
1067
|
+
editRegressionBand(options: {
|
|
1068
|
+
target?: string;
|
|
1069
|
+
color?: string;
|
|
1070
|
+
opacity?: number;
|
|
1071
|
+
stroke?: string | false;
|
|
1072
|
+
strokeWidth?: number;
|
|
1073
|
+
curve?: CurveInterpolation;
|
|
1074
|
+
}): ChartProgram;
|
|
1075
|
+
createRegressionLine(options: ActionOptions & {
|
|
1076
|
+
id: string;
|
|
1077
|
+
strokeWidth?: number;
|
|
1078
|
+
curve?: CurveInterpolation;
|
|
1079
|
+
}): ChartProgram;
|
|
1080
|
+
editRegressionLine(options: {
|
|
1081
|
+
target?: string;
|
|
1082
|
+
strokeWidth?: number;
|
|
1083
|
+
curve?: CurveInterpolation;
|
|
1084
|
+
}): ChartProgram;
|
|
1085
|
+
|
|
1086
|
+
editSemantic(options: EditSemanticOptions): ChartProgram;
|
|
1087
|
+
createGraphics(options: {
|
|
1088
|
+
id: string;
|
|
1089
|
+
type: GraphicType;
|
|
1090
|
+
length?: number;
|
|
1091
|
+
parent?: string;
|
|
1092
|
+
before?: string;
|
|
1093
|
+
after?: string;
|
|
1094
|
+
}): ChartProgram;
|
|
1095
|
+
editGraphics(options: EditGraphicsOptions): ChartProgram;
|
|
1096
|
+
}
|