@motionscript/charts 0.1.0 → 0.1.1-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (215) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +98 -28
  3. package/dist/bar-chart/bar-chart.d.ts +242 -119
  4. package/dist/bar-chart/bar-chart.d.ts.map +1 -1
  5. package/dist/bar-chart/bar-chart.js +231 -260
  6. package/dist/bar-chart/bar-chart.js.map +1 -1
  7. package/dist/bar-chart/category-axis.d.ts +16 -38
  8. package/dist/bar-chart/category-axis.d.ts.map +1 -1
  9. package/dist/bar-chart/category-axis.js +59 -68
  10. package/dist/bar-chart/category-axis.js.map +1 -1
  11. package/dist/bar-chart/chart-bars.d.ts +60 -91
  12. package/dist/bar-chart/chart-bars.d.ts.map +1 -1
  13. package/dist/bar-chart/chart-bars.js +88 -125
  14. package/dist/bar-chart/chart-bars.js.map +1 -1
  15. package/dist/bar-chart/index.d.ts +5 -13
  16. package/dist/bar-chart/index.d.ts.map +1 -1
  17. package/dist/bar-chart/index.js +2 -9
  18. package/dist/bar-chart/index.js.map +1 -1
  19. package/dist/bar-chart/shared.d.ts +40 -132
  20. package/dist/bar-chart/shared.d.ts.map +1 -1
  21. package/dist/bar-chart/shared.js +70 -158
  22. package/dist/bar-chart/shared.js.map +1 -1
  23. package/dist/browser/chunks/chunk-R3Q5EE6E.js +2 -0
  24. package/dist/browser/chunks/chunk-R3Q5EE6E.js.map +7 -0
  25. package/dist/browser/index.js +1 -1
  26. package/dist/browser/index.js.map +4 -4
  27. package/dist/browser/kit.js +1 -1
  28. package/dist/browser/manifest.json +1 -1
  29. package/dist/engine.d.ts +8 -17
  30. package/dist/engine.d.ts.map +1 -1
  31. package/dist/engine.js +8 -17
  32. package/dist/engine.js.map +1 -1
  33. package/dist/index.d.ts +2 -0
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +2 -0
  36. package/dist/index.js.map +1 -1
  37. package/dist/kit/cartesian.d.ts +49 -35
  38. package/dist/kit/cartesian.d.ts.map +1 -1
  39. package/dist/kit/cartesian.js +80 -42
  40. package/dist/kit/cartesian.js.map +1 -1
  41. package/dist/kit/chart-canvas.d.ts +37 -40
  42. package/dist/kit/chart-canvas.d.ts.map +1 -1
  43. package/dist/kit/chart-canvas.js +53 -47
  44. package/dist/kit/chart-canvas.js.map +1 -1
  45. package/dist/kit/chart-legend.d.ts +16 -59
  46. package/dist/kit/chart-legend.d.ts.map +1 -1
  47. package/dist/kit/chart-legend.js +38 -76
  48. package/dist/kit/chart-legend.js.map +1 -1
  49. package/dist/kit/entries.d.ts +2 -0
  50. package/dist/kit/entries.d.ts.map +1 -1
  51. package/dist/kit/entries.js +2 -0
  52. package/dist/kit/entries.js.map +1 -1
  53. package/dist/kit/horizontal-axis.d.ts +77 -0
  54. package/dist/kit/horizontal-axis.d.ts.map +1 -0
  55. package/dist/kit/horizontal-axis.js +99 -0
  56. package/dist/kit/horizontal-axis.js.map +1 -0
  57. package/dist/kit/motion.d.ts +16 -3
  58. package/dist/kit/motion.d.ts.map +1 -1
  59. package/dist/kit/motion.js +15 -1
  60. package/dist/kit/motion.js.map +1 -1
  61. package/dist/{pie-chart → kit}/pie-legend.d.ts +14 -29
  62. package/dist/kit/pie-legend.d.ts.map +1 -0
  63. package/dist/kit/pie-legend.js +93 -0
  64. package/dist/kit/pie-legend.js.map +1 -0
  65. package/dist/kit/polar.d.ts +31 -0
  66. package/dist/kit/polar.d.ts.map +1 -0
  67. package/dist/kit/polar.js +33 -0
  68. package/dist/kit/polar.js.map +1 -0
  69. package/dist/kit/shared.d.ts +60 -214
  70. package/dist/kit/shared.d.ts.map +1 -1
  71. package/dist/kit/shared.js +91 -291
  72. package/dist/kit/shared.js.map +1 -1
  73. package/dist/kit/style.d.ts +254 -0
  74. package/dist/kit/style.d.ts.map +1 -0
  75. package/dist/kit/style.js +197 -0
  76. package/dist/kit/style.js.map +1 -0
  77. package/dist/kit/vertical-axis.d.ts +36 -45
  78. package/dist/kit/vertical-axis.d.ts.map +1 -1
  79. package/dist/kit/vertical-axis.js +69 -81
  80. package/dist/kit/vertical-axis.js.map +1 -1
  81. package/dist/line-chart/chart-line.d.ts +107 -40
  82. package/dist/line-chart/chart-line.d.ts.map +1 -1
  83. package/dist/line-chart/chart-line.js +172 -89
  84. package/dist/line-chart/chart-line.js.map +1 -1
  85. package/dist/line-chart/chart-region.d.ts +14 -27
  86. package/dist/line-chart/chart-region.d.ts.map +1 -1
  87. package/dist/line-chart/chart-region.js +13 -28
  88. package/dist/line-chart/chart-region.js.map +1 -1
  89. package/dist/line-chart/index.d.ts +5 -18
  90. package/dist/line-chart/index.d.ts.map +1 -1
  91. package/dist/line-chart/index.js +3 -16
  92. package/dist/line-chart/index.js.map +1 -1
  93. package/dist/line-chart/line-chart.d.ts +272 -119
  94. package/dist/line-chart/line-chart.d.ts.map +1 -1
  95. package/dist/line-chart/line-chart.js +309 -257
  96. package/dist/line-chart/line-chart.js.map +1 -1
  97. package/dist/line-chart/shared.d.ts +73 -130
  98. package/dist/line-chart/shared.d.ts.map +1 -1
  99. package/dist/line-chart/shared.js +195 -156
  100. package/dist/line-chart/shared.js.map +1 -1
  101. package/dist/line-chart/x-scale.d.ts +16 -55
  102. package/dist/line-chart/x-scale.d.ts.map +1 -1
  103. package/dist/line-chart/x-scale.js +44 -111
  104. package/dist/line-chart/x-scale.js.map +1 -1
  105. package/dist/nodes.d.ts +3 -13
  106. package/dist/nodes.d.ts.map +1 -1
  107. package/dist/nodes.js +9 -13
  108. package/dist/nodes.js.map +1 -1
  109. package/dist/pie-chart/index.d.ts +3 -15
  110. package/dist/pie-chart/index.d.ts.map +1 -1
  111. package/dist/pie-chart/index.js +1 -11
  112. package/dist/pie-chart/index.js.map +1 -1
  113. package/dist/pie-chart/pie-chart.d.ts +147 -85
  114. package/dist/pie-chart/pie-chart.d.ts.map +1 -1
  115. package/dist/pie-chart/pie-chart.js +65 -86
  116. package/dist/pie-chart/pie-chart.js.map +1 -1
  117. package/dist/pie-chart/pie-ring.d.ts +65 -196
  118. package/dist/pie-chart/pie-ring.d.ts.map +1 -1
  119. package/dist/pie-chart/pie-ring.js +154 -292
  120. package/dist/pie-chart/pie-ring.js.map +1 -1
  121. package/dist/pie-chart/shared.d.ts +78 -172
  122. package/dist/pie-chart/shared.d.ts.map +1 -1
  123. package/dist/pie-chart/shared.js +54 -177
  124. package/dist/pie-chart/shared.js.map +1 -1
  125. package/dist/radar-chart/index.d.ts +5 -0
  126. package/dist/radar-chart/index.d.ts.map +1 -0
  127. package/dist/radar-chart/index.js +5 -0
  128. package/dist/radar-chart/index.js.map +1 -0
  129. package/dist/radar-chart/radar-chart.d.ts +218 -0
  130. package/dist/radar-chart/radar-chart.d.ts.map +1 -0
  131. package/dist/radar-chart/radar-chart.js +224 -0
  132. package/dist/radar-chart/radar-chart.js.map +1 -0
  133. package/dist/radar-chart/radar-grid.d.ts +43 -0
  134. package/dist/radar-chart/radar-grid.d.ts.map +1 -0
  135. package/dist/radar-chart/radar-grid.js +61 -0
  136. package/dist/radar-chart/radar-grid.js.map +1 -0
  137. package/dist/radar-chart/radar-series.d.ts +59 -0
  138. package/dist/radar-chart/radar-series.d.ts.map +1 -0
  139. package/dist/radar-chart/radar-series.js +71 -0
  140. package/dist/radar-chart/radar-series.js.map +1 -0
  141. package/dist/radar-chart/shared.d.ts +73 -0
  142. package/dist/radar-chart/shared.d.ts.map +1 -0
  143. package/dist/radar-chart/shared.js +123 -0
  144. package/dist/radar-chart/shared.js.map +1 -0
  145. package/dist/radial-chart/index.d.ts +6 -0
  146. package/dist/radial-chart/index.d.ts.map +1 -0
  147. package/dist/radial-chart/index.js +4 -0
  148. package/dist/radial-chart/index.js.map +1 -0
  149. package/dist/radial-chart/radial-chart.d.ts +216 -0
  150. package/dist/radial-chart/radial-chart.d.ts.map +1 -0
  151. package/dist/radial-chart/radial-chart.js +174 -0
  152. package/dist/radial-chart/radial-chart.js.map +1 -0
  153. package/dist/radial-chart/radial-rings.d.ts +121 -0
  154. package/dist/radial-chart/radial-rings.d.ts.map +1 -0
  155. package/dist/radial-chart/radial-rings.js +273 -0
  156. package/dist/radial-chart/radial-rings.js.map +1 -0
  157. package/dist/radial-chart/shared.d.ts +73 -0
  158. package/dist/radial-chart/shared.d.ts.map +1 -0
  159. package/dist/radial-chart/shared.js +79 -0
  160. package/dist/radial-chart/shared.js.map +1 -0
  161. package/package.json +4 -4
  162. package/registry.json +21 -6
  163. package/src/bar-chart/bar-chart.ts +274 -315
  164. package/src/bar-chart/category-axis.ts +53 -88
  165. package/src/bar-chart/chart-bars.ts +108 -205
  166. package/src/bar-chart/index.ts +8 -19
  167. package/src/bar-chart/shared.ts +81 -309
  168. package/src/engine.ts +8 -17
  169. package/src/index.ts +2 -0
  170. package/src/kit/cartesian.ts +118 -55
  171. package/src/kit/chart-canvas.ts +50 -80
  172. package/src/kit/chart-legend.ts +36 -97
  173. package/src/kit/entries.ts +4 -1
  174. package/src/kit/horizontal-axis.ts +114 -0
  175. package/src/kit/motion.ts +18 -2
  176. package/src/{pie-chart → kit}/pie-legend.ts +25 -65
  177. package/src/kit/polar.ts +54 -0
  178. package/src/kit/shared.ts +104 -487
  179. package/src/kit/style.ts +257 -0
  180. package/src/kit/vertical-axis.ts +81 -115
  181. package/src/line-chart/chart-line.ts +185 -91
  182. package/src/line-chart/chart-region.ts +14 -31
  183. package/src/line-chart/index.ts +14 -22
  184. package/src/line-chart/line-chart.ts +377 -315
  185. package/src/line-chart/shared.ts +229 -304
  186. package/src/line-chart/x-scale.ts +44 -121
  187. package/src/nodes.ts +9 -13
  188. package/src/pie-chart/index.ts +3 -35
  189. package/src/pie-chart/pie-chart.ts +83 -134
  190. package/src/pie-chart/pie-ring.ts +162 -368
  191. package/src/pie-chart/shared.ts +92 -379
  192. package/src/radar-chart/index.ts +4 -0
  193. package/src/radar-chart/radar-chart.ts +287 -0
  194. package/src/radar-chart/radar-grid.ts +78 -0
  195. package/src/radar-chart/radar-series.ts +88 -0
  196. package/src/radar-chart/shared.ts +146 -0
  197. package/src/radial-chart/index.ts +5 -0
  198. package/src/radial-chart/radial-chart.ts +210 -0
  199. package/src/radial-chart/radial-rings.ts +328 -0
  200. package/src/radial-chart/shared.ts +114 -0
  201. package/dist/browser/chunks/chunk-TJNHLQGV.js +0 -2
  202. package/dist/browser/chunks/chunk-TJNHLQGV.js.map +0 -7
  203. package/dist/kit/chart-border.d.ts +0 -27
  204. package/dist/kit/chart-border.d.ts.map +0 -1
  205. package/dist/kit/chart-border.js +0 -28
  206. package/dist/kit/chart-border.js.map +0 -1
  207. package/dist/line-chart/horizontal-axis.d.ts +0 -79
  208. package/dist/line-chart/horizontal-axis.d.ts.map +0 -1
  209. package/dist/line-chart/horizontal-axis.js +0 -129
  210. package/dist/line-chart/horizontal-axis.js.map +0 -1
  211. package/dist/pie-chart/pie-legend.d.ts.map +0 -1
  212. package/dist/pie-chart/pie-legend.js +0 -117
  213. package/dist/pie-chart/pie-legend.js.map +0 -1
  214. package/src/kit/chart-border.ts +0 -50
  215. package/src/line-chart/horizontal-axis.ts +0 -151
