@motionscript/charts 0.1.0-alpha.3 → 0.1.0-alpha.6

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/CHANGELOG.md +63 -0
  2. package/LICENSE +201 -201
  3. package/NOTICE +48 -0
  4. package/README.md +99 -0
  5. package/dist/bar-chart/bar-chart.d.ts +93 -231
  6. package/dist/bar-chart/bar-chart.d.ts.map +1 -1
  7. package/dist/bar-chart/bar-chart.js +378 -565
  8. package/dist/bar-chart/bar-chart.js.map +1 -1
  9. package/dist/bar-chart/category-axis.d.ts +24 -41
  10. package/dist/bar-chart/category-axis.d.ts.map +1 -1
  11. package/dist/bar-chart/category-axis.js +93 -115
  12. package/dist/bar-chart/category-axis.js.map +1 -1
  13. package/dist/bar-chart/chart-bars.d.ts +36 -70
  14. package/dist/bar-chart/chart-bars.d.ts.map +1 -1
  15. package/dist/bar-chart/chart-bars.js +156 -210
  16. package/dist/bar-chart/chart-bars.js.map +1 -1
  17. package/dist/bar-chart/index.d.ts +2 -2
  18. package/dist/bar-chart/index.d.ts.map +1 -1
  19. package/dist/bar-chart/index.js +1 -1
  20. package/dist/bar-chart/index.js.map +1 -1
  21. package/dist/bar-chart/shared.d.ts +6 -6
  22. package/dist/bar-chart/shared.d.ts.map +1 -1
  23. package/dist/bar-chart/shared.js +6 -6
  24. package/dist/bar-chart/shared.js.map +1 -1
  25. package/dist/browser/chunks/chunk-XROBIRQK.js +2 -0
  26. package/dist/browser/chunks/chunk-XROBIRQK.js.map +7 -0
  27. package/dist/browser/index.js +1 -1
  28. package/dist/browser/index.js.map +3 -3
  29. package/dist/browser/kit.js +1 -1
  30. package/dist/browser/manifest.json +3 -2
  31. package/dist/engine.d.ts +8 -6
  32. package/dist/engine.d.ts.map +1 -1
  33. package/dist/engine.js +8 -6
  34. package/dist/engine.js.map +1 -1
  35. package/dist/index.js.map +1 -1
  36. package/dist/kit/cartesian.d.ts +44 -0
  37. package/dist/kit/cartesian.d.ts.map +1 -0
  38. package/dist/kit/cartesian.js +59 -0
  39. package/dist/kit/cartesian.js.map +1 -0
  40. package/dist/kit/chart-border.d.ts +8 -11
  41. package/dist/kit/chart-border.d.ts.map +1 -1
  42. package/dist/kit/chart-border.js +15 -32
  43. package/dist/kit/chart-border.js.map +1 -1
  44. package/dist/kit/chart-canvas.d.ts +23 -21
  45. package/dist/kit/chart-canvas.d.ts.map +1 -1
  46. package/dist/kit/chart-canvas.js +33 -90
  47. package/dist/kit/chart-canvas.js.map +1 -1
  48. package/dist/kit/chart-legend.d.ts +79 -88
  49. package/dist/kit/chart-legend.d.ts.map +1 -1
  50. package/dist/kit/chart-legend.js +137 -186
  51. package/dist/kit/chart-legend.js.map +1 -1
  52. package/dist/kit/entries.d.ts +17 -0
  53. package/dist/kit/entries.d.ts.map +1 -0
  54. package/dist/kit/entries.js +19 -0
  55. package/dist/kit/entries.js.map +1 -0
  56. package/dist/kit/motion.d.ts +48 -0
  57. package/dist/kit/motion.d.ts.map +1 -0
  58. package/dist/kit/motion.js +63 -0
  59. package/dist/kit/motion.js.map +1 -0
  60. package/dist/kit/paints.d.ts +10 -0
  61. package/dist/kit/paints.d.ts.map +1 -0
  62. package/dist/kit/paints.js +12 -0
  63. package/dist/kit/paints.js.map +1 -0
  64. package/dist/kit/shared.d.ts +59 -8
  65. package/dist/kit/shared.d.ts.map +1 -1
  66. package/dist/kit/shared.js +105 -10
  67. package/dist/kit/shared.js.map +1 -1
  68. package/dist/kit/vertical-axis.d.ts +36 -61
  69. package/dist/kit/vertical-axis.d.ts.map +1 -1
  70. package/dist/kit/vertical-axis.js +97 -132
  71. package/dist/kit/vertical-axis.js.map +1 -1
  72. package/dist/line-chart/chart-line.d.ts +27 -53
  73. package/dist/line-chart/chart-line.d.ts.map +1 -1
  74. package/dist/line-chart/chart-line.js +89 -120
  75. package/dist/line-chart/chart-line.js.map +1 -1
  76. package/dist/line-chart/chart-region.d.ts +14 -14
  77. package/dist/line-chart/chart-region.d.ts.map +1 -1
  78. package/dist/line-chart/chart-region.js +26 -64
  79. package/dist/line-chart/chart-region.js.map +1 -1
  80. package/dist/line-chart/horizontal-axis.d.ts +32 -56
  81. package/dist/line-chart/horizontal-axis.d.ts.map +1 -1
  82. package/dist/line-chart/horizontal-axis.js +85 -123
  83. package/dist/line-chart/horizontal-axis.js.map +1 -1
  84. package/dist/line-chart/index.d.ts +2 -2
  85. package/dist/line-chart/index.d.ts.map +1 -1
  86. package/dist/line-chart/index.js +1 -1
  87. package/dist/line-chart/index.js.map +1 -1
  88. package/dist/line-chart/line-chart.d.ts +111 -311
  89. package/dist/line-chart/line-chart.d.ts.map +1 -1
  90. package/dist/line-chart/line-chart.js +403 -639
  91. package/dist/line-chart/line-chart.js.map +1 -1
  92. package/dist/line-chart/shared.d.ts +6 -6
  93. package/dist/line-chart/shared.d.ts.map +1 -1
  94. package/dist/line-chart/shared.js +22 -7
  95. package/dist/line-chart/shared.js.map +1 -1
  96. package/dist/line-chart/x-scale.d.ts +1 -1
  97. package/dist/line-chart/x-scale.js +1 -1
  98. package/dist/line-chart/x-scale.js.map +1 -1
  99. package/dist/nodes.d.ts +6 -9
  100. package/dist/nodes.d.ts.map +1 -1
  101. package/dist/nodes.js +7 -9
  102. package/dist/nodes.js.map +1 -1
  103. package/dist/pie-chart/index.d.ts +2 -2
  104. package/dist/pie-chart/index.d.ts.map +1 -1
  105. package/dist/pie-chart/index.js +1 -1
  106. package/dist/pie-chart/index.js.map +1 -1
  107. package/dist/pie-chart/pie-chart.d.ts +77 -134
  108. package/dist/pie-chart/pie-chart.d.ts.map +1 -1
  109. package/dist/pie-chart/pie-chart.js +199 -268
  110. package/dist/pie-chart/pie-chart.js.map +1 -1
  111. package/dist/pie-chart/pie-legend.d.ts +54 -31
  112. package/dist/pie-chart/pie-legend.d.ts.map +1 -1
  113. package/dist/pie-chart/pie-legend.js +93 -107
  114. package/dist/pie-chart/pie-legend.js.map +1 -1
  115. package/dist/pie-chart/pie-ring.d.ts +142 -122
  116. package/dist/pie-chart/pie-ring.d.ts.map +1 -1
  117. package/dist/pie-chart/pie-ring.js +333 -361
  118. package/dist/pie-chart/pie-ring.js.map +1 -1
  119. package/dist/pie-chart/shared.d.ts +3 -3
  120. package/dist/pie-chart/shared.js +3 -3
  121. package/dist/pie-chart/shared.js.map +1 -1
  122. package/package.json +6 -5
  123. package/registry.json +23 -23
  124. package/src/bar-chart/bar-chart.ts +534 -814
  125. package/src/bar-chart/category-axis.ts +162 -177
  126. package/src/bar-chart/chart-bars.ts +288 -310
  127. package/src/bar-chart/index.ts +31 -31
  128. package/src/bar-chart/shared.ts +354 -354
  129. package/src/engine.ts +28 -26
  130. package/src/index.ts +5 -5
  131. package/src/kit/cartesian.ts +81 -0
  132. package/src/kit/chart-border.ts +50 -61
  133. package/src/kit/chart-canvas.ts +122 -157
  134. package/src/kit/chart-legend.ts +229 -250
  135. package/src/kit/entries.ts +20 -0
  136. package/src/kit/motion.ts +90 -0
  137. package/src/kit/paints.ts +15 -0
  138. package/src/kit/shared.ts +782 -675
  139. package/src/kit/vertical-axis.ts +194 -224
  140. package/src/line-chart/chart-line.ts +181 -208
  141. package/src/line-chart/chart-region.ts +106 -135
  142. package/src/line-chart/horizontal-axis.ts +166 -202
  143. package/src/line-chart/index.ts +39 -39
  144. package/src/line-chart/line-chart.ts +585 -929
  145. package/src/line-chart/shared.ts +473 -459
  146. package/src/line-chart/x-scale.ts +367 -367
  147. package/src/nodes.ts +18 -20
  148. package/src/pie-chart/index.ts +37 -37
  149. package/src/pie-chart/pie-chart.ts +293 -381
  150. package/src/pie-chart/pie-legend.ts +169 -159
  151. package/src/pie-chart/pie-ring.ts +848 -903
  152. package/src/pie-chart/shared.ts +490 -490
  153. package/dist/browser/chunks/chunk-RMHQ6GYU.js +0 -2
  154. package/dist/browser/chunks/chunk-RMHQ6GYU.js.map +0 -7
