@uwdata/mosaic-spec 0.7.0 → 0.8.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.
Files changed (154) hide show
  1. package/dist/mosaic-schema.json +186153 -0
  2. package/dist/mosaic-spec.js +3387 -4641
  3. package/dist/mosaic-spec.min.js +23 -23
  4. package/dist/types/ast/ASTNode.d.ts +26 -0
  5. package/dist/types/ast/DataNode.d.ts +60 -0
  6. package/dist/types/ast/ExpressionNode.d.ts +15 -0
  7. package/dist/types/ast/HConcatNode.d.ts +10 -0
  8. package/dist/types/ast/HSpaceNode.d.ts +11 -0
  9. package/dist/types/ast/InputNode.d.ts +8 -0
  10. package/dist/types/ast/LiteralNode.d.ts +7 -0
  11. package/dist/types/ast/OptionsNode.d.ts +10 -0
  12. package/dist/types/ast/ParamNode.d.ts +9 -0
  13. package/dist/types/ast/ParamRefNode.d.ts +8 -0
  14. package/dist/types/ast/PlotAttributeNode.d.ts +18 -0
  15. package/dist/types/ast/PlotFromNode.d.ts +9 -0
  16. package/dist/types/ast/PlotInteractorNode.d.ts +8 -0
  17. package/dist/types/ast/PlotLegendNode.d.ts +10 -0
  18. package/dist/types/ast/PlotMarkNode.d.ts +10 -0
  19. package/dist/types/ast/PlotNode.d.ts +11 -0
  20. package/dist/types/ast/SelectionNode.d.ts +12 -0
  21. package/dist/types/ast/SpecNode.d.ts +10 -0
  22. package/dist/types/ast/TransformNode.d.ts +13 -0
  23. package/dist/types/ast/VConcatNode.d.ts +10 -0
  24. package/dist/types/ast/VSpaceNode.d.ts +11 -0
  25. package/dist/types/ast-to-dom.d.ts +38 -0
  26. package/dist/types/ast-to-esm.d.ts +64 -0
  27. package/dist/types/config/components.d.ts +4 -0
  28. package/dist/types/config/extensions.d.ts +9 -0
  29. package/dist/types/config/inputs.d.ts +5 -0
  30. package/dist/types/config/plots.d.ts +34 -0
  31. package/dist/types/config/transforms.d.ts +4 -0
  32. package/dist/types/constants.d.ts +30 -0
  33. package/dist/types/index.d.ts +29 -0
  34. package/dist/types/parse-spec.d.ts +86 -0
  35. package/dist/types/spec/CSSStyles.d.ts +3 -0
  36. package/dist/types/spec/Data.d.ts +165 -0
  37. package/dist/types/spec/Expression.d.ts +27 -0
  38. package/dist/types/spec/HConcat.d.ts +8 -0
  39. package/dist/types/spec/HSpace.d.ts +9 -0
  40. package/dist/types/spec/Input.d.ts +182 -0
  41. package/dist/types/spec/Param.d.ts +51 -0
  42. package/dist/types/spec/Plot.d.ts +14 -0
  43. package/dist/types/spec/PlotAttribute.d.ts +1522 -0
  44. package/dist/types/spec/PlotFrom.d.ts +20 -0
  45. package/dist/types/spec/PlotInteractor.d.ts +8 -0
  46. package/dist/types/spec/PlotLegend.d.ts +68 -0
  47. package/dist/types/spec/PlotMark.d.ts +26 -0
  48. package/dist/types/spec/PlotTypes.d.ts +293 -0
  49. package/dist/types/spec/Spec.d.ts +45 -0
  50. package/dist/types/spec/Transform.d.ts +278 -0
  51. package/dist/types/spec/VConcat.d.ts +8 -0
  52. package/dist/types/spec/VSpace.d.ts +9 -0
  53. package/dist/types/spec/interactors/Highlight.d.ts +37 -0
  54. package/dist/types/spec/interactors/Interval1D.d.ts +63 -0
  55. package/dist/types/spec/interactors/Interval2D.d.ts +46 -0
  56. package/dist/types/spec/interactors/Nearest.d.ts +25 -0
  57. package/dist/types/spec/interactors/PanZoom.d.ts +58 -0
  58. package/dist/types/spec/interactors/Toggle.d.ts +51 -0
  59. package/dist/types/spec/marks/Area.d.ts +139 -0
  60. package/dist/types/spec/marks/Arrow.d.ts +94 -0
  61. package/dist/types/spec/marks/Axis.d.ts +281 -0
  62. package/dist/types/spec/marks/Bar.d.ts +150 -0
  63. package/dist/types/spec/marks/Cell.d.ts +57 -0
  64. package/dist/types/spec/marks/Contour.d.ts +23 -0
  65. package/dist/types/spec/marks/Delaunay.d.ts +86 -0
  66. package/dist/types/spec/marks/DenseLine.d.ts +27 -0
  67. package/dist/types/spec/marks/Density.d.ts +121 -0
  68. package/dist/types/spec/marks/Dot.d.ts +129 -0
  69. package/dist/types/spec/marks/Frame.d.ts +21 -0
  70. package/dist/types/spec/marks/Geo.d.ts +53 -0
  71. package/dist/types/spec/marks/Hexbin.d.ts +30 -0
  72. package/dist/types/spec/marks/Hexgrid.d.ts +25 -0
  73. package/dist/types/spec/marks/Image.d.ts +89 -0
  74. package/dist/types/spec/marks/Line.d.ts +82 -0
  75. package/dist/types/spec/marks/Link.d.ts +60 -0
  76. package/dist/types/spec/marks/Marks.d.ts +890 -0
  77. package/dist/types/spec/marks/Raster.d.ts +124 -0
  78. package/dist/types/spec/marks/Rect.d.ts +166 -0
  79. package/dist/types/spec/marks/Regression.d.ts +58 -0
  80. package/dist/types/spec/marks/Rule.d.ts +100 -0
  81. package/dist/types/spec/marks/Text.d.ts +106 -0
  82. package/dist/types/spec/marks/Tick.d.ts +61 -0
  83. package/dist/types/spec/marks/Vector.d.ts +99 -0
  84. package/dist/types/util.d.ts +12 -0
  85. package/jsconfig.json +10 -0
  86. package/package.json +16 -9
  87. package/src/ast/ASTNode.js +23 -2
  88. package/src/ast/DataNode.js +79 -21
  89. package/src/ast/HSpaceNode.js +1 -1
  90. package/src/ast/InputNode.js +1 -2
  91. package/src/ast/ParamNode.js +1 -2
  92. package/src/ast/PlotAttributeNode.js +1 -2
  93. package/src/ast/PlotInteractorNode.js +1 -2
  94. package/src/ast/PlotLegendNode.js +1 -2
  95. package/src/ast/PlotMarkNode.js +3 -2
  96. package/src/ast/TransformNode.js +1 -2
  97. package/src/ast/VSpaceNode.js +1 -1
  98. package/src/ast-to-dom.js +16 -7
  99. package/src/ast-to-esm.js +41 -12
  100. package/src/config/inputs.js +1 -0
  101. package/src/config/plots.js +4 -0
  102. package/src/index.js +4 -0
  103. package/src/parse-spec.js +38 -5
  104. package/src/spec/CSSStyles.ts +9 -0
  105. package/src/spec/Data.ts +184 -0
  106. package/src/spec/Expression.ts +31 -0
  107. package/src/spec/HConcat.ts +9 -0
  108. package/src/spec/HSpace.ts +9 -0
  109. package/src/spec/Input.ts +182 -0
  110. package/src/spec/Param.ts +68 -0
  111. package/src/spec/Plot.ts +15 -0
  112. package/src/spec/PlotAttribute.ts +1783 -0
  113. package/src/spec/PlotFrom.ts +23 -0
  114. package/src/spec/PlotInteractor.ts +25 -0
  115. package/src/spec/PlotLegend.ts +70 -0
  116. package/src/spec/PlotMark.ts +51 -0
  117. package/src/spec/PlotTypes.ts +519 -0
  118. package/src/spec/Spec.ts +63 -0
  119. package/src/spec/Transform.ts +394 -0
  120. package/src/spec/VConcat.ts +9 -0
  121. package/src/spec/VSpace.ts +9 -0
  122. package/src/spec/interactors/Highlight.ts +38 -0
  123. package/src/spec/interactors/Interval1D.ts +67 -0
  124. package/src/spec/interactors/Interval2D.ts +48 -0
  125. package/src/spec/interactors/Nearest.ts +28 -0
  126. package/src/spec/interactors/PanZoom.ts +65 -0
  127. package/src/spec/interactors/Toggle.ts +56 -0
  128. package/src/spec/marks/Area.ts +154 -0
  129. package/src/spec/marks/Arrow.ts +108 -0
  130. package/src/spec/marks/Axis.ts +305 -0
  131. package/src/spec/marks/Bar.ts +160 -0
  132. package/src/spec/marks/Cell.ts +62 -0
  133. package/src/spec/marks/Contour.ts +25 -0
  134. package/src/spec/marks/Delaunay.ts +95 -0
  135. package/src/spec/marks/DenseLine.ts +30 -0
  136. package/src/spec/marks/Density.ts +145 -0
  137. package/src/spec/marks/Dot.ts +147 -0
  138. package/src/spec/marks/Frame.ts +23 -0
  139. package/src/spec/marks/Geo.ts +58 -0
  140. package/src/spec/marks/Hexbin.ts +34 -0
  141. package/src/spec/marks/Hexgrid.ts +27 -0
  142. package/src/spec/marks/Image.ts +101 -0
  143. package/src/spec/marks/Line.ts +93 -0
  144. package/src/spec/marks/Link.ts +70 -0
  145. package/src/spec/marks/Marks.ts +1062 -0
  146. package/src/spec/marks/Raster.ts +145 -0
  147. package/src/spec/marks/Rect.ts +183 -0
  148. package/src/spec/marks/Regression.ts +63 -0
  149. package/src/spec/marks/Rule.ts +113 -0
  150. package/src/spec/marks/Text.ts +122 -0
  151. package/src/spec/marks/Tick.ts +69 -0
  152. package/src/spec/marks/Vector.ts +113 -0
  153. package/src/util.js +8 -0
  154. package/tsconfig.json +11 -0