@@ -1,129 +1,98 @@
1
- import { type Fill, type FillResolved, type NodeOf, type Node2D as _Node2D, type Node2DProps, type Shadow, type ShadowResolved, type Stroke, type StrokeResolved, type TextStyle } from "@motionscript/sdk";
1
+ import { type Fill, type FillResolved, type NodeOf, type Node2D, type Node2DProps as _Node2DProps, type TextStyle } from "@motionscript/sdk";
2
2
  /**
3
- * One drawn column, already mapped into the plot's **centred pixel space**
4
- * (origin at the plot centre, y-up) by the parent {@link BarChart}.
5
- *
6
- * `from`/`to` are the two ends of the column rather than a base and a height,
7
- * for the same reason {@link BarSpan} is a span: it is the one shape that fits a
8
- * grouped bar, a stacked segment and a negative value without a special case.
3
+ * One drawn bar in the plot's centred pixel space (origin at the centre, y-up),
4
+ * mapped by the parent {@link BarChart}: `center` and `thickness` across the
5
+ * category slot, `from` and `to` along the value axis (y for a column, x for a
6
+ * horizontal bar). Two ends rather than a base and a length, like `BarSpan`:
7
+ * one shape fits grouped, stacked and negative.
9
8
  */
10
9
  export interface BarGeometry {
11
- /** Centre x of the column. */
12
- x: number;
13
- /** Column width in px. */
14
- width: number;
15
- /** Pixel y of the column's base — the baseline when grouped, the running stack top when stacked. */
10
+ center: number;
11
+ thickness: number;
12
+ /** The base: the baseline when grouped, the running stack end when stacked. */
16
13
  from: number;
17
- /** Pixel y of its far end, at full {@link ChartBarsProps.growth}. */
14
+ /** The far end at full growth. */
18
15
  to: number;
19
- /** Whether the far end takes the theme's corner radius (the stack's cap). */
16
+ /** Whether the far end takes the corner radius (the stack's last segment on its side). */
20
17
  round: boolean;
21
- /** The value this column plots, for the figure printed on it. */
22
- value: number;
23
- /**
24
- * The figure printed on it, written as the chart's value axis writes its
25
- * ticks, so the two cannot disagree. Absent, the bare marker reading of
26
- * {@link value}.
27
- */
28
- caption?: string;
29
- }
30
- export interface ChartBarsProps extends Node2DProps {
31
- /** This series' columns, one per row of the chart's data. */
32
- bars: BarGeometry[];
33
- /** Pixel y of value 0 — where every column grows *from*. */
34
- baseline: number;
35
- /** Column paint — this series' own, or the theme palette's entry for its index. */
36
- fill: Fill;
37
- /** Optional outline on every column. */
38
- barStroke: Stroke;
39
- /** Optional drop shadow on every column. */
40
- barShadow: Shadow;
41
- /** Radius of the far-end corners, in px. */
42
- cornerRadius: number;
43
- /**
44
- * Rise of every column in `[0, 1]`, measured **about the baseline**: 0
45
- * collapses them all onto it, 1 draws them at full length.
46
- *
47
- * Scaling about the baseline rather than about each column's own base is what
48
- * keeps a stack flush mid-animation — every segment's base and end travel by
49
- * the same factor, so the segments stay stacked instead of the upper ones
50
- * floating above the still-growing lower ones. It also means a negative
51
- * column grows *down* out of the same signal.
52
- */
53
- growth: number;
54
- /**
55
- * Per-column opacity multiplier, by row index — how the chart's category
56
- * spotlight reaches a single column without touching the series it belongs
57
- * to. Missing entries read as 1.
58
- */
59
- dims: number[];
60
- /** Whether the figure each column plots is printed on it. */
61
- showValues: boolean;
62
- /** Type style for those figures. */
63
- valueStyle: TextStyle;
64
- /**
65
- * Whether this series draws at all — the wholesale switch behind
66
- * `BarChart.showSeries`/`hideSeries`, alongside the slot weight that animates
67
- * the reflow. Off skips the columns *and* their figures.
68
- */
69
- enabled: boolean;
18
+ /** The figure printed by the bar; empty for none. */
19
+ caption: string;
70
20
  }