@@ -1,2 +1,2 @@
1
- import{A,B,C,D,E,F,G,H,I,J,K,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunks/chunk-RMHQ6GYU.js";export{c as CHART_PALETTE,H as ChartBorder,I as ChartCanvas,J as ChartLegend,m as DEFAULT_LEGEND,l as DEFAULT_PLOT_AREA,d as DEFAULT_SERIES_COLORS,o as DEFAULT_SERIES_FILLS,n as DEFAULT_SERIES_STROKES,j as DEFAULT_X_AXIS,k as DEFAULT_Y_AXIS,e as SPOTLIGHT_DIM,K as VerticalAxis,f as clampUnit,G as enterBudget,C as formatMarker,D as formatPercent,q as lerpAxisConfig,b as lerpAxisDomain,u as lerpLegendConfig,s as lerpPlotArea,y as lerpSeriesFills,w as lerpSeriesStrokes,E as markerValues,F as niceStep,g as num,i as numericFields,p as resolveAxisConfig,a as resolveAxisDomain,t as resolveLegendConfig,B as resolvePalettePaint,r as resolvePlotArea,A as resolveSeriesFill,x as resolveSeriesFills,z as resolveSeriesStroke,v as resolveSeriesStrokes,h as text};
1
+ import{$,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,_,a,aa,b,ba,c,ca,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunks/chunk-XROBIRQK.js";export{o as CHART_PALETTE,$ as ChartBorder,aa as ChartCanvas,ba as ChartLegend,y as DEFAULT_LEGEND,x as DEFAULT_PLOT_AREA,p as DEFAULT_SERIES_COLORS,A as DEFAULT_SERIES_FILLS,z as DEFAULT_SERIES_STROKES,v as DEFAULT_X_AXIS,w as DEFAULT_Y_AXIS,e as LANDED,q as SPOTLIGHT_DIM,W as TOP_HEADROOM,V as VerticalAxis,h as armed,i as arrival,g as arrivalOf,f as arrivalsEntry,b as asParts,l as axisTweenTarget,d as beats,X as cartesianFrame,Y as cartesianViews,r as clampUnit,T as enterBudget,O as formatMarker,Q as formatPercent,c as frameEase,a as fresh,Z as laidOutSize,ca as legendShows,C as lerpAxisConfig,k as lerpAxisDomain,m as lerpAxisEntry,G as lerpLegendConfig,E as lerpPlotArea,K as lerpSeriesFills,I as lerpSeriesStrokes,_ as loadPaints,U as markerCaption,P as markerStep,R as markerValues,S as niceStep,s as num,u as numericFields,B as resolveAxisConfig,j as resolveAxisDomain,F as resolveLegendConfig,N as resolvePalettePaint,D as resolvePlotArea,M as resolveSeriesFill,J as resolveSeriesFills,L as resolveSeriesStroke,H as resolveSeriesStrokes,n as settleAxisDomain,t as text};
2
2
  //# sourceMappingURL=kit.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@motionscript/charts",
3
- "version": "0.1.0-alpha.3",
3
+ "version": "0.1.0-alpha.6",
4
4
  "exports": {
5
5
  ".": "dist/browser/index.js",
6
6
  "./kit": "dist/browser/kit.js"
@@ -8,5 +8,6 @@
8
8
  "peers": [
9
9
  "@motionscript/sdk"
10
10
  ],
11
- "assets": {}
11
+ "assets": {},
12
+ "thirdParty": []
12
13
  }
package/dist/engine.d.ts CHANGED
@@ -7,21 +7,23 @@
7
7
  * axis, the legend and the number formatting stay a real dependency. That is
8
8
  * not a size decision — it is the only arrangement that works.
9
9
  *
10
- * A chart identifies its own parts, and the engine keys signal machinery to
11
- * class identity: `@property` installs against the class it was applied with,
12
- * and the renderer asks `instanceof` about what it is drawing. Copy
13
- * `VerticalAxis` alongside your fork and there are now two of it — two classes
14
- * answering one name, and whichever one your chart did not get renders as
15
- * nothing at all, with no error. Keeping the kit external makes that
10
+ * A chart identifies its own parts by component identity (`VerticalAxis.is`).
11
+ * Copy `VerticalAxis` alongside your fork and there are now two of it — two
12
+ * components answering one name, and whichever one your chart did not get is
13
+ * a part it never finds, with no error. Keeping the kit external makes that
16
14
  * impossible rather than unlikely.
17
15
  *
18
16
  * It also means a fix to the axis reaches a forked chart without a re-add,
19
17
  * which is the half of the bargain you get back for it.
20
18
  */
21
19
  export * from "./kit/shared.js";
20
+ export * from "./kit/cartesian.js";
22
21
  export * from "./kit/chart-border.js";
23
22
  export * from "./kit/chart-canvas.js";
24
23
  export * from "./kit/chart-legend.js";
24
+ export * from "./kit/entries.js";
25
+ export * from "./kit/motion.js";
26
+ export * from "./kit/paints.js";
25
27
  export * from "./kit/vertical-axis.js";
26
28
  export * from "@motionscript/sdk/component";
27
29
  //# sourceMappingURL=engine.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,cAAc,cAAc,CAAA;AAC5B,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,6BAA6B,CAAA"}
1
+ {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,cAAc,cAAc,CAAA;AAC5B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,qBAAqB,CAAA;AACnC,cAAc,6BAA6B,CAAA"}
package/dist/engine.js CHANGED
@@ -7,21 +7,23 @@
7
7
  * axis, the legend and the number formatting stay a real dependency. That is
8
8
  * not a size decision — it is the only arrangement that works.
9
9
  *
10
- * A chart identifies its own parts, and the engine keys signal machinery to
11
- * class identity: `@property` installs against the class it was applied with,
12
- * and the renderer asks `instanceof` about what it is drawing. Copy
13
- * `VerticalAxis` alongside your fork and there are now two of it — two classes
14
- * answering one name, and whichever one your chart did not get renders as
15
- * nothing at all, with no error. Keeping the kit external makes that
10
+ * A chart identifies its own parts by component identity (`VerticalAxis.is`).
11
+ * Copy `VerticalAxis` alongside your fork and there are now two of it — two
12
+ * components answering one name, and whichever one your chart did not get is
13
+ * a part it never finds, with no error. Keeping the kit external makes that
16
14
  * impossible rather than unlikely.
17
15
  *
18
16
  * It also means a fix to the axis reaches a forked chart without a re-add,
19
17
  * which is the half of the bargain you get back for it.
20
18
  */
21
19
  export * from "./kit/shared.js";
20
+ export * from "./kit/cartesian.js";
22
21
  export * from "./kit/chart-border.js";
23
22
  export * from "./kit/chart-canvas.js";
24
23
  export * from "./kit/chart-legend.js";
24
+ export * from "./kit/entries.js";
25
+ export * from "./kit/motion.js";
26
+ export * from "./kit/paints.js";
25
27
  export * from "./kit/vertical-axis.js";
26
28
  export * from "@motionscript/sdk/component";
27
29
  //# sourceMappingURL=engine.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"engine.js","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,cAAc,cAAc,CAAA;AAC5B,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,6BAA6B,CAAA","sourcesContent":["/**\n * The chart **kit**: everything the three charts share, and the one thing a\n * copied chart does not copy.\n *\n * `ms add line-chart` writes `line-chart/*` into your project and rewrites its\n * reach for these to `@motionscript/charts`, so the plot panel, the value\n * axis, the legend and the number formatting stay a real dependency. That is\n * not a size decision — it is the only arrangement that works.\n *\n * A chart identifies its own parts, and the engine keys signal machinery to\n * class identity: `@property` installs against the class it was applied with,\n * and the renderer asks `instanceof` about what it is drawing. Copy\n * `VerticalAxis` alongside your fork and there are now two of it — two classes\n * answering one name, and whichever one your chart did not get renders as\n * nothing at all, with no error. Keeping the kit external makes that\n * impossible rather than unlikely.\n *\n * It also means a fix to the axis reaches a forked chart without a re-add,\n * which is the half of the bargain you get back for it.\n */\nexport * from \"./kit/shared\"\nexport * from \"./kit/chart-border\"\nexport * from \"./kit/chart-canvas\"\nexport * from \"./kit/chart-legend\"\nexport * from \"./kit/vertical-axis\"\nexport * from \"@motionscript/sdk/component\"\n"]}
1
+ {"version":3,"file":"engine.js","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,cAAc,cAAc,CAAA;AAC5B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,qBAAqB,CAAA;AACnC,cAAc,6BAA6B,CAAA","sourcesContent":["/**\r\n * The chart **kit**: everything the three charts share, and the one thing a\r\n * copied chart does not copy.\r\n *\r\n * `ms add line-chart` writes `line-chart/*` into your project and rewrites its\r\n * reach for these to `@motionscript/charts`, so the plot panel, the value\r\n * axis, the legend and the number formatting stay a real dependency. That is\r\n * not a size decision — it is the only arrangement that works.\r\n *\r\n * A chart identifies its own parts by component identity (`VerticalAxis.is`).\r\n * Copy `VerticalAxis` alongside your fork and there are now two of it — two\r\n * components answering one name, and whichever one your chart did not get is\r\n * a part it never finds, with no error. Keeping the kit external makes that\r\n * impossible rather than unlikely.\r\n *\r\n * It also means a fix to the axis reaches a forked chart without a re-add,\r\n * which is the half of the bargain you get back for it.\r\n */\r\nexport * from \"./kit/shared\"\r\nexport * from \"./kit/cartesian\"\r\nexport * from \"./kit/chart-border\"\r\nexport * from \"./kit/chart-canvas\"\r\nexport * from \"./kit/chart-legend\"\r\nexport * from \"./kit/entries\"\r\nexport * from \"./kit/motion\"\r\nexport * from \"./kit/paints\"\r\nexport * from \"./kit/vertical-axis\"\r\nexport * from \"@motionscript/sdk/component\"\r\n"]}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC","sourcesContent":["export * from \"./line-chart\";\nexport * from \"./bar-chart\";\nexport * from \"./pie-chart\";\nexport * from \"./engine\";\nexport { NODES } from \"./nodes\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC","sourcesContent":["export * from \"./line-chart\";\r\nexport * from \"./bar-chart\";\r\nexport * from \"./pie-chart\";\r\nexport * from \"./engine\";\r\nexport { NODES } from \"./nodes\";\r\n"]}
@@ -0,0 +1,44 @@
1
+ import { type ChildView, type Node2D, type Size2D } from "@motionscript/sdk";
2
+ /**
3
+ * Headroom above the plot, in px.
4
+ *
5
+ * Two jobs, and the second is why it is real padding on the composition rather
6
+ * than a number the point-mapping math imagines: a series peaking at the top of
7
+ * the scale isn't flush to the top edge, **and** the top marker, which is
8
+ * centred on that top grid line, has somewhere to be. Without it the marker's
9
+ * upper half is drawn above the chart's own box.
10
+ */
11
+ export declare const TOP_HEADROOM = 24;
12
+ /** The parts of a cartesian chart's frame, as {@link cartesianFrame} arranges them. */
13
+ export interface CartesianParts {
14
+ /** The value axis, left of the plot. */
15
+ readonly axis: Node2D;
16
+ /** The plot panel: the box the grid and the marks share. */
17
+ readonly plot: Node2D;
18
+ /** An invisible twin of the value axis, reserving its gutter under the plot. */
19
+ readonly gutter: Node2D;
20
+ /** What sits under the plot, top to bottom: the other axis, then the legend. */
21
+ readonly below: readonly Node2D[];
22
+ }
23
+ /**
24
+ * The frame the line and bar charts share: the value axis beside the plot, and
25
+ * under them the gutter beside the rows below the plot, so those rows start at
26
+ * the plot's left edge rather than the chart's.
27
+ */
28
+ export declare function cartesianFrame(parts: CartesianParts): Node2D;
29
+ /** A cartesian frame's parts, as a command reaches them through its chart's children. */
30
+ export interface CartesianViews {
31
+ readonly axis: ChildView;
32
+ /** The plot panel's own children: the grid, the marks, the border. */
33
+ readonly plot: readonly ChildView[];
34
+ readonly below: readonly ChildView[];
35
+ }
36
+ /**
37
+ * The frame among a chart's children: the last child shaped as
38
+ * {@link cartesianFrame} builds it. The chart builds it after the children it
39
+ * was given, and a document adds its own later still, so it is found by shape.
40
+ */
41
+ export declare function cartesianViews(children: readonly ChildView[]): CartesianViews | null;
42
+ /** A part's laid-out size, or nothing before it is built or laid out. */
43
+ export declare function laidOutSize(node: Node2D | undefined): Size2D;
44
+ //# sourceMappingURL=cartesian.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cartesian.d.ts","sourceRoot":"","sources":["../../src/kit/cartesian.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,SAAS,EAAE,KAAK,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAIlF;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,KAAK,CAAA;AAE9B,uFAAuF;AACvF,MAAM,WAAW,cAAc;IAC7B,wCAAwC;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,4DAA4D;IAC5D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,gFAAgF;IAChF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,gFAAgF;IAChF,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;CAClC;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,CAe5D;AAED,yFAAyF;AACzF,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;IACxB,sEAAsE;IACtE,QAAQ,CAAC,IAAI,EAAE,SAAS,SAAS,EAAE,CAAA;IACnC,QAAQ,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,CAAA;CACrC;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,SAAS,SAAS,EAAE,GAAG,cAAc,GAAG,IAAI,CAYpF;AAED,yEAAyE;AACzE,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAG5D"}
@@ -0,0 +1,59 @@
1
+ import { Rect } from "@motionscript/sdk";
2
+ import { VerticalAxis } from "./vertical-axis.js";
3
+ /**
4
+ * Headroom above the plot, in px.
5
+ *
6
+ * Two jobs, and the second is why it is real padding on the composition rather
7
+ * than a number the point-mapping math imagines: a series peaking at the top of
8
+ * the scale isn't flush to the top edge, **and** the top marker, which is
9
+ * centred on that top grid line, has somewhere to be. Without it the marker's
10
+ * upper half is drawn above the chart's own box.
11
+ */
12
+ export const TOP_HEADROOM = 24;
13
+ /**
14
+ * The frame the line and bar charts share: the value axis beside the plot, and
15
+ * under them the gutter beside the rows below the plot, so those rows start at
16
+ * the plot's left edge rather than the chart's.
17
+ */
18
+ export function cartesianFrame(parts) {
19
+ return new Rect({
20
+ flow: "vertical",
21
+ width: "fill",
22
+ height: "fill",
23
+ padding: { top: TOP_HEADROOM },
24
+ children: [
25
+ new Rect({ flow: "horizontal", height: "fill", width: "fill", children: [parts.axis, parts.plot] }),
26
+ new Rect({
27
+ flow: "horizontal",
28
+ width: "fill",
29
+ children: [parts.gutter, new Rect({ flow: "vertical", width: "fill", gap: 20, children: [...parts.below] })],
30
+ }),
31
+ ],
32
+ });
33
+ }
34
+ /**
35
+ * The frame among a chart's children: the last child shaped as
36
+ * {@link cartesianFrame} builds it. The chart builds it after the children it
37
+ * was given, and a document adds its own later still, so it is found by shape.
38
+ */
39
+ export function cartesianViews(children) {
40
+ for (let i = children.length - 1; i >= 0; i--) {
41
+ const frame = children[i];
42
+ if (!Rect.is(frame))
43
+ continue;
44
+ const [top, bottom] = frame.children;
45
+ const axis = top?.children[0];
46
+ const plot = top?.children[1];
47
+ const below = bottom?.children[1];
48
+ if (!axis || !VerticalAxis.is(axis) || !plot || !below)
49
+ continue;
50
+ return { axis, plot: plot.children, below: below.children };
51
+ }
52
+ return null;
53
+ }
54
+ /** A part's laid-out size, or nothing before it is built or laid out. */
55
+ export function laidOutSize(node) {
56
+ const bounds = node?.layoutBounds;
57
+ return { width: bounds?.width ?? 0, height: bounds?.height ?? 0 };
58
+ }
59
+ //# sourceMappingURL=cartesian.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cartesian.js","sourceRoot":"","sources":["../../src/kit/cartesian.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAA4C,MAAM,mBAAmB,CAAA;AAElF,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAA;AAc9B;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,KAAqB;IAClD,OAAO,IAAI,IAAI,CAAC;QACd,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,MAAM;QACb,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE;QAC9B,QAAQ,EAAE;YACR,IAAI,IAAI,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;YACnG,IAAI,IAAI,CAAC;gBACP,IAAI,EAAE,YAAY;gBAClB,KAAK,EAAE,MAAM;gBACb,QAAQ,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,IAAI,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;aAC7G,CAAC;SACH;KACF,CAAsB,CAAA;AACzB,CAAC;AAUD;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,QAA8B;IAC3D,KAAK,IAAI,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9C,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;QACzB,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC;YAAE,SAAQ;QAC7B,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAA;QACpC,MAAM,IAAI,GAAG,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAA;QAC7B,MAAM,IAAI,GAAG,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAA;QAC7B,MAAM,KAAK,GAAG,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAA;QACjC,IAAI,CAAC,IAAI,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK;YAAE,SAAQ;QAChE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAA;IAC7D,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,WAAW,CAAC,IAAwB;IAClD,MAAM,MAAM,GAAG,IAAI,EAAE,YAAY,CAAA;IACjC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC,EAAE,CAAA;AACnE,CAAC","sourcesContent":["import { Rect, type ChildView, type Node2D, type Size2D } from \"@motionscript/sdk\"\r\n\r\nimport { VerticalAxis } from \"./vertical-axis\"\r\n\r\n/**\r\n * Headroom above the plot, in px.\r\n *\r\n * Two jobs, and the second is why it is real padding on the composition rather\r\n * than a number the point-mapping math imagines: a series peaking at the top of\r\n * the scale isn't flush to the top edge, **and** the top marker, which is\r\n * centred on that top grid line, has somewhere to be. Without it the marker's\r\n * upper half is drawn above the chart's own box.\r\n */\r\nexport const TOP_HEADROOM = 24\r\n\r\n/** The parts of a cartesian chart's frame, as {@link cartesianFrame} arranges them. */\r\nexport interface CartesianParts {\r\n /** The value axis, left of the plot. */\r\n readonly axis: Node2D\r\n /** The plot panel: the box the grid and the marks share. */\r\n readonly plot: Node2D\r\n /** An invisible twin of the value axis, reserving its gutter under the plot. */\r\n readonly gutter: Node2D\r\n /** What sits under the plot, top to bottom: the other axis, then the legend. */\r\n readonly below: readonly Node2D[]\r\n}\r\n\r\n/**\r\n * The frame the line and bar charts share: the value axis beside the plot, and\r\n * under them the gutter beside the rows below the plot, so those rows start at\r\n * the plot's left edge rather than the chart's.\r\n */\r\nexport function cartesianFrame(parts: CartesianParts): Node2D {\r\n return new Rect({\r\n flow: \"vertical\",\r\n width: \"fill\",\r\n height: \"fill\",\r\n padding: { top: TOP_HEADROOM },\r\n children: [\r\n new Rect({ flow: \"horizontal\", height: \"fill\", width: \"fill\", children: [parts.axis, parts.plot] }),\r\n new Rect({\r\n flow: \"horizontal\",\r\n width: \"fill\",\r\n children: [parts.gutter, new Rect({ flow: \"vertical\", width: \"fill\", gap: 20, children: [...parts.below] })],\r\n }),\r\n ],\r\n }) as unknown as Node2D\r\n}\r\n\r\n/** A cartesian frame's parts, as a command reaches them through its chart's children. */\r\nexport interface CartesianViews {\r\n readonly axis: ChildView\r\n /** The plot panel's own children: the grid, the marks, the border. */\r\n readonly plot: readonly ChildView[]\r\n readonly below: readonly ChildView[]\r\n}\r\n\r\n/**\r\n * The frame among a chart's children: the last child shaped as\r\n * {@link cartesianFrame} builds it. The chart builds it after the children it\r\n * was given, and a document adds its own later still, so it is found by shape.\r\n */\r\nexport function cartesianViews(children: readonly ChildView[]): CartesianViews | null {\r\n for (let i = children.length - 1; i >= 0; i--) {\r\n const frame = children[i]\r\n if (!Rect.is(frame)) continue\r\n const [top, bottom] = frame.children\r\n const axis = top?.children[0]\r\n const plot = top?.children[1]\r\n const below = bottom?.children[1]\r\n if (!axis || !VerticalAxis.is(axis) || !plot || !below) continue\r\n return { axis, plot: plot.children, below: below.children }\r\n }\r\n return null\r\n}\r\n\r\n/** A part's laid-out size, or nothing before it is built or laid out. */\r\nexport function laidOutSize(node: Node2D | undefined): Size2D {\r\n const bounds = node?.layoutBounds\r\n return { width: bounds?.width ?? 0, height: bounds?.height ?? 0 }\r\n}\r\n"]}
@@ -1,4 +1,4 @@
1
- import { type AssetScope, Node2D, type Node2DProps, type RenderContext2D, type Stroke } from "@motionscript/sdk";
1
+ import { type NodeOf, type Node2D as _Node2D, type Node2DProps, type Stroke, type StrokeResolved } from "@motionscript/sdk";
2
2
  export interface ChartBorderProps extends Node2DProps {
3
3
  /**
4
4
  * The plot's thick frame stroke. The stroke resolver's default `align` is
@@ -9,20 +9,17 @@ export interface ChartBorderProps extends Node2DProps {
9
9
  }
10
10
  /**
11
11
  * The thick **frame** around a cartesian chart's plot: an empty rect wearing an
12
- * inside stroke, sized from its allocated `layoutBounds`.
12
+ * inside stroke, sized from its box.
13
13
  *
14
14
  * Split out of {@link ChartCanvas} (the filled + gridded backdrop) so it can be
15
15
  * placed *after* the marks in the tree — the box then frames the plot **over**
16
16
  * them, so a line or a column running to the edge tucks cleanly under the border
17
17
  * rather than sitting on top of it.
18
18
  */
19
- export declare class ChartBorder extends Node2D<ChartBorderProps> {
20
- stroke: Stroke;
21
- /**
22
- * This node extends `Node2D` rather than `ShapeNode`, so nothing declares the
23
- * paint props it carries — see {@link declarePaints}.
24
- */
25
- declareAssets(assets: AssetScope): void;
26
- protected renderSelf(ctx: RenderContext2D): void;
27
- }
19
+ export declare const ChartBorder: import("@motionscript/sdk").Component<"chartBorder", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
20
+ readonly stroke: import("@motionscript/sdk").Type<Stroke, StrokeResolved[], false>;
21
+ }>, {}, null, _Node2D<Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
22
+ readonly stroke: import("@motionscript/sdk").Type<Stroke, StrokeResolved[], false>;
23
+ }>, null>>;
24
+ export type ChartBorder = NodeOf<typeof ChartBorder>;
28
25
  //# sourceMappingURL=chart-border.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chart-border.d.ts","sourceRoot":"","sources":["../../src/kit/chart-border.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EAEf,MAAM,EAGN,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,MAAM,EACZ,MAAM,mBAAmB,CAAA;AAK1B,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAA;CACf;AAED;;;;;;;;GAQG;AACH,qBAAa,WAAY,SAAQ,MAAM,CAAC,gBAAgB,CAAC;IAM/C,MAAM,EAAE,MAAM,CAAA;IAEtB;;;OAGG;IACM,aAAa,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAKhD,SAAS,CAAC,UAAU,CAAC,GAAG,EAAE,eAAe,GAAG,IAAI;CAWjD"}
1
+ {"version":3,"file":"chart-border.d.ts","sourceRoot":"","sources":["../../src/kit/chart-border.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,MAAM,EAEX,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,WAAW,EAChB,KAAK,MAAM,EACX,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAA;AAK1B,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAA;CACf;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW;;;;UAatB,CAAA;AAEF,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,WAAW,CAAC,CAAA"}
@@ -1,45 +1,28 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import { Graphics2D, Node2D, strokeOps, property, } from "@motionscript/sdk";
1
+ import { Graphics2D, Types, component2d, strokeOps, } from "@motionscript/sdk";
2
+ import { loadPaints } from "./paints.js";
8
3
  import { DEFAULT_PLOT_AREA } from "./shared.js";
9
- import { declarePaints } from "@motionscript/sdk/component";
10
4
  /**
11
5
  * The thick **frame** around a cartesian chart's plot: an empty rect wearing an
12
- * inside stroke, sized from its allocated `layoutBounds`.
6
+ * inside stroke, sized from its box.
13
7
  *
14
8
  * Split out of {@link ChartCanvas} (the filled + gridded backdrop) so it can be
15
9
  * placed *after* the marks in the tree — the box then frames the plot **over**
16
10
  * them, so a line or a column running to the edge tucks cleanly under the border
17
11
  * rather than sitting on top of it.
18
12
  */
19
- export class ChartBorder extends Node2D {
20
- /**
21
- * This node extends `Node2D` rather than `ShapeNode`, so nothing declares the
22
- * paint props it carries — see {@link declarePaints}.
23
- */
24
- declareAssets(assets) {
25
- super.declareAssets(assets);
26
- declarePaints(this, assets);
27
- }
28
- renderSelf(ctx) {
29
- const W = this.layoutBounds.width;
30
- const H = this.layoutBounds.height;
31
- if (W <= 0 || H <= 0)
13
+ export const ChartBorder = component2d({
14
+ key: "chartBorder",
15
+ state: {
16
+ stroke: Types.custom(DEFAULT_PLOT_AREA.stroke, { resolve: strokeOps.resolve, lerp: strokeOps.lerp }),
17
+ },
18
+ load: (loader, state) => loadPaints(loader, { strokes: [state.stroke] }),
19
+ render: (ctx, state) => {
20
+ const { width, height } = ctx.size;
21
+ if (width <= 0 || height <= 0)
32
22
  return;
33
23
  // Empty rect (no fill) with the themed stroke, so the frame sits over the
34
24
  // marks but the box interior stays clear.
35
- ctx.draw(new Graphics2D().rect({ x: 0, y: 0, width: W, height: H }).stroke(this.stroke));
36
- }
37
- }
38
- __decorate([
39
- property({
40
- default: DEFAULT_PLOT_AREA.stroke,
41
- mapper: strokeOps.resolve,
42
- tween: strokeOps.lerp,
43
- })
44
- ], ChartBorder.prototype, "stroke", void 0);
25
+ ctx.draw(new Graphics2D().rect({ x: 0, y: 0, width, height }).stroke(state.stroke));
26
+ },
27
+ });
45
28
  //# sourceMappingURL=chart-border.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"chart-border.js","sourceRoot":"","sources":["../../src/kit/chart-border.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAEL,UAAU,EACV,MAAM,EACN,SAAS,EACT,QAAQ,GAIT,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAW3D;;;;;;;;GAQG;AACH,MAAM,OAAO,WAAY,SAAQ,MAAwB;IAQvD;;;OAGG;IACM,aAAa,CAAC,MAAkB;QACvC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAA;QAC3B,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IAC7B,CAAC;IAES,UAAU,CAAC,GAAoB;QACvC,MAAM,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,KAAK,CAAA;QACjC,MAAM,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CAAA;QAClC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;YAAE,OAAM;QAE5B,0EAA0E;QAC1E,0CAA0C;QAC1C,GAAG,CAAC,IAAI,CACN,IAAI,UAAU,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAC/E,CAAA;IACH,CAAC;CACF;AAtBS;IALP,QAAQ,CAAC;QACR,OAAO,EAAE,iBAAiB,CAAC,MAAM;QACjC,MAAM,EAAE,SAAS,CAAC,OAAO;QACzB,KAAK,EAAE,SAAS,CAAC,IAAI;KACtB,CAAC;2CACoB","sourcesContent":["import {\n type AssetScope,\n Graphics2D,\n Node2D,\n strokeOps,\n property,\n type Node2DProps,\n type RenderContext2D,\n type Stroke,\n} from \"@motionscript/sdk\"\n\nimport { DEFAULT_PLOT_AREA } from \"./shared\"\nimport { declarePaints } from \"@motionscript/sdk/component\"\n\nexport interface ChartBorderProps extends Node2DProps {\n /**\n * The plot's thick frame stroke. The stroke resolver's default `align` is\n * `'inside'`, so the whole weight sits within the layout box unless the theme\n * overrides it.\n */\n stroke: Stroke\n}\n\n/**\n * The thick **frame** around a cartesian chart's plot: an empty rect wearing an\n * inside stroke, sized from its allocated `layoutBounds`.\n *\n * Split out of {@link ChartCanvas} (the filled + gridded backdrop) so it can be\n * placed *after* the marks in the tree — the box then frames the plot **over**\n * them, so a line or a column running to the edge tucks cleanly under the border\n * rather than sitting on top of it.\n */\nexport class ChartBorder extends Node2D<ChartBorderProps> {\n @property({\n default: DEFAULT_PLOT_AREA.stroke,\n mapper: strokeOps.resolve,\n tween: strokeOps.lerp,\n })\n declare stroke: Stroke\n\n /**\n * This node extends `Node2D` rather than `ShapeNode`, so nothing declares the\n * paint props it carries — see {@link declarePaints}.\n */\n override declareAssets(assets: AssetScope): void {\n super.declareAssets(assets)\n declarePaints(this, assets)\n }\n\n protected renderSelf(ctx: RenderContext2D): void {\n const W = this.layoutBounds.width\n const H = this.layoutBounds.height\n if (W <= 0 || H <= 0) return\n\n // Empty rect (no fill) with the themed stroke, so the frame sits over the\n // marks but the box interior stays clear.\n ctx.draw(\n new Graphics2D().rect({ x: 0, y: 0, width: W, height: H }).stroke(this.stroke)\n )\n }\n}\n"]}
1
+ {"version":3,"file":"chart-border.js","sourceRoot":"","sources":["../../src/kit/chart-border.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,KAAK,EACL,WAAW,EACX,SAAS,GAOV,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAW5C;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,WAAW,CAAC;IACrC,GAAG,EAAE,aAAa;IAClB,KAAK,EAAE;QACL,MAAM,EAAE,KAAK,CAAC,MAAM,CAA2B,iBAAiB,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,EAAE,CAAC;KAC/H;IACD,IAAI,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;IACxE,MAAM,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;QACrB,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,IAAI,CAAA;QAClC,IAAI,KAAK,IAAI,CAAC,IAAI,MAAM,IAAI,CAAC;YAAE,OAAM;QACrC,0EAA0E;QAC1E,0CAA0C;QAC1C,GAAG,CAAC,IAAI,CAAC,IAAI,UAAU,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;IACrF,CAAC;CACF,CAAC,CAAA","sourcesContent":["import {\r\n Graphics2D,\r\n Types,\r\n component2d,\r\n strokeOps,\r\n type NodeOf,\r\n // Named so this component's emitted type reaches `Node2D` through the sdk, not core.\r\n type Node2D as _Node2D,\r\n type Node2DProps,\r\n type Stroke,\r\n type StrokeResolved,\r\n} from \"@motionscript/sdk\"\r\n\r\nimport { loadPaints } from \"./paints\"\r\nimport { DEFAULT_PLOT_AREA } from \"./shared\"\r\n\r\nexport interface ChartBorderProps extends Node2DProps {\r\n /**\r\n * The plot's thick frame stroke. The stroke resolver's default `align` is\r\n * `'inside'`, so the whole weight sits within the layout box unless the theme\r\n * overrides it.\r\n */\r\n stroke: Stroke\r\n}\r\n\r\n/**\r\n * The thick **frame** around a cartesian chart's plot: an empty rect wearing an\r\n * inside stroke, sized from its box.\r\n *\r\n * Split out of {@link ChartCanvas} (the filled + gridded backdrop) so it can be\r\n * placed *after* the marks in the tree — the box then frames the plot **over**\r\n * them, so a line or a column running to the edge tucks cleanly under the border\r\n * rather than sitting on top of it.\r\n */\r\nexport const ChartBorder = component2d({\r\n key: \"chartBorder\",\r\n state: {\r\n stroke: Types.custom<Stroke, StrokeResolved[]>(DEFAULT_PLOT_AREA.stroke, { resolve: strokeOps.resolve, lerp: strokeOps.lerp }),\r\n },\r\n load: (loader, state) => loadPaints(loader, { strokes: [state.stroke] }),\r\n render: (ctx, state) => {\r\n const { width, height } = ctx.size\r\n if (width <= 0 || height <= 0) return\r\n // Empty rect (no fill) with the themed stroke, so the frame sits over the\r\n // marks but the box interior stays clear.\r\n ctx.draw(new Graphics2D().rect({ x: 0, y: 0, width, height }).stroke(state.stroke))\r\n },\r\n})\r\n\r\nexport type ChartBorder = NodeOf<typeof ChartBorder>\r\n"]}
@@ -1,4 +1,4 @@
1
- import { type AssetScope, Node2D, type Fill, type Node2DProps, type RenderContext2D, type Shadow, type Stroke } from "@motionscript/sdk";
1
+ import { type Fill, type FillResolved, type NodeOf, type Node2D as _Node2D, type Node2DProps, type Shadow, type ShadowResolved, type Stroke, type StrokeResolved } from "@motionscript/sdk";
2
2
  import { type Range } from "./shared.js";
3
3
  export interface ChartCanvasProps extends Node2DProps {
4
4
  /** Fill of the plot panel behind the marks. */
@@ -26,9 +26,8 @@ export interface ChartCanvasProps extends Node2DProps {
26
26
  }
27
27
  /**
28
28
  * The plot **backdrop** of a cartesian chart: a filled panel with a grid of
29
- * faint lines spanning both directions across it. Drawn as one {@link Graphics2D}
30
- * command list, sized from its allocated `layoutBounds` and centred on the node
31
- * origin.
29
+ * faint lines spanning both directions across it, sized from its box and centred
30
+ * on its origin.
32
31
  *
33
32
  * The thick frame is a **separate** {@link ChartBorder} node so it can be drawn
34
33
  * *over* the marks while this panel sits under them. Grid lines are placed from
@@ -36,21 +35,24 @@ export interface ChartCanvasProps extends Node2DProps {
36
35
  * {@link ChartCanvasProps.xExtent}/`yExtent` — so each line lands under its
37
36
  * marker whether or not the markers are evenly spaced.
38
37
  */
39
- export declare class ChartCanvas extends Node2D<ChartCanvasProps> {
40
- fill: Fill;
41
- shadow: Shadow;
42
- xGridStroke: Stroke;
43
- yGridStroke: Stroke;
44
- xMarkers: number[];
45
- yMarkers: number[];
46
- xExtent: Range;
47
- yExtent: Range;
48
- /**
49
- * This node extends `Node2D` rather than `ShapeNode`, so nothing declares the
50
- * paint props it carries — see {@link declarePaints}. The grid strokes are
51
- * named past the conventional slots, so they are passed explicitly.
52
- */
53
- declareAssets(assets: AssetScope): void;
54
- protected renderSelf(ctx: RenderContext2D): void;
55
- }
38
+ export declare const ChartCanvas: import("@motionscript/sdk").Component<"chartCanvas", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
39
+ readonly fill: import("@motionscript/sdk").Type<Fill, FillResolved[], false>;
40
+ readonly shadow: import("@motionscript/sdk").Type<Shadow, ShadowResolved[], false>;
41
+ readonly xGridStroke: import("@motionscript/sdk").Type<Stroke, StrokeResolved[], false>;
42
+ readonly yGridStroke: import("@motionscript/sdk").Type<Stroke, StrokeResolved[], false>;
43
+ readonly xMarkers: import("@motionscript/sdk").Type<number[], number[], false>;
44
+ readonly yMarkers: import("@motionscript/sdk").Type<number[], number[], false>;
45
+ readonly xExtent: import("@motionscript/sdk").Type<Range, Range, false>;
46
+ readonly yExtent: import("@motionscript/sdk").Type<Range, Range, false>;
47
+ }>, {}, null, _Node2D<Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
48
+ readonly fill: import("@motionscript/sdk").Type<Fill, FillResolved[], false>;
49
+ readonly shadow: import("@motionscript/sdk").Type<Shadow, ShadowResolved[], false>;
50
+ readonly xGridStroke: import("@motionscript/sdk").Type<Stroke, StrokeResolved[], false>;
51
+ readonly yGridStroke: import("@motionscript/sdk").Type<Stroke, StrokeResolved[], false>;
52
+ readonly xMarkers: import("@motionscript/sdk").Type<number[], number[], false>;
53
+ readonly yMarkers: import("@motionscript/sdk").Type<number[], number[], false>;
54
+ readonly xExtent: import("@motionscript/sdk").Type<Range, Range, false>;
55
+ readonly yExtent: import("@motionscript/sdk").Type<Range, Range, false>;
56
+ }>, null>>;
57
+ export type ChartCanvas = NodeOf<typeof ChartCanvas>;
56
58
  //# sourceMappingURL=chart-canvas.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chart-canvas.d.ts","sourceRoot":"","sources":["../../src/kit/chart-canvas.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EAEf,MAAM,EAKN,KAAK,IAAI,EACT,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,MAAM,EACX,KAAK,MAAM,EAEZ,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAIL,KAAK,KAAK,EACX,MAAM,UAAU,CAAA;AAGjB,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,+CAA+C;IAC/C,IAAI,EAAE,IAAI,CAAA;IACV,8CAA8C;IAC9C,MAAM,EAAE,MAAM,CAAA;IACd,oEAAoE;IACpE,WAAW,EAAE,MAAM,CAAA;IACnB,sEAAsE;IACtE,WAAW,EAAE,MAAM,CAAA;IACnB;;;;;;OAMG;IACH,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,+DAA+D;IAC/D,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,mFAAmF;IACnF,OAAO,EAAE,KAAK,CAAA;IACd,iFAAiF;IACjF,OAAO,EAAE,KAAK,CAAA;CACf;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,WAAY,SAAQ,MAAM,CAAC,gBAAgB,CAAC;IAM/C,IAAI,EAAE,IAAI,CAAA;IAMV,MAAM,EAAE,MAAM,CAAA;IAMd,WAAW,EAAE,MAAM,CAAA;IAMnB,WAAW,EAAE,MAAM,CAAA;IAC0B,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,QAAQ,EAAE,MAAM,EAAE,CAAA;IACjB,OAAO,EAAE,KAAK,CAAA;IACd,OAAO,EAAE,KAAK,CAAA;IAEpE;;;;OAIG;IACM,aAAa,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAOhD,SAAS,CAAC,UAAU,CAAC,GAAG,EAAE,eAAe,GAAG,IAAI;CAqDjD"}
1
+ {"version":3,"file":"chart-canvas.d.ts","sourceRoot":"","sources":["../../src/kit/chart-canvas.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,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,EACpB,MAAM,mBAAmB,CAAA;AAI1B,OAAO,EAIL,KAAK,KAAK,EACX,MAAM,UAAU,CAAA;AAEjB,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,+CAA+C;IAC/C,IAAI,EAAE,IAAI,CAAA;IACV,8CAA8C;IAC9C,MAAM,EAAE,MAAM,CAAA;IACd,oEAAoE;IACpE,WAAW,EAAE,MAAM,CAAA;IACnB,sEAAsE;IACtE,WAAW,EAAE,MAAM,CAAA;IACnB;;;;;;OAMG;IACH,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,+DAA+D;IAC/D,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,mFAAmF;IACnF,OAAO,EAAE,KAAK,CAAA;IACd,iFAAiF;IACjF,OAAO,EAAE,KAAK,CAAA;CACf;AAKD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;UAoDtB,CAAA;AAEF,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,WAAW,CAAC,CAAA"}
@@ -1,17 +1,12 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import { Graphics2D, Node2D, fillOps, shadowOps, strokeOps, property, } from "@motionscript/sdk";
1
+ import { Graphics2D, Types, component2d, fillOps, shadowOps, strokeOps, } from "@motionscript/sdk";
2
+ import { fresh } from "./entries.js";
3
+ import { loadPaints } from "./paints.js";
8
4
  import { DEFAULT_PLOT_AREA, DEFAULT_X_AXIS, DEFAULT_Y_AXIS, } from "./shared.js";
9
- import { declarePaints } from "@motionscript/sdk/component";
5
+ const strokeEntry = (initial) => Types.custom(initial, { resolve: strokeOps.resolve, lerp: strokeOps.lerp });
10
6
  /**
11
7
  * The plot **backdrop** of a cartesian chart: a filled panel with a grid of
12
- * faint lines spanning both directions across it. Drawn as one {@link Graphics2D}
13
- * command list, sized from its allocated `layoutBounds` and centred on the node
14
- * origin.
8
+ * faint lines spanning both directions across it, sized from its box and centred
9
+ * on its origin.
15
10
  *
16
11
  * The thick frame is a **separate** {@link ChartBorder} node so it can be drawn
17
12
  * *over* the marks while this panel sits under them. Grid lines are placed from
@@ -19,107 +14,55 @@ import { declarePaints } from "@motionscript/sdk/component";
19
14
  * {@link ChartCanvasProps.xExtent}/`yExtent` — so each line lands under its
20
15
  * marker whether or not the markers are evenly spaced.
21
16
  */
22
- export class ChartCanvas extends Node2D {
23
- /**
24
- * This node extends `Node2D` rather than `ShapeNode`, so nothing declares the
25
- * paint props it carries — see {@link declarePaints}. The grid strokes are
26
- * named past the conventional slots, so they are passed explicitly.
27
- */
28
- declareAssets(assets) {
29
- super.declareAssets(assets);
30
- declarePaints(this, assets, {
31
- strokes: [this.xGridStroke, this.yGridStroke],
32
- });
33
- }
34
- renderSelf(ctx) {
35
- const W = this.layoutBounds.width;
36
- const H = this.layoutBounds.height;
17
+ export const ChartCanvas = component2d({
18
+ key: "chartCanvas",
19
+ state: {
20
+ fill: Types.custom(DEFAULT_PLOT_AREA.fill, { resolve: fillOps.resolve, lerp: fillOps.lerp }),
21
+ shadow: Types.custom(DEFAULT_PLOT_AREA.shadow, { resolve: shadowOps.resolve, lerp: shadowOps.lerp }),
22
+ xGridStroke: strokeEntry(DEFAULT_X_AXIS.lineStyle),
23
+ yGridStroke: strokeEntry(DEFAULT_Y_AXIS.lineStyle),
24
+ xMarkers: fresh(() => []),
25
+ yMarkers: fresh(() => []),
26
+ xExtent: fresh(() => [0, 1]),
27
+ yExtent: fresh(() => [0, 1]),
28
+ },
29
+ // The grid strokes are named past the conventional slots, so they are named here.
30
+ load: (loader, state) => loadPaints(loader, { fills: [state.fill], shadows: [state.shadow], strokes: [state.xGridStroke, state.yGridStroke] }),
31
+ render: (ctx, state) => {
32
+ const { width: W, height: H } = ctx.size;
37
33
  if (W <= 0 || H <= 0)
38
34
  return;
39
35
  // Plot panel, centred on the origin (node space is y-up, origin centre).
40
- ctx.draw(new Graphics2D()
41
- .rect({ x: 0, y: 0, width: W, height: H })
42
- .shadow(this.shadow)
43
- .fill(this.fill));
44
- const [xMin, xMax] = this.xExtent;
45
- const [yMin, yMax] = this.yExtent;
36
+ ctx.draw(new Graphics2D().rect({ x: 0, y: 0, width: W, height: H }).shadow(state.shadow).fill(state.fill));
37
+ const [xMin, xMax] = state.xExtent;
38
+ const [yMin, yMax] = state.yExtent;
46
39
  // Fraction of a marker across its extent; guard a zero-width extent.
47
40
  const xFrac = (v) => (xMax <= xMin ? 0 : (v - xMin) / (xMax - xMin));
48
41
  const yFrac = (v) => (yMax <= yMin ? 0 : (v - yMin) / (yMax - yMin));
49
42
  // Skip markers landing on (or outside) the edges — they'd sit under the border.
50
43
  const interior = (f) => f > 1e-6 && f < 1 - 1e-6;
51
- const xStroke = this.xGridStroke[0];
44
+ const xStroke = state.xGridStroke[0];
52
45
  if (xStroke) {
53
46
  const xGrid = new Graphics2D();
54
- for (const v of this.xMarkers) {
47
+ for (const v of state.xMarkers) {
55
48
  const f = xFrac(v);
56
49
  if (!interior(f))
57
50
  continue;
58
- xGrid.rect({
59
- x: -W / 2 + f * W,
60
- y: 0,
61
- width: xStroke.weight,
62
- height: H,
63
- });
51
+ xGrid.rect({ x: -W / 2 + f * W, y: 0, width: xStroke.weight, height: H });
64
52
  }
65
53
  ctx.draw(xGrid.fill(xStroke.fill));
66
54
  }
67
- const yStroke = this.yGridStroke[0];
55
+ const yStroke = state.yGridStroke[0];
68
56
  if (yStroke) {
69
57
  const yGrid = new Graphics2D();
70
- for (const v of this.yMarkers) {
58
+ for (const v of state.yMarkers) {
71
59
  const f = yFrac(v);
72
60
  if (!interior(f))
73
61
  continue;
74
- yGrid.rect({
75
- x: 0,
76
- y: -H / 2 + f * H,
77
- width: W,
78
- height: yStroke.weight,
79
- });
62
+ yGrid.rect({ x: 0, y: -H / 2 + f * H, width: W, height: yStroke.weight });
80
63
  }
81
64
  ctx.draw(yGrid.fill(yStroke.fill));
82
65
  }
83
- }
84
- }
85
- __decorate([
86
- property({
87
- default: DEFAULT_PLOT_AREA.fill,
88
- mapper: fillOps.resolve,
89
- tween: fillOps.lerp,
90
- })
91
- ], ChartCanvas.prototype, "fill", void 0);
92
- __decorate([
93
- property({
94
- default: DEFAULT_PLOT_AREA.shadow,
95
- mapper: shadowOps.resolve,
96
- tween: shadowOps.lerp,
97
- })
98
- ], ChartCanvas.prototype, "shadow", void 0);
99
- __decorate([
100
- property({
101
- default: DEFAULT_X_AXIS.lineStyle,
102
- mapper: strokeOps.resolve,
103
- tween: strokeOps.lerp,
104
- })
105
- ], ChartCanvas.prototype, "xGridStroke", void 0);
106
- __decorate([
107
- property({
108
- default: DEFAULT_Y_AXIS.lineStyle,
109
- mapper: strokeOps.resolve,
110
- tween: strokeOps.lerp,
111
- })
112
- ], ChartCanvas.prototype, "yGridStroke", void 0);
113
- __decorate([
114
- property({ default: () => [] })
115
- ], ChartCanvas.prototype, "xMarkers", void 0);
116
- __decorate([
117
- property({ default: () => [] })
118
- ], ChartCanvas.prototype, "yMarkers", void 0);
119
- __decorate([
120
- property({ default: () => [0, 1] })
121
- ], ChartCanvas.prototype, "xExtent", void 0);
122
- __decorate([
123
- property({ default: () => [0, 1] })
124
- ], ChartCanvas.prototype, "yExtent", void 0);
66
+ },
67
+ });
125
68
  //# sourceMappingURL=chart-canvas.js.map