@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,65 @@
1
+ import { ParamRef } from '../Param.js';
2
+
3
+ /** Options for pan/zoom interactors. */
4
+ export interface PanZoomOptions {
5
+ /**
6
+ * The output selection for the `x` domain.
7
+ * A clause of the form `field BETWEEN x1 AND x2` is added for the
8
+ * current pan/zom interval [x1, x2].
9
+ */
10
+ x?: ParamRef;
11
+ /**
12
+ * The output selection for the `y` domain.
13
+ * A clause of the form `field BETWEEN y1 AND y2` is added for the
14
+ * current pan/zom interval [y1, y2].
15
+ */
16
+ y?: ParamRef;
17
+ /**
18
+ * The name of the field (database column) over which the `x`-component
19
+ * of the pan/zoom interval should be defined. If unspecified, the `x`
20
+ * channel field of the first valid prior mark definition is used.
21
+ */
22
+ xfield?: string;
23
+ /**
24
+ * The name of the field (database column) over which the `y`-component
25
+ * of the pan/zoom interval should be defined. If unspecified, the `y`
26
+ * channel field of the first valid prior mark definition is used.
27
+ */
28
+ yfield?: string;
29
+ }
30
+
31
+ /** A pan interactor. */
32
+ export interface Pan extends PanZoomOptions {
33
+ /** Pan a plot along both the `x` and `y` scales. */
34
+ select: 'pan';
35
+ }
36
+
37
+ /** A panX interactor. */
38
+ export interface PanX extends PanZoomOptions {
39
+ /** Pan a plot along the `x` scale only. */
40
+ select: 'panX';
41
+ }
42
+
43
+ /** A panY interactor. */
44
+ export interface PanY extends PanZoomOptions {
45
+ /** Pan a plot along the `y` scale only. */
46
+ select: 'panY';
47
+ }
48
+
49
+ /** A panZoom interactor. */
50
+ export interface PanZoom extends PanZoomOptions {
51
+ /** Pan and zoom a plot along both the `x` and `y` scales. */
52
+ select: 'panZoom';
53
+ }
54
+
55
+ /** A panZoomX interactor. */
56
+ export interface PanZoomX extends PanZoomOptions {
57
+ /** Pan and zoom a plot along the `x` scale only. */
58
+ select: 'panZoomX';
59
+ }
60
+
61
+ /** A panZoomY interactor. */
62
+ export interface PanZoomY extends PanZoomOptions {
63
+ /** Pan and zoom a plot along the `y` scale only. */
64
+ select: 'panZoomY';
65
+ }
@@ -0,0 +1,56 @@
1
+ import { ParamRef } from '../Param.js';
2
+
3
+ /** Options for toggle interactors. */
4
+ export interface ToggleOptions {
5
+ /**
6
+ * The output selection. A clause of the form
7
+ * `(field = value1) OR (field = value2) ...`
8
+ * is added for the currently selected values.
9
+ */
10
+ as: ParamRef;
11
+ /**
12
+ * A flag indicating if peer (sibling) marks are when cross-filtering
13
+ * (default `true`). If set, peer marks will not be filtered by this
14
+ * interactor's selection in cross-filtering setups.
15
+ */
16
+ peers?: boolean;
17
+ }
18
+
19
+ /** A toggle interactor. */
20
+ export interface Toggle extends ToggleOptions {
21
+ /** Select individal values. */
22
+ select: 'toggle';
23
+ /**
24
+ * The encoding channels over which to select values.
25
+ * For a selected mark, selection clauses will cover
26
+ * the backing data fields for each channel.
27
+ */
28
+ channels: string[];
29
+ }
30
+
31
+ /** A toggleX interactor. */
32
+ export interface ToggleX extends ToggleOptions {
33
+ /**
34
+ * Select individal values in the `x` scale domain.
35
+ * Clicking or touching a mark toggles its selection status.
36
+ */
37
+ select: 'toggleX';
38
+ }
39
+
40
+ /** A toggleY interactor. */
41
+ export interface ToggleY extends ToggleOptions {
42
+ /**
43
+ * Select individal values in the `y` scale domain.
44
+ * Clicking or touching a mark toggles its selection status.
45
+ */
46
+ select: 'toggleY';
47
+ }
48
+
49
+ /** A toggleColor interactor. */
50
+ export interface ToggleColor extends ToggleOptions {
51
+ /**
52
+ * Select individal values in the `color` scale domain.
53
+ * Clicking or touching a mark toggles its selection status.
54
+ */
55
+ select: 'toggleColor';
56
+ }
@@ -0,0 +1,154 @@
1
+ import {
2
+ ChannelValue, ChannelValueSpec, CurveOptions,
3
+ MarkData, MarkOptions, StackOptions
4
+ } from './Marks.js';
5
+
6
+ /** Options for the area, areaX, and areaY marks. */
7
+ export interface AreaOptions extends MarkOptions, StackOptions, CurveOptions {
8
+ /**
9
+ * The required primary (starting, often left) horizontal position channel,
10
+ * representing the area’s baseline, typically bound to the *x* scale. For
11
+ * areaX, setting this option disables the implicit stackX transform.
12
+ */
13
+ x1?: ChannelValueSpec;
14
+
15
+ /**
16
+ * The optional secondary (ending, often right) horizontal position channel,
17
+ * representing the area’s topline, typically bound to the *x* scale; if not
18
+ * specified, **x1** is used. For areaX, setting this option disables the
19
+ * implicit stackX transform.
20
+ */
21
+ x2?: ChannelValueSpec;
22
+
23
+ /**
24
+ * The required primary (starting, often bottom) vertical position channel,
25
+ * representing the area’s baseline, typically bound to the *y* scale. For
26
+ * areaY, setting this option disables the implicit stackY transform.
27
+ */
28
+ y1?: ChannelValueSpec;
29
+
30
+ /**
31
+ * The optional secondary (ending, often top) vertical position channel,
32
+ * representing the area’s topline, typically bound to the *y* scale; if not
33
+ * specified, **y1** is used. For areaY, setting this option disables the
34
+ * implicit stackY transform.
35
+ */
36
+ y2?: ChannelValueSpec;
37
+
38
+ /**
39
+ * An optional ordinal channel for grouping data into (possibly stacked)
40
+ * series to be drawn as separate areas; defaults to **fill** if a channel, or
41
+ * **stroke** if a channel.
42
+ */
43
+ z?: ChannelValue;
44
+ }
45
+
46
+ /** Options for the areaX mark. */
47
+ export interface AreaXOptions extends Omit<AreaOptions, 'y1' | 'y2'> {
48
+ /**
49
+ * The horizontal position (or length) channel, typically bound to the *x*
50
+ * scale.
51
+ *
52
+ * If neither **x1** nor **x2** is specified, an implicit stackX transform is
53
+ * applied and **x** defaults to the identity function, assuming that *data* =
54
+ * [*x₀*, *x₁*, *x₂*, …]. Otherwise, if only one of **x1** or **x2** is
55
+ * specified, the other defaults to **x**, which defaults to zero.
56
+ */
57
+ x?: ChannelValueSpec;
58
+
59
+ /**
60
+ * The vertical position channel, typically bound to the *y* scale; defaults
61
+ * to the zero-based index of the data [0, 1, 2, …].
62
+ */
63
+ y?: ChannelValueSpec;
64
+ }
65
+
66
+ /** Options for the areaY mark. */
67
+ export interface AreaYOptions extends Omit<AreaOptions, 'x1' | 'x2'> {
68
+ /**
69
+ * The horizontal position channel, typically bound to the *x* scale; defaults
70
+ * to the zero-based index of the data [0, 1, 2, …].
71
+ */
72
+ x?: ChannelValueSpec;
73
+
74
+ /**
75
+ * The vertical position (or length) channel, typically bound to the *y*
76
+ * scale.
77
+ *
78
+ * If neither **y1** nor **y2** is specified, an implicit stackY transform is
79
+ * applied and **y** defaults to the identity function, assuming that *data* =
80
+ * [*y₀*, *y₁*, *y₂*, …]. Otherwise, if only one of **y1** or **y2** is
81
+ * specified, the other defaults to **y**, which defaults to zero.
82
+ */
83
+ y?: ChannelValueSpec;
84
+ }
85
+
86
+ /** The area mark. */
87
+ export interface Area extends MarkData, AreaOptions {
88
+ /**
89
+ * An area mark. The area mark is rarely used directly; it is only needed
90
+ * when the baseline and topline have neither *x* nor *y* values in common.
91
+ * Use areaY for a horizontal orientation where the baseline and topline
92
+ * share *x* values, or areaX for a vertical orientation where the baseline
93
+ * and topline share *y* values.
94
+ */
95
+ mark: 'area';
96
+ }
97
+
98
+ /** The areaX mark. */
99
+ export interface AreaX extends MarkData, AreaXOptions {
100
+ /**
101
+ * A vertically-oriented area mark, where the baseline and topline share
102
+ * **y** values, as in a time-series area chart where time goes up↑.
103
+ *
104
+ * If neither **x1** nor **x2** is specified, an implicit stackX transform is
105
+ * applied and **x** defaults to the identity function, assuming that *data* =
106
+ * [*x₀*, *x₁*, *x₂*, …]. Otherwise, if only one of **x1** or **x2** is
107
+ * specified, the other defaults to **x**, which defaults to zero.
108
+ *
109
+ * If an **interval** is specified, **y** values are binned accordingly,
110
+ * allowing zeroes for empty bins instead of interpolating across gaps. This is
111
+ * recommended to “regularize” sampled data; for example, if your data
112
+ * represents timestamped observations and you expect one observation per day,
113
+ * use *day* as the **interval**.
114
+ *
115
+ * Variable aesthetic channels are supported: if the **fill** is defined as a
116
+ * channel, the area will be broken into contiguous overlapping sections when
117
+ * the fill color changes; the fill color will apply to the interval spanning
118
+ * the current data point and the following data point. This behavior also
119
+ * applies to the **fillOpacity**, **stroke**, **strokeOpacity**,
120
+ * **strokeWidth**, **opacity**, **href**, **title**, and **ariaLabel**
121
+ * channels. When any of these channels are used, setting an explicit **z**
122
+ * channel (possibly to null) is strongly recommended.
123
+ */
124
+ mark: 'areaX';
125
+ }
126
+
127
+ /** The areaY mark. */
128
+ export interface AreaY extends MarkData, AreaYOptions {
129
+ /**
130
+ * A horizontally-oriented area mark, where the baseline and topline share
131
+ * **x** values, as in a time-series area chart where time goes right→.
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
+ * If an **interval** is specified, **x** values are binned accordingly,
139
+ * allowing zeroes for empty bins instead of interpolating across gaps. This is
140
+ * recommended to “regularize” sampled data; for example, if your data
141
+ * represents timestamped observations and you expect one observation per day,
142
+ * use *day* as the **interval**.
143
+ *
144
+ * Variable aesthetic channels are supported: if the **fill** is defined as a
145
+ * channel, the area will be broken into contiguous overlapping sections when
146
+ * the fill color changes; the fill color will apply to the interval spanning
147
+ * the current data point and the following data point. This behavior also
148
+ * applies to the **fillOpacity**, **stroke**, **strokeOpacity**,
149
+ * **strokeWidth**, **opacity**, **href**, **title**, and **ariaLabel**
150
+ * channels. When any of these channels are used, setting an explicit **z**
151
+ * channel (possibly to null) is strongly recommended.
152
+ */
153
+ mark: 'areaY';
154
+ }
@@ -0,0 +1,108 @@
1
+ import { ParamRef } from '../Param.js';
2
+ import { ChannelValueSpec, MarkData, MarkOptions } from './Marks.js';
3
+
4
+ /** Options for the arrow mark. */
5
+ export interface ArrowOptions extends MarkOptions {
6
+ /**
7
+ * The horizontal position, for vertical arrows; typically bound to the *x*
8
+ * scale; shorthand for setting defaults for both **x1** and **x2**.
9
+ */
10
+ x?: ChannelValueSpec;
11
+
12
+ /**
13
+ * The vertical position, for horizontal arrows; typically bound to the *y*
14
+ * scale; shorthand for setting defaults for both **y1** and **y2**.
15
+ */
16
+ y?: ChannelValueSpec;
17
+
18
+ /**
19
+ * The starting horizontal position; typically bound to the *x* scale; also
20
+ * sets a default for **x2**.
21
+ */
22
+ x1?: ChannelValueSpec;
23
+
24
+ /**
25
+ * The starting vertical position; typically bound to the *y* scale; also
26
+ * sets a default for **y2**.
27
+ */
28
+ y1?: ChannelValueSpec;
29
+
30
+ /**
31
+ * The ending horizontal position; typically bound to the *x* scale; also
32
+ * sets a default for **x1**.
33
+ */
34
+ x2?: ChannelValueSpec;
35
+
36
+ /**
37
+ * The ending vertical position; typically bound to the *y* scale; also sets
38
+ * a default for **y1**.
39
+ */
40
+ y2?: ChannelValueSpec;
41
+
42
+ /**
43
+ * The angle, a constant in degrees, between the straight line intersecting
44
+ * the arrow’s two control points and the outgoing tangent direction of the
45
+ * arrow from the start point. The angle must be within ±90°; a positive
46
+ * angle will produce a clockwise curve, while a negative angle will produce
47
+ * a counterclockwise curve; zero (the default) will produce a straight line.
48
+ * Use true for 22.5°.
49
+ */
50
+ bend?: number | boolean | ParamRef;
51
+
52
+ /**
53
+ * How pointy the arrowhead is, in degrees; a constant typically between 0°
54
+ * and 180°, and defaults to 60°.
55
+ */
56
+ headAngle?: number | ParamRef;
57
+
58
+ /**
59
+ * The size of the arrowhead relative to the **strokeWidth**; a constant.
60
+ * Assuming the default of stroke width 1.5px, this is the length of the
61
+ * arrowhead’s side in pixels.
62
+ */
63
+ headLength?: number | ParamRef;
64
+
65
+ /**
66
+ * Shorthand to set the same default for **insetStart** and **insetEnd**.
67
+ */
68
+ inset?: number | ParamRef;
69
+
70
+ /**
71
+ * The starting inset, a constant in pixels; defaults to 0. A positive inset
72
+ * shortens the arrow by moving the starting point towards the endpoint
73
+ * point, while a negative inset extends it by moving the starting point in
74
+ * the opposite direction. A positive starting inset may be useful if the
75
+ * arrow emerges from a dot.
76
+ */
77
+ insetStart?: number | ParamRef;
78
+
79
+ /**
80
+ * The ending inset, a constant in pixels; defaults to 0. A positive inset
81
+ * shortens the arrow by moving the ending point towards the starting point,
82
+ * while a negative inset extends it by moving the ending point in the
83
+ * opposite direction. A positive ending inset may be useful if the arrow
84
+ * points to a dot.
85
+ */
86
+ insetEnd?: number | ParamRef;
87
+
88
+ /**
89
+ * The sweep order; defaults to 1 indicating a positive (clockwise) bend
90
+ * angle; -1 indicates a negative (anticlockwise) bend angle; 0 effectively
91
+ * clears the bend angle. If set to *-x*, the bend angle is flipped when the
92
+ * ending point is to the left of the starting point — ensuring all arrows
93
+ * bulge up (down if bend is negative); if set to *-y*, the bend angle is
94
+ * flipped when the ending point is above the starting point — ensuring all
95
+ * arrows bulge right (left if bend is negative); the sign is negated for
96
+ * *+x* and *+y*.
97
+ */
98
+ sweep?: number | '+x' | '-x' | '+y' | '-y' | ParamRef;
99
+ }
100
+
101
+ /** The arrow mark. */
102
+ export interface Arrow extends MarkData, ArrowOptions {
103
+ /**
104
+ * An arrow mark, drawing (possibly swoopy) arrows connecting pairs of
105
+ * points.
106
+ */
107
+ mark: 'arrow';
108
+ }
@@ -0,0 +1,305 @@
1
+ import { ParamRef } from '../Param.js';
2
+ import { Interval } from '../PlotTypes.js';
3
+ import { MarkOptions } from './Marks.js';
4
+ import { RuleXOptions, RuleYOptions } from './Rule.js';
5
+ import { TextOptions } from './Text.js';
6
+ import { TickXOptions, TickYOptions } from './Tick.js';
7
+
8
+ /** The scale options used by axis and grid marks. */
9
+ interface ScaleOptions {
10
+ /**
11
+ * Enforces uniformity for data at regular intervals, such as integer values
12
+ * or daily samples. The interval may be one of:
13
+ *
14
+ * - a named time interval such as *day* (for date intervals)
15
+ * - a number (for number intervals), defining intervals at integer multiples of *n*
16
+ *
17
+ * This option sets the internal transform to the given interval’s
18
+ * *interval*.floor function. In addition, the default **domain** will align
19
+ * with interval boundaries.
20
+ */
21
+ interval?: Interval | ParamRef;
22
+
23
+ /**
24
+ * The desired approximate number of axis ticks, or an explicit array of tick
25
+ * values, or an interval such as *day* or *month*.
26
+ */
27
+ ticks?: number | Interval | any[] | ParamRef;
28
+
29
+ /**
30
+ * The length of axis tick marks in pixels; negative values extend in the
31
+ * opposite direction. Defaults to 6 for *x* and *y* axes and *color* and
32
+ * *opacity* *ramp* legends, and 0 for *fx* and *fy* axes.
33
+ */
34
+ tickSize?: number | ParamRef;
35
+
36
+ /**
37
+ * The desired approximate spacing between adjacent axis ticks, affecting the
38
+ * default **ticks**; defaults to 80 pixels for *x* and *fx*, and 35 pixels
39
+ * for *y* and *fy*.
40
+ */
41
+ tickSpacing?: number | ParamRef;
42
+
43
+ /**
44
+ * The distance between an axis tick mark and its associated text label (in
45
+ * pixels); often defaults to 3, but may be affected by **xTickSize** and
46
+ * **xTickRotate**.
47
+ */
48
+ tickPadding?: number | ParamRef;
49
+
50
+ /**
51
+ * How to format inputs (abstract values) for axis tick labels; one of:
52
+ *
53
+ * - a [d3-format][1] string for numeric scales
54
+ * - a [d3-time-format][2] string for temporal scales
55
+ *
56
+ * [1]: https://d3js.org/d3-time
57
+ * [2]: https://d3js.org/d3-time-format
58
+ */
59
+ tickFormat?: string | null | ParamRef;
60
+
61
+ /**
62
+ * The rotation angle of axis tick labels in degrees clocksize; defaults to 0.
63
+ */
64
+ tickRotate?: number | ParamRef;
65
+
66
+ /**
67
+ * A textual label to show on the axis or legend; if null, show no label. By
68
+ * default the scale label is inferred from channel definitions, possibly with
69
+ * an arrow (↑, →, ↓, or ←) to indicate the direction of increasing value.
70
+ *
71
+ * For axes and legends only.
72
+ */
73
+ label?: string | null | ParamRef;
74
+
75
+ /**
76
+ * Where to place the axis **label** relative to the plot’s frame. For
77
+ * vertical position scales (*y* and *fy*), may be *top*, *bottom*, or
78
+ * *center*; for horizontal position scales (*x* and *fx*), may be *left*,
79
+ * *right*, or *center*. Defaults to *center* for ordinal scales (including
80
+ * *fx* and *fy*), and otherwise *top* for *y*, and *right* for *x*.
81
+ */
82
+ labelAnchor?: 'top' | 'right' | 'bottom' | 'left' | 'center' | ParamRef;
83
+
84
+ /**
85
+ * The axis **label** position offset (in pixels); default depends on margins
86
+ * and orientation.
87
+ */
88
+ labelOffset?: number | ParamRef;
89
+
90
+ /**
91
+ * Whether to apply a directional arrow such as → or ↑ to the scale label. If
92
+ * *auto* (the default), the presence of the arrow depends on whether the
93
+ * scale is ordinal.
94
+ */
95
+ labelArrow?: 'auto' | 'up' | 'right' | 'down' | 'left' | 'none' | true | false | null | ParamRef;
96
+ }
97
+
98
+ /** The subset of scale options for grids. */
99
+ type GridScaleOptions = Pick<ScaleOptions, 'interval' | 'ticks' | 'tickSpacing'>;
100
+
101
+ /** The subset of scale options for axes. */
102
+ type AxisScaleOptions = Pick<ScaleOptions, 'tickSize' | 'tickPadding' | 'tickFormat' | 'tickRotate' | 'label' | 'labelOffset' | 'labelAnchor' | 'labelArrow'>;
103
+
104
+ /** Options for the grid marks. */
105
+ export interface GridOptions extends GridScaleOptions {
106
+ /**
107
+ * The side of the frame on which to place the axis: *top* or *bottom* for
108
+ * horizontal axes (axisX and axisFx) and their associated vertical grids
109
+ * (gridX and gridFx), or *left* or *right* for vertical axes (axisY and
110
+ * axisFY) and their associated horizontal grids (gridY and gridFy).
111
+ *
112
+ * The default **anchor** depends on the associated scale:
113
+ *
114
+ * - *x* - *bottom*
115
+ * - *y* - *left*
116
+ * - *fx* - *top* if there is a *bottom* *x* axis, and otherwise *bottom*
117
+ * - *fy* - *right* if there is a *left* *y* axis, and otherwise *right*
118
+ *
119
+ * For grids, the **anchor** also affects the extent of grid lines when the
120
+ * opposite dimension is specified (**x** for gridY and **y** for gridX).
121
+ */
122
+ anchor?: 'top' | 'right' | 'bottom' | 'left' | ParamRef;
123
+
124
+ /**
125
+ * A shorthand for setting both **fill** and **stroke**; affects the stroke of
126
+ * tick vectors and grid rules, and the fill of tick texts and axis label
127
+ * texts; defaults to *currentColor*.
128
+ */
129
+ color?: MarkOptions['stroke'];
130
+
131
+ /**
132
+ * A shorthand for setting both **fillOpacity** and **strokeOpacity**; affects
133
+ * the stroke opacity of tick vectors and grid rules, and the fill opacity of
134
+ * tick texts and axis label texts; defaults to 1 for axes and 0.1 for grids.
135
+ */
136
+ opacity?: MarkOptions['opacity'];
137
+ }
138
+
139
+ /** Options for the axis marks. */
140
+ export interface AxisOptions extends GridOptions, MarkOptions, TextOptions, AxisScaleOptions {
141
+ /** The tick text **stroke**, say for a *white* outline to improve legibility; defaults to null. */
142
+ textStroke?: MarkOptions['stroke'];
143
+ /** The tick text **strokeOpacity**; defaults to 1; has no effect unless **textStroke** is set. */
144
+ textStrokeOpacity?: MarkOptions['strokeOpacity'];
145
+ /** The tick text **strokeWidth**; defaults to 4; has no effect unless **textStroke** is set. */
146
+ textStrokeWidth?: MarkOptions['strokeWidth'];
147
+ }
148
+
149
+ /** Options for the axisX and axisFx marks. */
150
+ export interface AxisXOptions extends AxisOptions, Omit<TickXOptions, 'data'> {}
151
+
152
+ /** Options for the axisY and axisFy marks. */
153
+ export interface AxisYOptions extends AxisOptions, Omit<TickYOptions, 'data'> {}
154
+
155
+ /** Options for the gridX and gridFx marks. */
156
+ export interface GridXOptions extends GridOptions, Omit<RuleXOptions, 'data' | 'interval'> {}
157
+
158
+ /** Options for the gridY and gridFy marks. */
159
+ export interface GridYOptions extends GridOptions, Omit<RuleYOptions, 'data' | 'interval'> {}
160
+
161
+ /** The axisX mark. */
162
+ export interface AxisX extends AxisXOptions {
163
+ /**
164
+ * An axis mark to document the visual encoding of the horizontal position
165
+ * *x* scale, comprised of (up to) three marks: a vector for ticks, a text
166
+ * for tick labels, and another text for an axis label. The data defaults to
167
+ * tick values sampled from the *x* scale’s domain; if desired, use one of
168
+ * the **ticks**, **tickSpacing**, or **interval** options.
169
+ *
170
+ * The **facetAnchor** option defaults to *bottom-empty* if **anchor** is
171
+ * *bottom*, and *top-empty* if **anchor** is *top*. The default margins
172
+ * likewise depend on **anchor** as follows; in order of **marginTop**,
173
+ * **marginRight**, **marginBottom**, and **marginLeft**, in pixels:
174
+ *
175
+ * - *top* - 30, 20, 0, 20
176
+ * - *bottom* - 0, 20, 30, 20
177
+ *
178
+ * For simplicity, and for consistent layout across plots, default axis margins
179
+ * are not affected by tick labels. If tick labels are too long, either increase
180
+ * the margin or shorten the labels: use the *k* SI-prefix tick format; use the
181
+ * **transform** *y*-scale option to show thousands or millions; or use the
182
+ * **textOverflow** and **lineWidth** options to clip.
183
+ */
184
+ mark: 'axisX';
185
+ }
186
+
187
+ /** The axisFx mark. */
188
+ export interface AxisFx extends AxisXOptions {
189
+ /**
190
+ * An axis mark to document the visual encoding of the horizontal facet
191
+ * position *fx* scale, comprised of (up to) three marks: a vector for ticks,
192
+ * a text for tick labels, and another text for an axis label. The data
193
+ * defaults to the *fx* scale’s domain; if desired, use one of the **ticks**,
194
+ * **tickSpacing**, or **interval** options.
195
+ *
196
+ * The **facetAnchor** and **frameAnchor** options defaults to **anchor**. The
197
+ * default margins likewise depend on **anchor** as follows; in order of
198
+ * **marginTop**, **marginRight**, **marginBottom**, and **marginLeft**, in
199
+ * pixels:
200
+ *
201
+ * - *top* - 30, 20, 0, 20
202
+ * - *bottom* - 0, 20, 30, 20
203
+ *
204
+ * For simplicity, and for consistent layout across plots, default axis margins
205
+ * are not affected by tick labels. If tick labels are too long, either increase
206
+ * the margin or shorten the labels: use the *k* SI-prefix tick format; use the
207
+ * **transform** *y*-scale option to show thousands or millions; or use the
208
+ * **textOverflow** and **lineWidth** options to clip.
209
+ */
210
+ mark: 'axisFx';
211
+ }
212
+
213
+ /** The axisY mark. */
214
+ export interface AxisY extends AxisYOptions {
215
+ /**
216
+ * An axis mark to document the visual encoding of the vertical position *y*
217
+ * scale, comprised of (up to) three marks: a vector for ticks, a text for
218
+ * tick labels, and another text for an axis label. The data defaults to tick
219
+ * values sampled from the *y* scale’s domain; if desired, use one of the
220
+ * **ticks**, **tickSpacing**, or **interval** options.
221
+ *
222
+ * The **facetAnchor** option defaults to *right-empty* if **anchor** is
223
+ * *right*, and *left-empty* if **anchor** is *left*. The default margins
224
+ * likewise depend on **anchor** as follows; in order of **marginTop**,
225
+ * **marginRight**, **marginBottom**, and **marginLeft**, in pixels:
226
+ *
227
+ * - *right* - 20, 40, 20, 0
228
+ * - *left* - 20, 0, 20, 40
229
+ *
230
+ * For simplicity, and for consistent layout across plots, default axis
231
+ * margins are not affected by tick labels. If tick labels are too long,
232
+ * either increase the margin or shorten the labels: use the *k* SI-prefix
233
+ * tick format; or use the **textOverflow** and **lineWidth** options to
234
+ * clip.
235
+ */
236
+ mark: 'axisY';
237
+ }
238
+
239
+ /** The axisFy mark. */
240
+ export interface AxisFy extends AxisYOptions {
241
+ /**
242
+ * An axis mark to document the visual encoding of the vertical facet
243
+ * position *fy* scale, comprised of (up to) three marks: a vector for ticks,
244
+ * a text for tick labels, and another text for an axis label. The data
245
+ * defaults to the *fy* scale’s domain; if desired, use one of the **ticks**,
246
+ * **tickSpacing**, or **interval** options.
247
+ *
248
+ * The **facetAnchor** option defaults to *right-empty* if **anchor** is
249
+ * *right*, and *left-empty* if **anchor** is *left*. The default margins
250
+ * likewise depend on **anchor** as follows; in order of **marginTop**,
251
+ * **marginRight**, **marginBottom**, and **marginLeft**, in pixels:
252
+ *
253
+ * - *right* - 20, 40, 20, 0
254
+ * - *left* - 20, 0, 20, 40
255
+ *
256
+ * For simplicity, and for consistent layout across plots, default axis
257
+ * margins are not affected by tick labels. If tick labels are too long,
258
+ * either increase the margin or shorten the labels: use the *k* SI-prefix
259
+ * tick format; or use the **textOverflow** and **lineWidth** options to
260
+ * clip.
261
+ */
262
+ mark: 'axisFy';
263
+ }
264
+
265
+ /** The gridX mark. */
266
+ export interface GridX extends GridXOptions {
267
+ /**
268
+ * A horizontally-positioned ruleX mark (a vertical line, |) that renders a
269
+ * grid for the *x* scale. The data defaults to tick values sampled from the
270
+ * *x* scale’s domain; if desired, use one of the **ticks**, **tickSpacing**,
271
+ * or **interval** options.
272
+ */
273
+ mark: 'gridX';
274
+ }
275
+
276
+ /** The gridFx mark. */
277
+ export interface GridFx extends GridXOptions {
278
+ /**
279
+ * A horizontally-positioned ruleX mark (a vertical line, |) that renders a
280
+ * grid for the *fx* scale. The data defaults to the *fx* scale’s domain;
281
+ * if desired, use the **ticks** option.
282
+ */
283
+ mark: 'gridFx';
284
+ }
285
+
286
+ /** The gridY mark. */
287
+ export interface GridY extends GridYOptions {
288
+ /**
289
+ * A vertically-positioned ruleY mark (a horizontal line, —) that renders a
290
+ * grid for the *y* scale. The data defaults to tick values sampled from the
291
+ * *y* scale’s domain; if desired, use one of the **ticks**, **tickSpacing**,
292
+ * or **interval** options.
293
+ */
294
+ mark: 'gridY';
295
+ }
296
+
297
+ /** The gridFy mark. */
298
+ export interface GridFy extends GridYOptions {
299
+ /**
300
+ * A vertically-positioned ruleY mark (a horizontal line, —) that renders a
301
+ * grid for the *fy* scale. The data defaults to the *fy* scale’s domain;
302
+ * if desired, use the **ticks** option.
303
+ */
304
+ mark: 'gridFy';
305
+ }