71
21
  /**
72
- * One **series** of a {@link BarChart}, drawn as one command list: its column in
73
- * every category, plus the figures printed on them.
74
- *
75
- * A node per series rather than a node per bar, deliberately — it is the same
76
- * unit `ChartLine` is, which is what lets `showSeries`/`hideSeries`/
77
- * `spotlightSeries` mean exactly the same thing on a bar chart as on a line
78
- * chart: enable the node, or tween its opacity. The columns' *positions* come
79
- * from the parent (it owns the slot arithmetic both modes share), so this part
80
- * only has to know how to draw a span and grow it.
81
- *
82
- * The figures are real {@link Text} children rather than glyphs in the command
83
- * list, so they take the theme's type style, are measured by the layout engine,
84
- * and ride the node's own opacity — which is why hiding the series takes its
85
- * figures with it for free.
22
+ * One series of a {@link BarChart}: its bar in every category plus the printed
23
+ * figures. A node per series, like `ChartLine`, so `showSeries` and
24
+ * `spotlightSeries` mean the same on both: enable the node or tween its opacity.
25
+ * Positions come from the parent, which owns the slot arithmetic.
86
26
  */
87
27
  export declare const ChartBars: import("@motionscript/sdk").Component<"chartBars", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
88
28
  readonly bars: import("@motionscript/sdk").Type<BarGeometry[], BarGeometry[], false>;
29
+ /** Pixel position of value 0 along the value axis, where every bar grows from. */
89
30
  readonly baseline: 0;
31
+ /** Bars grow along x from a category column rather than along y from a row. */
32
+ readonly horizontal: false;
90
33
  readonly fill: import("@motionscript/sdk").Type<Fill, FillResolved[], false>;
91
- readonly barStroke: import("@motionscript/sdk").Type<Stroke, StrokeResolved[], false>;
92
- readonly barShadow: import("@motionscript/sdk").Type<Shadow, ShadowResolved[], false>;
93
- readonly cornerRadius: number;
34
+ readonly cornerRadius: 8;
35
+ /**
36
+ * Rise of every bar in `[0, 1]` about the baseline, not each bar's own base:
37
+ * every segment travels by the same factor, so a stack stays flush
38
+ * mid-animation and a negative bar grows the other way.
39
+ */
94
40
  readonly growth: 1;
41
+ /** Per-bar opacity by row index, how the category spotlight reaches one bar. Missing reads as 1. */
95
42
  readonly dims: import("@motionscript/sdk").Type<number[], number[], false>;
96
- readonly showValues: false;
43
+ /** Read as built: whether each bar prints its figure, and where. */
44
+ readonly values: import("@motionscript/sdk").Type<"end" | "inside" | "none", "end" | "inside" | "none", false>;
97
45
  readonly valueStyle: import("@motionscript/sdk").Type<TextStyle, TextStyle, false>;
46
+ /** The wholesale switch behind `showSeries`/`hideSeries`; off skips the bars and their figures. */
98
47
  readonly enabled: true;
99
48
  }>, {
100
49
  readonly enter: unknown;
101
- }, null, _Node2D<Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
50
+ }, null, Node2D<_Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
102
51
  readonly bars: import("@motionscript/sdk").Type<BarGeometry[], BarGeometry[], false>;
52
+ /** Pixel position of value 0 along the value axis, where every bar grows from. */
103
53
  readonly baseline: 0;
54
+ /** Bars grow along x from a category column rather than along y from a row. */
55
+ readonly horizontal: false;
104
56
  readonly fill: import("@motionscript/sdk").Type<Fill, FillResolved[], false>;
105
- readonly barStroke: import("@motionscript/sdk").Type<Stroke, StrokeResolved[], false>;
106
- readonly barShadow: import("@motionscript/sdk").Type<Shadow, ShadowResolved[], false>;
107
- readonly cornerRadius: number;
57
+ readonly cornerRadius: 8;
58
+ /**
59
+ * Rise of every bar in `[0, 1]` about the baseline, not each bar's own base:
60
+ * every segment travels by the same factor, so a stack stays flush
61
+ * mid-animation and a negative bar grows the other way.
62
+ */
108
63
  readonly growth: 1;
64
+ /** Per-bar opacity by row index, how the category spotlight reaches one bar. Missing reads as 1. */
109
65
  readonly dims: import("@motionscript/sdk").Type<number[], number[], false>;
110
- readonly showValues: false;
66
+ /** Read as built: whether each bar prints its figure, and where. */
67
+ readonly values: import("@motionscript/sdk").Type<"end" | "inside" | "none", "end" | "inside" | "none", false>;
111
68
  readonly valueStyle: import("@motionscript/sdk").Type<TextStyle, TextStyle, false>;
69
+ /** The wholesale switch behind `showSeries`/`hideSeries`; off skips the bars and their figures. */
112
70
  readonly enabled: true;
113
71
  }>, null, import("@motionscript/sdk").BuiltNode<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
114
72
  readonly bars: import("@motionscript/sdk").Type<BarGeometry[], BarGeometry[], false>;
73
+ /** Pixel position of value 0 along the value axis, where every bar grows from. */
115
74
  readonly baseline: 0;
75
+ /** Bars grow along x from a category column rather than along y from a row. */
76
+ readonly horizontal: false;
116
77
  readonly fill: import("@motionscript/sdk").Type<Fill, FillResolved[], false>;
117
- readonly barStroke: import("@motionscript/sdk").Type<Stroke, StrokeResolved[], false>;
118
- readonly barShadow: import("@motionscript/sdk").Type<Shadow, ShadowResolved[], false>;
119
- readonly cornerRadius: number;
78
+ readonly cornerRadius: 8;
79
+ /**
80
+ * Rise of every bar in `[0, 1]` about the baseline, not each bar's own base:
81
+ * every segment travels by the same factor, so a stack stays flush
82
+ * mid-animation and a negative bar grows the other way.
83
+ */
120
84
  readonly growth: 1;
85
+ /** Per-bar opacity by row index, how the category spotlight reaches one bar. Missing reads as 1. */
121
86
  readonly dims: import("@motionscript/sdk").Type<number[], number[], false>;
122
- readonly showValues: false;
87
+ /** Read as built: whether each bar prints its figure, and where. */
88
+ readonly values: import("@motionscript/sdk").Type<"end" | "inside" | "none", "end" | "inside" | "none", false>;
123
89
  readonly valueStyle: import("@motionscript/sdk").Type<TextStyle, TextStyle, false>;
90
+ /** The wholesale switch behind `showSeries`/`hideSeries`; off skips the bars and their figures. */
124
91
  readonly enabled: true;
125
92
  }>, {
126
93
  readonly enter: unknown;
127
- }, _Node2D<Node2DProps>>>>;
94
+ }, Node2D<_Node2DProps>>>>;
128
95
  export type ChartBars = NodeOf<typeof ChartBars>;
96
+ /** A figure as the bar prints it when the chart gives no caption. */
97
+ export declare function barCaption(value: number): string;
129
98
  //# sourceMappingURL=chart-bars.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chart-bars.d.ts","sourceRoot":"","sources":["../../src/bar-chart/chart-bars.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,KAAK,IAAI,EACT,KAAK,YAAY,EACjB,KAAK,MAAM,EAEX,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,WAAW,EAChB,KAAK,MAAM,EACX,KAAK,cAAc,EACnB,KAAK,MAAM,EACX,KAAK,cAAc,EACnB,KAAK,SAAS,EACf,MAAM,mBAAmB,CAAA;AAQ1B;;;;;;;GAOG;AACH,MAAM,WAAW,WAAW;IAC1B,8BAA8B;IAC9B,CAAC,EAAE,MAAM,CAAA;IACT,0BAA0B;IAC1B,KAAK,EAAE,MAAM,CAAA;IACb,oGAAoG;IACpG,IAAI,EAAE,MAAM,CAAA;IACZ,qEAAqE;IACrE,EAAE,EAAE,MAAM,CAAA;IACV,6EAA6E;IAC7E,KAAK,EAAE,OAAO,CAAA;IACd,iEAAiE;IACjE,KAAK,EAAE,MAAM,CAAA;IACb;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AASD,MAAM,WAAW,cAAe,SAAQ,WAAW;IACjD,6DAA6D;IAC7D,IAAI,EAAE,WAAW,EAAE,CAAA;IACnB,4DAA4D;IAC5D,QAAQ,EAAE,MAAM,CAAA;IAChB,mFAAmF;IACnF,IAAI,EAAE,IAAI,CAAA;IACV,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAA;IACjB,4CAA4C;IAC5C,SAAS,EAAE,MAAM,CAAA;IACjB,4CAA4C;IAC5C,YAAY,EAAE,MAAM,CAAA;IACpB;;;;;;;;;OASG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;;;OAIG;IACH,IAAI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G;;;;0BA8DrG,CAAA;AAEF,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,SAAS,CAAC,CAAA;AAEhD,qEAAqE;AACrE,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhD"}
