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