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