@@ -1,139 +1,107 @@
1
- import { Graphics2D, Text, Types, component2d, fillOps, shadowOps, strokeOps, textOps, } from "@motionscript/sdk";
2
- import { fresh } from "../kit/entries.js";
1
+ import { Graphics2D, Text, Types, clamp, component2d, fillOps, } from "@motionscript/sdk";
2
+ import { boundText } from "../kit/cartesian.js";
3
+ import { asParts, fresh } from "../kit/entries.js";
3
4
  import { frameEase } from "../kit/motion.js";
4
5
  import { loadPaints } from "../kit/paints.js";
5
- import { clampUnit, formatMarker } from "../kit/shared.js";
6
- import { DEFAULT_BAR_CHART_THEME } from "./shared.js";
7
- /** Gap between a grouped column's end and the figure printed over it, in px. */
8
- const VALUE_GAP = 10;
9
- /** A segment shorter than this many multiples of the type size prints no figure. */
10
- const VALUE_FIT = 1.6;
11
- /** Fallback type size when the theme's value style leaves it unset or autofit. */
12
- const VALUE_SIZE = 24;
13
- /**
14
- * How far column `i` is dimmed — the chart's category spotlight, and the series
15
- * switch on top of it.
16
- *
17
- * The captions read this rather than being hidden by `render`'s guard: they are
18
- * real child nodes, so a `return` in the draw would leave them on screen over a
19
- * series that isn't there.
20
- */
6
+ import { formatMarker } from "../kit/shared.js";
7
+ import { inkOn } from "./shared.js";
8
+ /** A figure inside a bar needs this much room around it, in multiples of the type size. */
9
+ const INSIDE_ROOM = 0.6;
10
+ /** Bar `i`'s dimming: the category spotlight, then the series switch. */
21
11
  function dimAt(s, index) {
22
12
  if (!s.enabled)
23
13
  return 0;
24
- return clampUnit(s.dims[index] ?? 1);
14
+ return clamp(s.dims[index] ?? 1, 0, 1);
25
15
  }
26
- /** The two ends of column `i` at the current growth. */
16
+ /** Bar `i`'s two ends as grown so far, along the value axis. */
27
17
  function endsAt(s, index) {
28
18
  const bar = s.bars[index];
29
19
  if (!bar)
30
20
  return null;
31
- const g = clampUnit(s.growth);
21
+ const g = clamp(s.growth, 0, 1);
32
22
  return { base: s.baseline + (bar.from - s.baseline) * g, end: s.baseline + (bar.to - s.baseline) * g };
33
23
  }