@@ -0,0 +1,145 @@
1
+ import { ParamRef } from '../Param.js';
2
+ import { ChannelValueSpec, MarkData, MarkOptions } from './Marks.js';
3
+
4
+ /**
5
+ * A spatial interpolation method; one of:
6
+ *
7
+ * - *none* - do not perform interpolation (the default), maps samples to single bins
8
+ * - *linear* - apply proportional linear interpolation across adjacent bins
9
+ * - *nearest* - assign each pixel to the closest sample’s value (Voronoi diagram)
10
+ * - *barycentric* - apply barycentric interpolation over the Delaunay triangulation
11
+ * - *random-walk* - apply a random walk from each pixel, stopping when near a sample
12
+ */
13
+ export type GridInterpolate =
14
+ | 'none'
15
+ | 'linear'
16
+ | 'nearest'
17
+ | 'barycentric'
18
+ | 'random-walk';
19
+
20
+ /** Options for grid2d marks. */
21
+ export interface Grid2DOptions {
22
+ /**
23
+ * The horizontal position channel, typically bound to the *x* scale.
24
+ * Domain values are binned into a grid with *width* horizontal bins.
25
+ */
26
+ x?: ChannelValueSpec;
27
+
28
+ /**
29
+ * The vertical position channel, typically bound to the *y* scale.
30
+ * Domain values are binned into a grid with *height* vertical bins.
31
+ */
32
+ y?: ChannelValueSpec;
33
+
34
+ /** The width (number of columns) of the grid, in actual pixels. */
35
+ width?: number | ParamRef;
36
+
37
+ /** The height (number of rows) of the grid, in actual pixels. */
38
+ height?: number | ParamRef;
39
+
40
+ /**
41
+ * The effective screen size of a raster pixel, used to determine the height
42
+ * and width of the raster from the frame’s dimensions; defaults to 1.
43
+ */
44
+ pixelSize?: number | ParamRef;
45
+
46
+ /**
47
+ * The bin padding, one of 1 (default) to include extra padding for the final
48
+ * bin, or 0 to make the bins flush with the maximum domain value.
49
+ */
50
+ pad?: number | ParamRef;
51
+
52
+ /**
53
+ * The kernel density bandwidth for smoothing, in pixels.
54
+ */
55
+ bandwidth?: number | ParamRef;
56
+
57
+ /**
58
+ * The spatial interpolation method; one of:
59
+ *
60
+ * - *none* - do not perform interpolation (the default), maps samples to single bins
61
+ * - *linear* - apply proportional linear interpolation across adjacent bins
62
+ * - *nearest* - assign each pixel to the closest sample’s value (Voronoi diagram)
63
+ * - *barycentric* - apply barycentric interpolation over the Delaunay triangulation
64
+ * - *random-walk* - apply a random walk from each pixel, stopping when near a sample
65
+ */
66
+ interpolate?: GridInterpolate | null | ParamRef;
67
+ }
68
+
69
+ /** Options for the raster mark. */
70
+ export interface RasterOptions extends Grid2DOptions, Omit<MarkOptions, 'fill' | 'fillOpacity'> {
71
+ /**
72
+ * The [image-rendering attribute][1]; defaults to *auto* (bilinear). The
73
+ * option may be set to *pixelated* to disable bilinear interpolation for a
74
+ * sharper image; however, note that this is not supported in WebKit.
75
+ *
76
+ * [1]: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/image-rendering
77
+ */
78
+ imageRendering?: string | ParamRef;
79
+
80
+ /**
81
+ * The fill, typically bound to the *color* scale. Can be specified as a
82
+ * constant or a channel based on the input data. Use the special value
83
+ * `"density"` to map computed density values to pixel colors. Use an
84
+ * aggregate expression to instead visualize an aggregate value per raster
85
+ * bin. If fill is set to a constant color or to a non-aggregate field,
86
+ * opacity will be used to convey densities. If a non-aggregate (group by)
87
+ * field is provided, multiple rasters are created with a unique categorical
88
+ * color per layer.
89
+ */
90
+ fill?: ChannelValueSpec | ParamRef;
91
+
92
+ /**
93
+ * The opacity, typically bound to the *opacity* scale. Can be specified as a
94
+ * constant or a channel based on the input data. Use the special value
95
+ * `"density"` to map computed density values to opacity. Use an aggregate
96
+ * expression to instead visualize an aggregate value per raster bin.
97
+ */
98
+ fillOpacity?: ChannelValueSpec | ParamRef;
99
+ }
100
+
101
+ /** The raster mark. */
102
+ export interface Raster extends MarkData, RasterOptions {
103
+ /**
104
+ * A raster mark which renders a raster image from spatial samples. It
105
+ * represents discrete samples in abstract coordinates **x** and **y**;
106
+ * the **fill** and **fillOpacity** channels specify further abstract
107
+ * values (_e.g._, height in a topographic map) to be spatially
108
+ * interpolated to produce an image.
109
+ *
110
+ * The **x** and **y** data domains are binned into the cells ("pixels")
111
+ * of a raster grid, typically with an aggregate function evaluated over
112
+ * the binned data. The result can be optionally smoothed (blurred).
113
+ *
114
+ * To create a smoothed density heatmap, use the heatmap mark, which is
115
+ * a raster mark with different default options.
116
+ */
117
+ mark: 'raster';
118
+ }
119
+
120
+ /** The heatmap mark. */
121
+ export interface Heatmap extends MarkData, RasterOptions {
122
+ /**
123
+ * Like raster, but with default options for accurate density estimation
124
+ * via smoothing. The *bandwidth* (20), *interpolate* ("linear"), and
125
+ * *pixelSize* (2) options are set to produce smoothed density heatmaps.
126
+ */
127
+ mark: 'heatmap';
128
+ }
129
+
130
+ /** The rasterTile mark. */
131
+ export interface RasterTile extends MarkData, RasterOptions {
132
+ /**
133
+ * An experimental raster mark which performs tiling and prefetching to
134
+ * support more scalable rasters upon panning the domain. Uses a tile
135
+ * size that matches with current width and height, and prefetches data
136
+ * from neighboring tile segments.
137
+ */
138
+ mark: 'rasterTile';
139
+
140
+ /**
141
+ * The coordinates of the tile origin in the **x** and **y** data domains.
142
+ * Defaults to [0, 0].
143
+ */
144
+ origin?: [number, number] | ParamRef;
145
+ }
@@ -0,0 +1,183 @@
1
+ import { ParamRef } from '../Param.js';
2
+ import { Interval } from '../PlotTypes.js';
3
+ import {
4
+ ChannelValueIntervalSpec, ChannelValueSpec, InsetOptions,
5
+ MarkData, MarkOptions, StackOptions
6
+ } from './Marks.js';
7
+
8
+ /** Options for marks that render rectangles, including bar, cell, and rect. */
9
+ export interface RectCornerOptions {
10
+ /**
11
+ * The rounded corner [*x*-radius][1], either in pixels or as a percentage of
12
+ * the rect width. If **rx** is not specified, it defaults to **ry** if
13
+ * present, and otherwise draws square corners.
14
+ *
15
+ * [1]: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/rx
16
+ */
17
+ rx?: number | string | ParamRef;
18
+
19
+ /**
20
+ * The rounded corner [*y*-radius][1], either in pixels or as a percentage of
21
+ * the rect height. If **ry** is not specified, it defaults to **rx** if
22
+ * present, and otherwise draws square corners.
23
+ *
24
+ * [1]: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/ry
25
+ */
26
+ ry?: number | string | ParamRef;
27
+ }
28
+
29
+ /** Options for the rect mark. */
30
+ export interface RectOptions extends MarkOptions, InsetOptions, RectCornerOptions, StackOptions {
31
+ /**
32
+ * The horizontal position (or length/width) channel, typically bound to the
33
+ * *x* scale.
34
+ *
35
+ * If an **interval** is specified, then **x1** and **x2** are derived from
36
+ * **x**, representing the lower and upper bound of the containing interval,
37
+ * respectively. For example, for a vertical bar chart of items sold by day:
38
+ *
39
+ * ```js
40
+ * Plot.rectY(sales, {x: "date", interval: "day", y2: "items"})
41
+ * ```
42
+ *
43
+ * If *x* represents ordinal values, use a bar or cell mark instead.
44
+ */
45
+ x?: ChannelValueIntervalSpec;
46
+
47
+ /**
48
+ * The required primary (starting, often left) horizontal position channel,
49
+ * typically bound to the *x* scale. Setting this option disables the rectX
50
+ * mark’s implicit stackX transform.
51
+ *
52
+ * If *x* represents ordinal values, use a bar or cell mark instead.
53
+ */
54
+ x1?: ChannelValueSpec;
55
+
56
+ /**
57
+ * The required secondary (ending, often right) horizontal position channel,
58
+ * typically bound to the *x* scale. Setting this option disables the rectX
59
+ * mark’s implicit stackX transform.
60
+ *
61
+ * If *x* represents ordinal values, use a bar or cell mark instead.
62
+ */
63
+ x2?: ChannelValueSpec;
64
+
65
+ /**
66
+ * The vertical position (or length/height) channel, typically bound to the
67
+ * *y* scale.
68
+ *
69
+ * If an **interval** is specified, then **y1** and **y2** are derived from
70
+ * **y**, representing the lower and upper bound of the containing interval,
71
+ * respectively. For example, for a horizontal bar chart of items sold by day:
72
+ *
73
+ * ```js
74
+ * Plot.rectX(sales, {y: "date", interval: "day", x2: "items"})
75
+ * ```
76
+ *
77
+ * If *y* represents ordinal values, use a bar or cell mark instead.
78
+ */
79
+ y?: ChannelValueIntervalSpec;
80
+
81
+ /**
82
+ * The required primary (starting, often bottom) vertical position channel,
83
+ * typically bound to the *y* scale. Setting this option disables the rectY
84
+ * mark’s implicit stackY transform.
85
+ *
86
+ * If *y* represents ordinal values, use a bar or cell mark instead.
87
+ */
88
+ y1?: ChannelValueSpec;
89
+
90
+ /**
91
+ * The required secondary (ending, often top) vertical position channel,
92
+ * typically bound to the *y* scale. Setting this option disables the rectY
93
+ * mark’s implicit stackY transform.
94
+ *
95
+ * If *y* represents ordinal values, use a bar or cell mark instead.
96
+ */
97
+ y2?: ChannelValueSpec;
98
+
99
+ /**
100
+ * How to convert a continuous value (**x** for rectY, **y** for rectX, or
101
+ * both for rect) into an interval (**x1** and **x2** for rectY, or **y1** and
102
+ * **y2** for rectX, or both for rect); one of:
103
+ *
104
+ * - a named time interval such as *day* (for date intervals)
105
+ * - a number (for number intervals), defining intervals at integer multiples of *n*
106
+ *
107
+ * Setting this option disables the implicit stack transform (stackX for rectX,
108
+ * or stackY for rectY).
109
+ */
110
+ interval?: Interval | ParamRef;
111
+ }
112
+
113
+ /** Options for the rectX mark. */
114
+ export interface RectXOptions extends RectOptions {
115
+ /**
116
+ * The horizontal position (or length/width) channel, typically bound to the
117
+ * *x* scale.
118
+ *
119
+ * If neither **x1** nor **x2** is specified, an implicit stackX transform is
120
+ * applied and **x** defaults to the identity function, assuming that *data* =
121
+ * [*x₀*, *x₁*, *x₂*, …]. Otherwise, if only one of **x1** or **x2** is
122
+ * specified, the other defaults to **x**, which defaults to zero.
123
+ */
124
+ x?: ChannelValueSpec; // disallow x interval
125
+ }
126
+
127
+ /** Options for the rectY mark. */
128
+ export interface RectYOptions extends RectOptions {
129
+ /**
130
+ * The vertical position (or length/height) channel, typically bound to the
131
+ * *y* scale.
132
+ *
133
+ * If neither **y1** nor **y2** is specified, an implicit stackY transform is
134
+ * applied and **y** defaults to the identity function, assuming that *data* =
135
+ * [*y₀*, *y₁*, *y₂*, …]. Otherwise, if only one of **y1** or **y2** is
136
+ * specified, the other defaults to **y**, which defaults to zero.
137
+ */
138
+ y?: ChannelValueSpec; // disallow y interval
139
+ }
140
+
141
+ /** The rect mark. */
142
+ export interface Rect extends MarkData, RectOptions {
143
+ /**
144
+ * A rect mark. The rectangle extends horizontally from **x1** to **x2**,
145
+ * and vertically from **y1** to **y2**. The position channels are often
146
+ * derived with a transform.
147
+ *
148
+ * When **y** extends from zero, for example for a histogram where the
149
+ * height of each rect reflects a count of values, use the rectY mark for an
150
+ * implicit stackY transform; similarly, if **x** extends from zero, use the
151
+ * rectX mark for an implicit stackX transform.
152
+ *
153
+ * If an **interval** is specified, then **x1** and **x2** are derived from
154
+ * **x**, and **y1** and **y2** are derived from **y**, each representing the
155
+ * lower and upper bound of the containing interval, respectively.
156
+ *
157
+ * Both *x* and *y* should be quantitative or temporal; otherwise, use a bar
158
+ * or cell mark.
159
+ */
160
+ mark: 'rect';
161
+ }
162
+
163
+ /** The rectX mark. */
164
+ export interface RectX extends MarkData, RectXOptions {
165
+ /**
166
+ * Like rect, but if neither **x1** nor **x2** is specified, an implicit
167
+ * stackX transform is applied to **x**, and if **x** is not specified, it
168
+ * defaults to the identity function, assuming that *data* is an array of
169
+ * numbers [*x₀*, *x₁*, *x₂*, …].
170
+ */
171
+ mark: 'rectX';
172
+ }
173
+
174
+ /** The rectY mark. */
175
+ export interface RectY extends MarkData, RectYOptions {
176
+ /**
177
+ * Like rect, but if neither **y1** nor **y2** is specified, apply an
178
+ * implicit stackY transform is applied to **y**, and if **y** is not
179
+ * specified, it defaults to the identity function, assuming that *data*
180
+ * is an array of numbers [*y₀*, *y₁*, *y₂*, …].
181
+ */
182
+ mark: 'rectY';
183
+ }
@@ -0,0 +1,63 @@
1
+ import { ParamRef } from '../Param.js';
2
+ import { ChannelValue, ChannelValueSpec, MarkData, MarkOptions } from './Marks.js';
3
+
4
+ /** Options for regression marks. */
5
+ interface RegressionOptions extends MarkOptions {
6
+ /**
7
+ * The confidence interval in (0, 1), or 0 to hide bands; defaults to 0.95.
8
+ */
9
+ ci?: number | ParamRef;
10
+
11
+ /**
12
+ * The distance in pixels between samples of the confidence band;
13
+ * defaults to 4.
14
+ */
15
+ precision?: number | ParamRef;
16
+
17
+ /**
18
+ * An optional ordinal channel for grouping data into (possibly stacked)
19
+ * series, producing an independent regression for each group. If not
20
+ * specified, it defaults to **fill** if a channel, or **stroke** if a
21
+ * channel.
22
+ */
23
+ z?: ChannelValue;
24
+ }
25
+
26
+ /** Options for the regressionY mark. */
27
+ export interface RegressionYOptions extends RegressionOptions {
28
+ /**
29
+ * The independent variable horizontal position channel, typically bound to
30
+ * the *x* scale; defaults to the zero-based index of the data [0, 1, 2, …].
31
+ */
32
+ x?: ChannelValueSpec;
33
+
34
+ /**
35
+ * The dependent variable vertical position channel, typically bound to the
36
+ * *y* scale; defaults to identity, assuming that *data* = [*y₀*, *y₁*, *y₂*,
37
+ * …].
38
+ */
39
+ y?: ChannelValueSpec;
40
+ }
41
+
42
+ /** The regressionY mark. */
43
+ export interface RegressionY extends MarkData, RegressionYOptions {
44
+ /**
45
+ * A mark that draws [linear regression][1] lines with confidence bands,
46
+ * representing the estimated relation of a dependent variable (*y*) on an
47
+ * independent variable (*x*).
48
+ *
49
+ * The linear regression line is fit using the [least squares][2] approach.
50
+ * See Torben Jansen’s [“Linear regression with confidence bands”][3] and
51
+ * [this StatExchange question][4] for details on the confidence interval
52
+ * calculation.
53
+ *
54
+ * Multiple regressions can be produced by specifying a **z**, **fill**, or
55
+ * **stroke** channel.
56
+ *
57
+ * [1]: https://en.wikipedia.org/wiki/Linear_regression
58
+ * [2]: https://en.wikipedia.org/wiki/Least_squares
59
+ * [3]: https://observablehq.com/@toja/linear-regression-with-confidence-bands
60
+ * [4]: https://stats.stackexchange.com/questions/101318/understanding-shape-and-calculation-of-confidence-bands-in-linear-regression
61
+ */
62
+ mark: 'regressionY';
63
+ }
@@ -0,0 +1,113 @@
1
+ import { ParamRef } from '../Param.js';
2
+ import { Interval } from '../PlotTypes.js';
3
+ import {
4
+ ChannelValueIntervalSpec, ChannelValueSpec, InsetOptions,
5
+ MarkDataOptional, MarkOptions, MarkerOptions
6
+ } from './Marks.js';
7
+
8
+ /** Options for the ruleX and ruleY marks. */
9
+ interface RuleOptions extends MarkOptions, MarkerOptions {
10
+ /**
11
+ * How to convert a continuous value (**y** for ruleX, or **x** for ruleY)
12
+ * into an interval (**y1** and **y2** for ruleX, or **x1** and **x2** for
13
+ * ruleY); one of:
14
+ *
15
+ * - a named time interval such as *day* (for date intervals)
16
+ * - a number (for number intervals), defining intervals at integer multiples of *n*
17
+ */
18
+ interval?: Interval | ParamRef;
19
+ }
20
+
21
+ /** Options for the ruleX mark. */
22
+ export interface RuleXOptions extends RuleOptions, Omit<InsetOptions, 'insetLeft' | 'insetRight'> {
23
+ /**
24
+ * The horizontal position of the tick; an optional channel bound to the *x*
25
+ * scale. If not specified, the rule will be horizontally centered in the
26
+ * plot’s frame.
27
+ */
28
+ x?: ChannelValueSpec;
29
+
30
+ /**
31
+ * Shorthand for specifying both the primary and secondary vertical position
32
+ * of the tick as the bounds of the containing interval; can only be used in
33
+ * conjunction with the **interval** option.
34
+ */
35
+ y?: ChannelValueIntervalSpec;
36
+
37
+ /**
38
+ * The primary (starting, often bottom) vertical position of the tick; a
39
+ * channel bound to the *y* scale.
40
+ *
41
+ * If *y* represents ordinal values, use a tickX mark instead.
42
+ */
43
+ y1?: ChannelValueSpec;
44
+
45
+ /**
46
+ * The secondary (ending, often top) vertical position of the tick; a channel
47
+ * bound to the *y* scale.
48
+ *
49
+ * If *y* represents ordinal values, use a tickX mark instead.
50
+ */
51
+ y2?: ChannelValueSpec;
52
+ }
53
+
54
+ /** Options for the ruleY mark. */
55
+ export interface RuleYOptions extends RuleOptions, Omit<InsetOptions, "insetTop" | "insetBottom"> {
56
+ /**
57
+ * Shorthand for specifying both the primary and secondary horizontal position
58
+ * of the tick as the bounds of the containing interval; can only be used in
59
+ * conjunction with the **interval** option.
60
+ */
61
+ x?: ChannelValueIntervalSpec;
62
+
63
+ /**
64
+ * The primary (starting, often left) horizontal position of the tick; a
65
+ * channel bound to the *x* scale.
66
+ *
67
+ * If *x* represents ordinal values, use a tickY mark instead.
68
+ */
69
+ x1?: ChannelValueSpec;
70
+
71
+ /**
72
+ * The secondary (ending, often right) horizontal position of the tick; a
73
+ * channel bound to the *x* scale.
74
+ *
75
+ * If *x* represents ordinal values, use a tickY mark instead.
76
+ */
77
+ x2?: ChannelValueSpec;
78
+
79
+ /**
80
+ * The vertical position of the tick; an optional channel bound to the *y*
81
+ * scale. If not specified, the rule will be vertically centered in the plot’s
82
+ * frame.
83
+ */
84
+ y?: ChannelValueSpec;
85
+ }
86
+
87
+ /** The ruleX mark. */
88
+ export interface RuleX extends MarkDataOptional, RuleXOptions {
89
+ /**
90
+ * A horizontally-positioned ruleX mark (a vertical line, |). The **x**
91
+ * channel specifies the rule’s horizontal position and defaults to identity,
92
+ * assuming that *data* = [*x₀*, *x₁*, *x₂*, …]; the optional **y1** and
93
+ * **y2** channels specify its vertical extent.
94
+ *
95
+ * The ruleX mark is often used to highlight specific *x* values.
96
+ * If *y* represents ordinal values, use a tickX mark instead.
97
+ */
98
+ mark: 'ruleX';
99
+ }
100
+
101
+ /** The ruleY mark. */
102
+ export interface RuleY extends MarkDataOptional, RuleXOptions {
103
+ /**
104
+ * A vertically-positioned ruleY mark (a horizontal line, —). The **y**
105
+ * channel specifies the rule's vertical position and defaults to identity,
106
+ * assuming that *data* = [*y₀*, *y₁*, *y₂*, …]; the optional **x1** and
107
+ * **x2** channels specify its horizontal extent.
108
+ *
109
+ * The ruleY mark is often used to highlight specific *y* values.
110
+ * If *x* represents ordinal values, use a tickY mark instead.
111
+ */
112
+ mark: 'ruleY';
113
+ }
@@ -0,0 +1,122 @@
1
+ import { ParamRef } from '../Param.js';
2
+ import { FrameAnchor, Interval } from '../PlotTypes.js';
3
+ import {
4
+ ChannelValue, ChannelValueIntervalSpec, ChannelValueSpec,
5
+ MarkDataOptional, MarkOptions, TextStyles
6
+ } from './Marks.js';
7
+
8
+ /** Options for the text mark. */
9
+ export interface TextOptions extends MarkOptions, TextStyles {
10
+ /**
11
+ * The horizontal position channel specifying the text’s anchor point,
12
+ * typically bound to the *x* scale.
13
+ */
14
+ x?: ChannelValueSpec;
15
+
16
+ /**
17
+ * The vertical position channel specifying the text’s anchor point, typically
18
+ * bound to the *y* scale.
19
+ */
20
+ y?: ChannelValueSpec;
21
+
22
+ /**
23
+ * The text contents channel, possibly with line breaks (\n, \r\n, or \r). If
24
+ * not specified, defaults to the zero-based index [0, 1, 2, …].
25
+ */
26
+ text?: ChannelValue;
27
+
28
+ /**
29
+ * The frame anchor specifies defaults for **x** and **y**, along with
30
+ * **textAnchor** and **lineAnchor**, based on the plot’s frame; it may be one
31
+ * of the four sides (*top*, *right*, *bottom*, *left*), one of the four
32
+ * corners (*top-left*, *top-right*, *bottom-right*, *bottom-left*), or the
33
+ * *middle* of the frame.
34
+ */
35
+ frameAnchor?: FrameAnchor | ParamRef;
36
+
37
+ /**
38
+ * The line anchor controls how text is aligned (typically vertically)
39
+ * relative to its anchor point; it is one of *top*, *bottom*, or *middle*. If
40
+ * the frame anchor is *top*, *top-left*, or *top-right*, the default line
41
+ * anchor is *top*; if the frame anchor is *bottom*, *bottom-right*, or
42
+ * *bottom-left*, the default is *bottom*; otherwise it is *middle*.
43
+ */
44
+ lineAnchor?: 'top' | 'middle' | 'bottom' | ParamRef;
45
+
46
+ /**
47
+ * The rotation angle in degrees clockwise; a constant or a channel; defaults
48
+ * to 0°. When a number, it is interpreted as a constant; otherwise it is
49
+ * interpreted as a channel.
50
+ */
51
+ rotate?: ChannelValue | ParamRef;
52
+ }
53
+
54
+ /** Options for the textX mark. */
55
+ export interface TextXOptions extends Omit<TextOptions, 'y'> {
56
+ /**
57
+ * The vertical position of the text’s anchor point, typically bound to the
58
+ * *y* scale.
59
+ */
60
+ y?: ChannelValueIntervalSpec;
61
+
62
+ /**
63
+ * An interval (such as *day* or a number), to transform **y** values to the
64
+ * middle of the interval.
65
+ */
66
+ interval?: Interval | ParamRef;
67
+ }
68
+
69
+ /** Options for the textY mark. */
70
+ export interface TextYOptions extends Omit<TextOptions, 'x'> {
71
+ /**
72
+ * The horizontal position of the text’s anchor point, typically bound to the
73
+ * *x* scale.
74
+ */
75
+ x?: ChannelValueIntervalSpec;
76
+
77
+ /**
78
+ * An interval (such as *day* or a number), to transform **x** values to the
79
+ * middle of the interval.
80
+ */
81
+ interval?: Interval;
82
+ }
83
+
84
+ /** The text mark. */
85
+ export interface Text extends MarkDataOptional, TextOptions {
86
+ /**
87
+ * A text mark. The **text** channel specifies the textual contents of the
88
+ * mark, which may be preformatted with line breaks (\n, \r\n, or \r), or
89
+ * wrapped or clipped using the **lineWidth** and **textOverflow** options.
90
+ *
91
+ * If **text** contains numbers or dates, a default formatter will be
92
+ * applied, and the **fontVariant** will default to *tabular-nums* instead
93
+ * of *normal*. If **text** is not specified, it defaults to the identity
94
+ * function for primitive data (such as numbers, dates, and strings), and to
95
+ * the zero-based index [0, 1, 2, …] for objects (so that something
96
+ * identifying is visible by default).
97
+ *
98
+ * If either **x** or **y** is not specified, the default is determined by
99
+ * the **frameAnchor** option.
100
+ */
101
+ mark: 'text';
102
+ }
103
+
104
+ /** The textX mark. */
105
+ export interface TextX extends MarkDataOptional, TextXOptions {
106
+ /**
107
+ * Like text, but **x** defaults to the identity function, assuming that
108
+ * *data* = [*x₀*, *x₁*, *x₂*, …]. If an **interval** is specified, such as
109
+ * *day*, **y** is transformed to the middle of the interval.
110
+ */
111
+ mark: 'textX';
112
+ }
113
+
114
+ /** The textY mark. */
115
+ export interface TextY extends MarkDataOptional, TextYOptions {
116
+ /**
117
+ * Like text, but **y** defaults to the identity function, assuming that
118
+ * *data* = [*y₀*, *y₁*, *y₂*, …]. If an **interval** is specified, such as
119
+ * *day*, **x** is transformed to the middle of the interval.
120
+ */
121
+ mark: 'textY';
122
+ }
@@ -0,0 +1,69 @@
1
+ import {
2
+ ChannelValueSpec, InsetOptions, MarkData, MarkOptions, MarkerOptions
3
+ } from './Marks.js';
4
+
5
+ /** Options for the tickX mark. */
6
+ export interface TickXOptions extends MarkOptions, MarkerOptions, Omit<InsetOptions, 'insetLeft' | 'insetRight'> {
7
+ /**
8
+ * The required horizontal position of the tick; a channel typically bound to
9
+ * the *x* scale.
10
+ */
11
+ x?: ChannelValueSpec;
12
+
13
+ /**
14
+ * The optional vertical position of the tick; an ordinal channel typically
15
+ * bound to the *y* scale. If not specified, the tick spans the vertical
16
+ * extent of the frame; otherwise the *y* scale must be a *band* scale.
17
+ *
18
+ * If *y* represents quantitative or temporal values, use a ruleX mark
19
+ * instead.
20
+ */
21
+ y?: ChannelValueSpec;
22
+ }
23
+
24
+ /** Options for the tickY mark. */
25
+ export interface TickYOptions extends MarkOptions, MarkerOptions, Omit<InsetOptions, 'insetTop' | 'insetBottom'> {
26
+ /**
27
+ * The required vertical position of the tick; a channel typically bound to
28
+ * the *y* scale.
29
+ */
30
+ y?: ChannelValueSpec;
31
+
32
+ /**
33
+ * The optional horizontal position of the tick; an ordinal channel typically
34
+ * bound to the *x* scale. If not specified, the tick spans the horizontal
35
+ * extent of the frame; otherwise the *x* scale must be a *band* scale.
36
+ *
37
+ * If *x* represents quantitative or temporal values, use a ruleY mark
38
+ * instead.
39
+ */
40
+ x?: ChannelValueSpec;
41
+ }
42
+
43
+ /** The tickX mark. */
44
+ export interface TickX extends MarkData, TickXOptions {
45
+ /**
46
+ * A horizontally-positioned tickX mark (a vertical line, |). The **x**
47
+ * channel specifies the tick’s horizontal position and defaults to identity,
48
+ * assuming that *data* = [*x₀*, *x₁*, *x₂*, …]; the optional **y** ordinal
49
+ * channel specifies its vertical position.
50
+ *
51
+ * If *y* represents quantitative or temporal values, use a ruleX mark
52
+ * instead.
53
+ */
54
+ mark: 'tickX';
55
+ }
56
+
57
+ /** The tickY mark. */
58
+ export interface TickY extends MarkData, TickYOptions {
59
+ /**
60
+ * A vertically-positioned tickY mark (a horizontal line, —). The **y**
61
+ * channel specifies the tick's vertical position and defaults to identity,
62
+ * assuming that *data* = [*y₀*, *y₁*, *y₂*, …]; the optional **x** ordinal
63
+ * channel specifies its horizontal position.
64
+ *
65
+ * If *x* represents quantitative or temporal values, use a ruleY mark
66
+ * instead.
67
+ */
68
+ mark: 'tickY';
69
+ }