34
- /** The type size the figures are set at, guarding the autofit/unset cases. */
35
- function valueSize(s) {
36
- const size = s.valueStyle.fontSize;
37
- return typeof size === "number" ? size : VALUE_SIZE;
38
- }
39
- /** Whether column `i`'s figure sits inside the column (a stacked segment) or past its end. */
40
- function insideAt(s, index) {
41
- const bar = s.bars[index];
42
- return bar !== undefined && Math.abs(bar.from - s.baseline) > 0.5;
43
- }
44
- /**
45
- * The figure printed on column `i`, or `""` where there is no room for it.
46
- *
47
- * Blanking the text rather than dropping the node keeps the caption list
48
- * index-aligned with the columns, so a chart that rescales into more room simply
49
- * starts printing again.
50
- */
51
- function captionAt(s, index) {
52
- const bar = s.bars[index];
53
- if (!bar || bar.value === 0)
54
- return "";
55
- // An interior segment prints inside itself, so it has to be tall enough to
56
- // hold a line of type; a grouped column prints in the headroom above its end,
57
- // where the only constraint is the plot's own top.
58
- if (insideAt(s, index)) {
59
- const ends = endsAt(s, index);
60
- if (!ends)
61
- return "";
62
- if (Math.abs(ends.end - ends.base) < valueSize(s) * VALUE_FIT)
63
- return "";
64
- }
65
- return bar.caption ?? formatMarker(bar.value);
24
+ function sizeOf(style) {
25
+ return typeof style.fontSize === "number" ? style.fontSize : 24;
66
26
  }
67
- /** Where column `i`'s figure sits, in the node's centred y-up space. */
68
- function captionY(s, index) {
27
+ /** Where bar `i`'s figure sits along the value axis: past its end, or in its middle. */
28
+ function captionAlong(s, index, extent) {
69
29
  const ends = endsAt(s, index);
70
30
  if (!ends)
71
31
  return 0;
72
- if (insideAt(s, index))
32
+ if (s.values === "inside")
73
33
  return (ends.base + ends.end) / 2;
74
- // Text is centred on its `y`, so clear the column's end by the gap plus half a
75
- // line — on whichever side of the baseline the column actually reached.
76
34
  const direction = ends.end >= ends.base ? 1 : -1;
77
- return ends.end + direction * (VALUE_GAP + valueSize(s) / 2);
35
+ return ends.end + direction * (sizeOf(s.valueStyle) * 0.4 + extent / 2);
36
+ }
37
+ /** Whether bar `i` has room for a figure `extent` long inside it. */
38
+ function fitsInside(s, index, extent, across) {
39
+ const bar = s.bars[index];
40
+ const ends = endsAt(s, index);
41
+ if (!bar || !ends)
42
+ return false;
43
+ const room = sizeOf(s.valueStyle) * INSIDE_ROOM;
44
+ return Math.abs(ends.end - ends.base) >= extent + room && bar.thickness >= across;
78
45
  }
79
46
  /**
80
- * One **series** of a {@link BarChart}, drawn as one command list: its column in
81
- * every category, plus the figures printed on them.
82
- *
83
- * A node per series rather than a node per bar, deliberately — it is the same
84
- * unit `ChartLine` is, which is what lets `showSeries`/`hideSeries`/
85
- * `spotlightSeries` mean exactly the same thing on a bar chart as on a line
86
- * chart: enable the node, or tween its opacity. The columns' *positions* come
87
- * from the parent (it owns the slot arithmetic both modes share), so this part
88
- * only has to know how to draw a span and grow it.
89
- *
90
- * The figures are real {@link Text} children rather than glyphs in the command
91
- * list, so they take the theme's type style, are measured by the layout engine,
92
- * and ride the node's own opacity — which is why hiding the series takes its
93
- * figures with it for free.
47
+ * One series of a {@link BarChart}: its bar in every category plus the printed
48
+ * figures. A node per series, like `ChartLine`, so `showSeries` and
49
+ * `spotlightSeries` mean the same on both: enable the node or tween its opacity.
50
+ * Positions come from the parent, which owns the slot arithmetic.
94
51
  */
95
52
  export const ChartBars = component2d({
96
53
  key: "chartBars",
97
54
  state: {
98
55
  bars: fresh(() => []),
56
+ /** Pixel position of value 0 along the value axis, where every bar grows from. */
99
57
  baseline: 0,
58
+ /** Bars grow along x from a category column rather than along y from a row. */
59
+ horizontal: false,
100
60
  fill: Types.custom([], { resolve: fillOps.resolve, lerp: fillOps.lerp }),
101
- barStroke: Types.custom(DEFAULT_BAR_CHART_THEME.bar.stroke, { resolve: strokeOps.resolve, lerp: strokeOps.lerp }),
102
- barShadow: Types.custom(DEFAULT_BAR_CHART_THEME.bar.shadow, { resolve: shadowOps.resolve, lerp: shadowOps.lerp }),
103
- cornerRadius: DEFAULT_BAR_CHART_THEME.bar.cornerRadius,
61
+ cornerRadius: 8,
62
+ /**
63
+ * Rise of every bar in `[0, 1]` about the baseline, not each bar's own base:
64
+ * every segment travels by the same factor, so a stack stays flush
65
+ * mid-animation and a negative bar grows the other way.
66
+ */
104
67
  growth: 1,
68
+ /** Per-bar opacity by row index, how the category spotlight reaches one bar. Missing reads as 1. */
105
69
  dims: fresh(() => []),
106
- showValues: false,
107
- valueStyle: Types.custom(DEFAULT_BAR_CHART_THEME.valueStyle),
70
+ /** Read as built: whether each bar prints its figure, and where. */
71
+ values: Types.custom("none"),
72
+ valueStyle: Types.custom({ fontSize: 24, fill: "white" }),
73
+ /** The wholesale switch behind `showSeries`/`hideSeries`; off skips the bars and their figures. */
108
74
  enabled: true,
109
75
  },
110
- // A plain node filled its parent; one made of its figures would hug them.
76
+ // A node made of its figures would otherwise hug them.
111
77
  defaults: { width: "fill", height: "fill" },
112
- // One caption per column, built once (the row count is fixed at construction,
113
- // like an axis's marker count) and bound to the live geometry so it travels
114
- // with its column as the chart grows, rescales or reflows.
78
+ // One figure per bar, built once (the row count is fixed at construction)
79
+ // and bound to the live geometry so it travels with its bar.
115
80
  children: (state) => {
116
- if (!state.showValues)
81
+ if (state.values === "none")
117
82
  return [];
118
- return state.bars.map((_, i) => Text({
119
- ...textOps.styleProps(state.valueStyle),
120
- text: () => captionAt(state, i),
121
- x: () => state.bars[i]?.x ?? 0,
122
- y: () => captionY(state, i),
123
- opacity: () => dimAt(state, i),
83
+ return asParts(state.bars.map((_, i) => {
84
+ const caption = new Text({
85
+ ...boundText(() => ({ ...state.valueStyle, ...(state.values === "inside" && { fill: inkOn(state.fill) }) })),
86
+ text: () => state.bars[i]?.caption ?? "",
87
+ x: () => (state.horizontal ? captionAlong(state, i, caption.layoutBounds.width) : (state.bars[i]?.center ?? 0)),
88
+ y: () => (state.horizontal ? (state.bars[i]?.center ?? 0) : captionAlong(state, i, caption.layoutBounds.height)),
89
+ opacity: () => {
90
+ const box = caption.layoutBounds;
91
+ const along = state.horizontal ? box.width : box.height;
92
+ const across = state.horizontal ? box.height : box.width;
93
+ if (state.values === "inside" && !fitsInside(state, i, along, across))
94
+ return 0;
95
+ // A figure past the end rises in with its bar's last stretch.
96
+ return dimAt(state, i) * clamp((state.growth - 0.6) / 0.4, 0, 1);
97
+ },
98
+ });
99
+ return caption;
124
100
  }));
125
101
  },
126
- // The column stroke and shadow are named past the conventional slots, so they are named here.
127
- load: (loader, state) => loadPaints(loader, { fills: [state.fill], shadows: [state.barShadow], strokes: [state.barStroke] }),
102
+ load: (loader, state) => loadPaints(loader, { fills: [state.fill] }),
128
103
  commands: {
129
- /**
130
- * Raise every column from the baseline by tweening `growth` `0 → 1`.
131
- *
132
- * The mirror of `ChartLine.enter`: same contract that the resting state is
133
- * the finished one, so the chart arms this back to 0 before animating rather
134
- * than the node hiding itself at construction. No priming to 0 first: the
135
- * value at `t` is a function of `t`, so a repeat call re-raises by definition.
136
- */
104
+ /** Raise every bar from the baseline (`growth` 0 to 1). The resting state is the finished one; the chart arms it back to 0. */
137
105
  enter: (timeline) => {
138
106
  const ease = frameEase(timeline);
139
107
  return timeline.animate((t) => ({ growth: ease(t) }));
@@ -144,38 +112,33 @@ export const ChartBars = component2d({
144
112
  for (let i = 0; i < state.bars.length; i++) {
145
113
  const bar = state.bars[i];
146
114
  const ends = endsAt(state, i);
147
- if (!ends || bar.width <= 0)
115
+ if (!ends || bar.thickness <= 0)
148
116
  continue;
149
- const height = Math.abs(ends.end - ends.base);
150
- if (height <= 0)
117
+ // A segment inside a stack reaches a pixel under the next, so no seam of background shows between them.
118
+ const seam = bar.round ? 0 : 1;
119
+ const length = Math.abs(ends.end - ends.base) + seam;
120
+ if (length <= seam)
151
121
  continue;
152
- const radius = bar.round ? Math.min(state.cornerRadius, height) : 0;
153
- // A column per `Graphics2D` rather than one list for the series: the
154
- // category spotlight dims individual columns, and opacity is a property
155
- // of the command list rather than of a shape within it.
156
- const g = new Graphics2D();
157
- const rect = g.rect({
158
- x: bar.x,
159
- y: (ends.base + ends.end) / 2,
160
- width: bar.width,
161
- height,
162
- // Corner keys are visual (the renderer keeps them in y-up author space),
163
- // so a column reaching *up* rounds its `top*` corners and one reaching
164
- // down its `bottom*` ones. Only the far end rounds, which is what makes
165
- // a stack read as a single capped column.
166
- cornerRadius: radius > 0
167
- ? ends.end >= ends.base
168
- ? { topLeft: radius, topRight: radius, bottomLeft: 0, bottomRight: 0 }
169
- : { bottomLeft: radius, bottomRight: radius, topLeft: 0, topRight: 0 }
170
- : 0,
171
- });
172
- rect.shadow(state.barShadow);
173
- rect.fill(state.fill);
174
- rect.stroke(state.barStroke);
122
+ const radius = bar.round ? Math.max(0, Math.min(state.cornerRadius, length, bar.thickness / 2)) : 0;
123
+ const forward = ends.end >= ends.base;
124
+ const mid = (ends.base + ends.end) / 2 + (forward ? seam : -seam) / 2;
125
+ // Corner keys are visual (y-up): only the far end rounds.
126
+ const far = state.horizontal
127
+ ? (forward ? { topRight: radius, bottomRight: radius, topLeft: 0, bottomLeft: 0 } : { topLeft: radius, bottomLeft: radius, topRight: 0, bottomRight: 0 })
128
+ : (forward ? { topLeft: radius, topRight: radius, bottomLeft: 0, bottomRight: 0 } : { bottomLeft: radius, bottomRight: radius, topLeft: 0, topRight: 0 });
129
+ // One `Graphics2D` per bar: opacity belongs to the command list, and the spotlight dims single bars.
130
+ const g = new Graphics2D().rect(state.horizontal
131
+ ? { x: mid, y: bar.center, width: length, height: bar.thickness, cornerRadius: radius > 0 ? far : 0 }
132
+ : { x: bar.center, y: mid, width: bar.thickness, height: length, cornerRadius: radius > 0 ? far : 0 });
133
+ g.fill(state.fill);
175
134
  ctx.draw(g.opacity(dimAt(state, i)));
176
135
  }
177
136
  }
178
137
  ctx.children();
179
138
  },
180
139
  });
140
+ /** A figure as the bar prints it when the chart gives no caption. */
141
+ export function barCaption(value) {
142
+ return value === 0 ? "" : formatMarker(value);
143
+ }
181
144
  //# sourceMappingURL=chart-bars.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"chart-bars.js","sourceRoot":"","sources":["../../src/bar-chart/chart-bars.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,IAAI,EACJ,KAAK,EACL,WAAW,EACX,OAAO,EACP,SAAS,EACT,SAAS,EACT,OAAO,GAYR,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA;AA+BlD,gFAAgF;AAChF,MAAM,SAAS,GAAG,EAAE,CAAA;AACpB,oFAAoF;AACpF,MAAM,SAAS,GAAG,GAAG,CAAA;AACrB,kFAAkF;AAClF,MAAM,UAAU,GAAG,EAAE,CAAA;AAsDrB;;;;;;;GAOG;AACH,SAAS,KAAK,CAAC,CAAU,EAAE,KAAa;IACtC,IAAI,CAAC,CAAC,CAAC,OAAO;QAAE,OAAO,CAAC,CAAA;IACxB,OAAO,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;AACtC,CAAC;AAED,wDAAwD;AACxD,SAAS,MAAM,CAAC,CAAU,EAAE,KAAa;IACvC,MAAM,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACzB,IAAI,CAAC,GAAG;QAAE,OAAO,IAAI,CAAA;IACrB,MAAM,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;IAC7B,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,QAAQ,GAAG,CAAC,GAAG,CAAC,IA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wDAAwD;gBACxD,MAAM,CAAC,GAAG,IAAI,UAAU,EAAE,CAAA;gBAC1B,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC;oBAClB,CAAC,EAAE,GAAG,CAAC,CAAC;oBACR,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;oBAC7B,KAAK,EAAE,GAAG,CAAC,KAAK;oBAChB,MAAM;oBACN,yEAAyE;oBACzE,uEAAuE;oBACvE,wEAAwE;oBACxE,0CAA0C;oBAC1C,YAAY,EACV,MAAM,GAAG,CAAC;wBACR,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,IAAI;4BACrB,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE;4BACtE,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE;wBACxE,CAAC,CAAC,CAAC;iBACR,CAAC,CAAA;gBACF,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;gBAC5B,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;gBACrB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;gBAC5B,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;YACtC,CAAC;QACH,CAAC;QACD,GAAG,CAAC,QAAQ,EAAE,CAAA;IAChB,CAAC;CACF,CAAC,CAAA","sourcesContent":["import {\n Graphics2D,\n Text,\n Types,\n component2d,\n fillOps,\n shadowOps,\n strokeOps,\n textOps,\n type Fill,\n type FillResolved,\n type NodeOf,\n // Named so this component's emitted type reaches `Node2D` through the sdk, not core.\n type Node2D as _Node2D,\n type Node2DProps,\n type Shadow,\n type ShadowResolved,\n type Stroke,\n type StrokeResolved,\n type TextStyle,\n} from \"@motionscript/sdk\"\n\nimport { fresh } from \"../kit/entries\"\nimport { frameEase } from \"../kit/motion\"\nimport { loadPaints } from \"../kit/paints\"\nimport { clampUnit, formatMarker } from \"../kit/shared\"\nimport { DEFAULT_BAR_CHART_THEME } from \"./shared\"\n\n/**\n * One drawn column, already mapped into the plot's **centred pixel space**\n * (origin at the plot centre, y-up) by the parent {@link BarChart}.\n *\n * `from`/`to` are the two ends of the column rather than a base and a height,\n * for the same reason {@link BarSpan} is a span: it is the one shape that fits a\n * grouped bar, a stacked segment and a negative value without a special case.\n */\nexport interface BarGeometry {\n /** Centre x of the column. */\n x: number\n /** Column width in px. */\n width: number\n /** Pixel y of the column's base — the baseline when grouped, the running stack top when stacked. */\n from: number\n /** Pixel y of its far end, at full {@link ChartBarsProps.growth}. */\n to: number\n /** Whether the far end takes the theme's corner radius (the stack's cap). */\n round: boolean\n /** The value this column plots, for the figure printed on it. */\n value: number\n /**\n * The figure printed on it, written as the chart's value axis writes its\n * ticks, so the two cannot disagree. Absent, the bare marker reading of\n * {@link value}.\n */\n caption?: string\n}\n\n/** Gap between a grouped column's end and the figure printed over it, in px. */\nconst VALUE_GAP = 10\n/** A segment shorter than this many multiples of the type size prints no figure. */\nconst VALUE_FIT = 1.6\n/** Fallback type size when the theme's value style leaves it unset or autofit. */\nconst VALUE_SIZE = 24\n\nexport interface ChartBarsProps extends Node2DProps {\n /** This series' columns, one per row of the chart's data. */\n bars: BarGeometry[]\n /** Pixel y of value 0 — where every column grows *from*. */\n baseline: number\n /** Column paint — this series' own, or the theme palette's entry for its index. */\n fill: Fill\n /** Optional outline on every column. */\n barStroke: Stroke\n /** Optional drop shadow on every column. */\n barShadow: Shadow\n /** Radius of the far-end corners, in px. */\n cornerRadius: number\n /**\n * Rise of every column in `[0, 1]`, measured **about the baseline**: 0\n * collapses them all onto it, 1 draws them at full length.\n *\n * Scaling about the baseline rather than about each column's own base is what\n * keeps a stack flush mid-animation — every segment's base and end travel by\n * the same factor, so the segments stay stacked instead of the upper ones\n * floating above the still-growing lower ones. It also means a negative\n * column grows *down* out of the same signal.\n */\n growth: number\n /**\n * Per-column opacity multiplier, by row index — how the chart's category\n * spotlight reaches a single column without touching the series it belongs\n * to. Missing entries read as 1.\n */\n dims: number[]\n /** Whether the figure each column plots is printed on it. */\n showValues: boolean\n /** Type style for those figures. */\n valueStyle: TextStyle\n /**\n * Whether this series draws at all — the wholesale switch behind\n * `BarChart.showSeries`/`hideSeries`, alongside the slot weight that animates\n * the reflow. Off skips the columns *and* their figures.\n */\n enabled: boolean\n}\n\n/** What the column geometry reads. */\ninterface Columns {\n readonly bars: readonly BarGeometry[]\n readonly baseline: number\n readonly growth: number\n readonly dims: readonly number[]\n readonly enabled: boolean\n readonly valueStyle: TextStyle\n}\n\n/**\n * How far column `i` is dimmed — the chart's category spotlight, and the series\n * switch on top of it.\n *\n * The captions read this rather than being hidden by `render`'s guard: they are\n * real child nodes, so a `return` in the draw would leave them on screen over a\n * series that isn't there.\n */\nfunction dimAt(s: Columns, index: number): number {\n if (!s.enabled) return 0\n return clampUnit(s.dims[index] ?? 1)\n}\n\n/** The two ends of column `i` at the current growth. */\nfunction endsAt(s: Columns, index: number): { base: number; end: number } | null {\n const bar = s.bars[index]\n if (!bar) return null\n const g = clampUnit(s.growth)\n return { base: s.baseline + (bar.from - s.baseline) * g, end: s.baseline + (bar.to - s.baseline) * g }\n}\n\n/** The type size the figures are set at, guarding the autofit/unset cases. */\nfunction valueSize(s: Columns): number {\n const size = s.valueStyle.fontSize\n return typeof size === \"number\" ? size : VALUE_SIZE\n}\n\n/** Whether column `i`'s figure sits inside the column (a stacked segment) or past its end. */\nfunction insideAt(s: Columns, index: number): boolean {\n const bar = s.bars[index]\n return bar !== undefined && Math.abs(bar.from - s.baseline) > 0.5\n}\n\n/**\n * The figure printed on column `i`, or `\"\"` where there is no room for it.\n *\n * Blanking the text rather than dropping the node keeps the caption list\n * index-aligned with the columns, so a chart that rescales into more room simply\n * starts printing again.\n */\nfunction captionAt(s: Columns, index: number): string {\n const bar = s.bars[index]\n if (!bar || bar.value === 0) return \"\"\n // An interior segment prints inside itself, so it has to be tall enough to\n // hold a line of type; a grouped column prints in the headroom above its end,\n // where the only constraint is the plot's own top.\n if (insideAt(s, index)) {\n const ends = endsAt(s, index)\n if (!ends) return \"\"\n if (Math.abs(ends.end - ends.base) < valueSize(s) * VALUE_FIT) return \"\"\n }\n return bar.caption ?? formatMarker(bar.value)\n}\n\n/** Where column `i`'s figure sits, in the node's centred y-up space. */\nfunction captionY(s: Columns, index: number): number {\n const ends = endsAt(s, index)\n if (!ends) return 0\n if (insideAt(s, index)) return (ends.base + ends.end) / 2\n // Text is centred on its `y`, so clear the column's end by the gap plus half a\n // line — on whichever side of the baseline the column actually reached.\n const direction = ends.end >= ends.base ? 1 : -1\n return ends.end + direction * (VALUE_GAP + valueSize(s) / 2)\n}\n\n/**\n * One **series** of a {@link BarChart}, drawn as one command list: its column in\n * every category, plus the figures printed on them.\n *\n * A node per series rather than a node per bar, deliberately — it is the same\n * unit `ChartLine` is, which is what lets `showSeries`/`hideSeries`/\n * `spotlightSeries` mean exactly the same thing on a bar chart as on a line\n * chart: enable the node, or tween its opacity. The columns' *positions* come\n * from the parent (it owns the slot arithmetic both modes share), so this part\n * only has to know how to draw a span and grow it.\n *\n * The figures are real {@link Text} children rather than glyphs in the command\n * list, so they take the theme's type style, are measured by the layout engine,\n * and ride the node's own opacity — which is why hiding the series takes its\n * figures with it for free.\n */\nexport const ChartBars = component2d({\n key: \"chartBars\",\n state: {\n bars: fresh<BarGeometry[]>(() => []),\n baseline: 0,\n fill: Types.custom<Fill, FillResolved[]>([], { resolve: fillOps.resolve, lerp: fillOps.lerp }),\n barStroke: Types.custom<Stroke, StrokeResolved[]>(DEFAULT_BAR_CHART_THEME.bar.stroke, { resolve: strokeOps.resolve, lerp: strokeOps.lerp }),\n barShadow: Types.custom<Shadow, ShadowResolved[]>(DEFAULT_BAR_CHART_THEME.bar.shadow, { resolve: shadowOps.resolve, lerp: shadowOps.lerp }),\n cornerRadius: DEFAULT_BAR_CHART_THEME.bar.cornerRadius,\n growth: 1,\n dims: fresh<number[]>(() => []),\n showValues: false,\n valueStyle: Types.custom<TextStyle>(DEFAULT_BAR_CHART_THEME.valueStyle),\n enabled: true,\n },\n // A plain node filled its parent; one made of its figures would hug them.\n defaults: { width: \"fill\", height: \"fill\" },\n // One caption per column, built once (the row count is fixed at construction,\n // like an axis's marker count) and bound to the live geometry so it travels\n // with its column as the chart grows, rescales or reflows.\n children: (state) => {\n if (!state.showValues) return []\n return state.bars.map((_, i) =>\n Text({\n ...textOps.styleProps(state.valueStyle),\n text: () => captionAt(state, i),\n x: () => state.bars[i]?.x ?? 0,\n y: () => captionY(state, i),\n opacity: () => dimAt(state, i),\n })\n )\n },\n // The column stroke and shadow are named past the conventional slots, so they are named here.\n load: (loader, state) =>\n loadPaints(loader, { fills: [state.fill], shadows: [state.barShadow], strokes: [state.barStroke] }),\n commands: {\n /**\n * Raise every column from the baseline by tweening `growth` `0 → 1`.\n *\n * The mirror of `ChartLine.enter`: same contract that the resting state is\n * the finished one, so the chart arms this back to 0 before animating rather\n * than the node hiding itself at construction. No priming to 0 first: the\n * value at `t` is a function of `t`, so a repeat call re-raises by definition.\n */\n enter: (timeline) => {\n const ease = frameEase(timeline)\n return timeline.animate((t) => ({ growth: ease(t) }))\n },\n },\n render: (ctx, state) => {\n if (state.enabled) {\n for (let i = 0; i < state.bars.length; i++) {\n const bar = state.bars[i]\n const ends = endsAt(state, i)\n if (!ends || bar.width <= 0) continue\n const height = Math.abs(ends.end - ends.base)\n if (height <= 0) continue\n\n const radius = bar.round ? Math.min(state.cornerRadius, height) : 0\n // A column per `Graphics2D` rather than one list for the series: the\n // category spotlight dims individual columns, and opacity is a property\n // of the command list rather than of a shape within it.\n const g = new Graphics2D()\n const rect = g.rect({\n x: bar.x,\n y: (ends.base + ends.end) / 2,\n width: bar.width,\n height,\n // Corner keys are visual (the renderer keeps them in y-up author space),\n // so a column reaching *up* rounds its `top*` corners and one reaching\n // down its `bottom*` ones. Only the far end rounds, which is what makes\n // a stack read as a single capped column.\n cornerRadius:\n radius > 0\n ? ends.end >= ends.base\n ? { topLeft: radius, topRight: radius, bottomLeft: 0, bottomRight: 0 }\n : { bottomLeft: radius, bottomRight: radius, topLeft: 0, topRight: 0 }\n : 0,\n })\n rect.shadow(state.barShadow)\n rect.fill(state.fill)\n rect.stroke(state.barStroke)\n ctx.draw(g.opacity(dimAt(state, i)))\n }\n }\n ctx.children()\n },\n})\n\nexport type ChartBars = NodeOf<typeof ChartBars>\n"]}
1
+ {"version":3,"file":"chart-bars.js","sourceRoot":"","sources":["../../src/bar-chart/chart-bars.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,IAAI,EACJ,KAAK,EACL,KAAK,EACL,WAAW,EACX,OAAO,GAQR,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAsBhC,2FAA2F;AAC3F,MAAM,WAAW,GAAG,GAAG,CAAA;AAavB,yEAAyE;AACzE,SAAS,KAAK,CAAC,CAAO,EAAE,KAAa;IACnC,IAAI,CAAC,CAAC,CAAC,OAAO;QAAE,OAAO,CAAC,CAAA;IACxB,OAAO,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAA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,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;YACtC,CAAC;QACH,CAAC;QACD,GAAG,CAAC,QAAQ,EAAE,CAAA;IAChB,CAAC;CACF,CAAC,CAAA;AAIF,qEAAqE;AACrE,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAAA;AAC/C,CAAC","sourcesContent":["import {\n Graphics2D,\n Text,\n Types,\n clamp,\n component2d,\n fillOps,\n type Fill,\n type FillResolved,\n type NodeOf,\n // Named so this component's emitted type reaches `Node2D` and its props through the sdk, not core.\n type Node2D,\n type Node2DProps as _Node2DProps,\n type TextStyle,\n} from \"@motionscript/sdk\"\n\nimport { boundText } from \"../kit/cartesian\"\nimport { asParts, fresh } from \"../kit/entries\"\nimport { frameEase } from \"../kit/motion\"\nimport { loadPaints } from \"../kit/paints\"\nimport { formatMarker } from \"../kit/shared\"\nimport { inkOn } from \"./shared\"\n\n/**\n * One drawn bar in the plot's centred pixel space (origin at the centre, y-up),\n * mapped by the parent {@link BarChart}: `center` and `thickness` across the\n * category slot, `from` and `to` along the value axis (y for a column, x for a\n * horizontal bar). Two ends rather than a base and a length, like `BarSpan`:\n * one shape fits grouped, stacked and negative.\n */\nexport interface BarGeometry {\n center: number\n thickness: number\n /** The base: the baseline when grouped, the running stack end when stacked. */\n from: number\n /** The far end at full growth. */\n to: number\n /** Whether the far end takes the corner radius (the stack's last segment on its side). */\n round: boolean\n /** The figure printed by the bar; empty for none. */\n caption: string\n}\n\n/** A figure inside a bar needs this much room around it, in multiples of the type size. */\nconst INSIDE_ROOM = 0.6\n\ninterface Bars {\n readonly bars: readonly BarGeometry[]\n readonly baseline: number\n readonly horizontal: boolean\n readonly growth: number\n readonly dims: readonly number[]\n readonly enabled: boolean\n readonly values: \"none\" | \"end\" | \"inside\"\n readonly valueStyle: TextStyle\n}\n\n/** Bar `i`'s dimming: the category spotlight, then the series switch. */\nfunction dimAt(s: Bars, index: number): number {\n if (!s.enabled) return 0\n return clamp(s.dims[index] ?? 1, 0, 1)\n}\n\n/** Bar `i`'s two ends as grown so far, along the value axis. */\nfunction endsAt(s: Bars, index: number): { base: number; end: number } | null {\n const bar = s.bars[index]\n if (!bar) return null\n const g = clamp(s.growth, 0, 1)\n return { base: s.baseline + (bar.from - s.baseline) * g, end: s.baseline + (bar.to - s.baseline) * g }\n}\n\nfunction sizeOf(style: TextStyle): number {\n return typeof style.fontSize === \"number\" ? style.fontSize : 24\n}\n\n/** Where bar `i`'s figure sits along the value axis: past its end, or in its middle. */\nfunction captionAlong(s: Bars, index: number, extent: number): number {\n const ends = endsAt(s, index)\n if (!ends) return 0\n if (s.values === \"inside\") return (ends.base + ends.end) / 2\n const direction = ends.end >= ends.base ? 1 : -1\n return ends.end + direction * (sizeOf(s.valueStyle) * 0.4 + extent / 2)\n}\n\n/** Whether bar `i` has room for a figure `extent` long inside it. */\nfunction fitsInside(s: Bars, index: number, extent: number, across: number): boolean {\n const bar = s.bars[index]\n const ends = endsAt(s, index)\n if (!bar || !ends) return false\n const room = sizeOf(s.valueStyle) * INSIDE_ROOM\n return Math.abs(ends.end - ends.base) >= extent + room && bar.thickness >= across\n}\n\n/**\n * One series of a {@link BarChart}: its bar in every category plus the printed\n * figures. A node per series, like `ChartLine`, so `showSeries` and\n * `spotlightSeries` mean the same on both: enable the node or tween its opacity.\n * Positions come from the parent, which owns the slot arithmetic.\n */\nexport const ChartBars = component2d({\n key: \"chartBars\",\n state: {\n bars: fresh<BarGeometry[]>(() => []),\n /** Pixel position of value 0 along the value axis, where every bar grows from. */\n baseline: 0,\n /** Bars grow along x from a category column rather than along y from a row. */\n horizontal: false,\n fill: Types.custom<Fill, FillResolved[]>([], { resolve: fillOps.resolve, lerp: fillOps.lerp }),\n cornerRadius: 8,\n /**\n * Rise of every bar in `[0, 1]` about the baseline, not each bar's own base:\n * every segment travels by the same factor, so a stack stays flush\n * mid-animation and a negative bar grows the other way.\n */\n growth: 1,\n /** Per-bar opacity by row index, how the category spotlight reaches one bar. Missing reads as 1. */\n dims: fresh<number[]>(() => []),\n /** Read as built: whether each bar prints its figure, and where. */\n values: Types.custom<\"none\" | \"end\" | \"inside\">(\"none\"),\n valueStyle: Types.custom<TextStyle>({ fontSize: 24, fill: \"white\" }),\n /** The wholesale switch behind `showSeries`/`hideSeries`; off skips the bars and their figures. */\n enabled: true,\n },\n // A node made of its figures would otherwise hug them.\n defaults: { width: \"fill\", height: \"fill\" },\n // One figure per bar, built once (the row count is fixed at construction)\n // and bound to the live geometry so it travels with its bar.\n children: (state) => {\n if (state.values === \"none\") return []\n return asParts(state.bars.map((_, i) => {\n const caption: Node2D = new Text({\n ...boundText(() => ({ ...state.valueStyle, ...(state.values === \"inside\" && { fill: inkOn(state.fill) }) })),\n text: () => state.bars[i]?.caption ?? \"\",\n x: () => (state.horizontal ? captionAlong(state, i, caption.layoutBounds.width) : (state.bars[i]?.center ?? 0)),\n y: () => (state.horizontal ? (state.bars[i]?.center ?? 0) : captionAlong(state, i, caption.layoutBounds.height)),\n opacity: () => {\n const box = caption.layoutBounds\n const along = state.horizontal ? box.width : box.height\n const across = state.horizontal ? box.height : box.width\n if (state.values === \"inside\" && !fitsInside(state, i, along, across)) return 0\n // A figure past the end rises in with its bar's last stretch.\n return dimAt(state, i) * clamp((state.growth - 0.6) / 0.4, 0, 1)\n },\n }) as unknown as Node2D\n return caption\n }))\n },\n load: (loader, state) => loadPaints(loader, { fills: [state.fill] }),\n commands: {\n /** Raise every bar from the baseline (`growth` 0 to 1). The resting state is the finished one; the chart arms it back to 0. */\n enter: (timeline) => {\n const ease = frameEase(timeline)\n return timeline.animate((t) => ({ growth: ease(t) }))\n },\n },\n render: (ctx, state) => {\n if (state.enabled) {\n for (let i = 0; i < state.bars.length; i++) {\n const bar = state.bars[i]\n const ends = endsAt(state, i)\n if (!ends || bar.thickness <= 0) continue\n // A segment inside a stack reaches a pixel under the next, so no seam of background shows between them.\n const seam = bar.round ? 0 : 1\n const length = Math.abs(ends.end - ends.base) + seam\n if (length <= seam) continue\n const radius = bar.round ? Math.max(0, Math.min(state.cornerRadius, length, bar.thickness / 2)) : 0\n const forward = ends.end >= ends.base\n const mid = (ends.base + ends.end) / 2 + (forward ? seam : -seam) / 2\n // Corner keys are visual (y-up): only the far end rounds.\n const far = state.horizontal\n ? (forward ? { topRight: radius, bottomRight: radius, topLeft: 0, bottomLeft: 0 } : { topLeft: radius, bottomLeft: radius, topRight: 0, bottomRight: 0 })\n : (forward ? { topLeft: radius, topRight: radius, bottomLeft: 0, bottomRight: 0 } : { bottomLeft: radius, bottomRight: radius, topLeft: 0, topRight: 0 })\n // One `Graphics2D` per bar: opacity belongs to the command list, and the spotlight dims single bars.\n const g = new Graphics2D().rect(state.horizontal\n ? { x: mid, y: bar.center, width: length, height: bar.thickness, cornerRadius: radius > 0 ? far : 0 }\n : { x: bar.center, y: mid, width: bar.thickness, height: length, cornerRadius: radius > 0 ? far : 0 })\n g.fill(state.fill)\n ctx.draw(g.opacity(dimAt(state, i)))\n }\n }\n ctx.children()\n },\n})\n\nexport type ChartBars = NodeOf<typeof ChartBars>\n\n/** A figure as the bar prints it when the chart gives no caption. */\nexport function barCaption(value: number): string {\n return value === 0 ? \"\" : formatMarker(value)\n}\n"]}
@@ -1,16 +1,8 @@
1
- /**
2
- * The bar chart: grouped or stacked columns off a category axis.
3
- *
4
- * Shares the plot panel, the value axis and the legend with the line chart —
5
- * which is what lets a scene swap one for the other without re-theming — and
6
- * brings its own category axis, since a band scale is not a continuous one.
7
- */
8
1
  export { BarChart, barChartDomain } from "./bar-chart.js";
9
- export type { BarChartDomain, BarChartProps, BarChartValues } from "./bar-chart.js";
2
+ export type { BarChartDomain, BarChartStyle, BarChartValues } from "./bar-chart.js";
10
3
  export { ChartBars } from "./chart-bars.js";
11
- export type { BarGeometry, ChartBarsProps } from "./chart-bars.js";
12
- export { CategoryAxis } from "./category-axis.js";
13
- export type { CategoryAxisProps } from "./category-axis.js";
14
- export { DEFAULT_BAR_CHART_THEME, barCategories, barSpans, barValueExtent, lerpBarChartTheme, resolveBarChartTheme, resolveBarFill, resolveBarScale, stackCapIndex, } from "./shared.js";
15
- export type { BarChartConfig, BarChartTheme, BarSeries, BarSpan, BarStyleConfig, } from "./shared.js";
4
+ export type { BarGeometry } from "./chart-bars.js";
5
+ export { CategoryAxis, slotCentre } from "./category-axis.js";
6
+ export { BAR_LABELS, BAR_MARKS, barCategories, barSpans, barValueExtent, inkOn, resolveBarScale, } from "./shared.js";
7
+ export type { BarOrientation, BarSeries, BarSpan, BarStack, } from "./shared.js";
16
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bar-chart/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACtD,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAChF,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACxD,OAAO,EACL,uBAAuB,EACvB,aAAa,EACb,QAAQ,EACR,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,aAAa,GACd,MAAM,UAAU,CAAA;AACjB,YAAY,EACV,cAAc,EACd,aAAa,EACb,SAAS,EACT,OAAO,EACP,cAAc,GACf,MAAM,UAAU,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bar-chart/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACtD,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAChF,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EACL,UAAU,EACV,SAAS,EACT,aAAa,EACb,QAAQ,EACR,cAAc,EACd,KAAK,EACL,eAAe,GAChB,MAAM,UAAU,CAAA;AACjB,YAAY,EACV,cAAc,EACd,SAAS,EACT,OAAO,EACP,QAAQ,GACT,MAAM,UAAU,CAAA"}
@@ -1,12 +1,5 @@
1
- /**
2
- * The bar chart: grouped or stacked columns off a category axis.
3
- *
4
- * Shares the plot panel, the value axis and the legend with the line chart —
5
- * which is what lets a scene swap one for the other without re-theming — and
6
- * brings its own category axis, since a band scale is not a continuous one.
7
- */
8
1
  export { BarChart, barChartDomain } from "./bar-chart.js";
9
2
  export { ChartBars } from "./chart-bars.js";
10
- export { CategoryAxis } from "./category-axis.js";
11
- export { DEFAULT_BAR_CHART_THEME, barCategories, barSpans, barValueExtent, lerpBarChartTheme, resolveBarChartTheme, resolveBarFill, resolveBarScale, stackCapIndex, } from "./shared.js";
3
+ export { CategoryAxis, slotCentre } from "./category-axis.js";
4
+ export { BAR_LABELS, BAR_MARKS, barCategories, barSpans, barValueExtent, inkOn, resolveBarScale, } from "./shared.js";
12
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bar-chart/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEtD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAExC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C,OAAO,EACL,uBAAuB,EACvB,aAAa,EACb,QAAQ,EACR,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,aAAa,GACd,MAAM,UAAU,CAAA","sourcesContent":["/**\n * The bar chart: grouped or stacked columns off a category axis.\n *\n * Shares the plot panel, the value axis and the legend with the line chart —\n * which is what lets a scene swap one for the other without re-theming — and\n * brings its own category axis, since a band scale is not a continuous one.\n */\nexport { BarChart, barChartDomain } from \"./bar-chart\"\nexport type { BarChartDomain, BarChartProps, BarChartValues } from \"./bar-chart\"\nexport { ChartBars } from \"./chart-bars\"\nexport type { BarGeometry, ChartBarsProps } from \"./chart-bars\"\nexport { CategoryAxis } from \"./category-axis\"\nexport type { CategoryAxisProps } from \"./category-axis\"\nexport {\n DEFAULT_BAR_CHART_THEME,\n barCategories,\n barSpans,\n barValueExtent,\n lerpBarChartTheme,\n resolveBarChartTheme,\n resolveBarFill,\n resolveBarScale,\n stackCapIndex,\n} from \"./shared\"\nexport type {\n BarChartConfig,\n BarChartTheme,\n BarSeries,\n BarSpan,\n BarStyleConfig,\n} from \"./shared\"\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bar-chart/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEtD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAExC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EACL,UAAU,EACV,SAAS,EACT,aAAa,EACb,QAAQ,EACR,cAAc,EACd,KAAK,EACL,eAAe,GAChB,MAAM,UAAU,CAAA","sourcesContent":["export { BarChart, barChartDomain } from \"./bar-chart\"\nexport type { BarChartDomain, BarChartStyle, BarChartValues } from \"./bar-chart\"\nexport { ChartBars } from \"./chart-bars\"\nexport type { BarGeometry } from \"./chart-bars\"\nexport { CategoryAxis, slotCentre } from \"./category-axis\"\nexport {\n BAR_LABELS,\n BAR_MARKS,\n barCategories,\n barSpans,\n barValueExtent,\n inkOn,\n resolveBarScale,\n} from \"./shared\"\nexport type {\n BarOrientation,\n BarSeries,\n BarSpan,\n BarStack,\n} from \"./shared\"\n"]}