@motionscript/charts 0.1.0 → 0.1.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/bar-chart/bar-chart.d.ts +22 -93
  3. package/dist/bar-chart/bar-chart.d.ts.map +1 -1
  4. package/dist/bar-chart/bar-chart.js +48 -121
  5. package/dist/bar-chart/bar-chart.js.map +1 -1
  6. package/dist/bar-chart/category-axis.d.ts +11 -38
  7. package/dist/bar-chart/category-axis.d.ts.map +1 -1
  8. package/dist/bar-chart/category-axis.js +15 -38
  9. package/dist/bar-chart/category-axis.js.map +1 -1
  10. package/dist/bar-chart/chart-bars.d.ts +43 -74
  11. package/dist/bar-chart/chart-bars.d.ts.map +1 -1
  12. package/dist/bar-chart/chart-bars.js +31 -59
  13. package/dist/bar-chart/chart-bars.js.map +1 -1
  14. package/dist/bar-chart/index.d.ts +2 -10
  15. package/dist/bar-chart/index.d.ts.map +1 -1
  16. package/dist/bar-chart/index.js +0 -7
  17. package/dist/bar-chart/index.js.map +1 -1
  18. package/dist/bar-chart/shared.d.ts +27 -90
  19. package/dist/bar-chart/shared.d.ts.map +1 -1
  20. package/dist/bar-chart/shared.js +15 -54
  21. package/dist/bar-chart/shared.js.map +1 -1
  22. package/dist/browser/chunks/chunk-4SMRCU24.js +2 -0
  23. package/dist/browser/chunks/chunk-4SMRCU24.js.map +7 -0
  24. package/dist/browser/index.js +1 -1
  25. package/dist/browser/index.js.map +3 -3
  26. package/dist/browser/kit.js +1 -1
  27. package/dist/browser/manifest.json +1 -1
  28. package/dist/engine.d.ts +4 -16
  29. package/dist/engine.d.ts.map +1 -1
  30. package/dist/engine.js +4 -16
  31. package/dist/engine.js.map +1 -1
  32. package/dist/kit/cartesian.d.ts +8 -28
  33. package/dist/kit/cartesian.d.ts.map +1 -1
  34. package/dist/kit/cartesian.js +7 -19
  35. package/dist/kit/cartesian.js.map +1 -1
  36. package/dist/kit/chart-border.d.ts +9 -18
  37. package/dist/kit/chart-border.d.ts.map +1 -1
  38. package/dist/kit/chart-border.js +4 -9
  39. package/dist/kit/chart-border.js.map +1 -1
  40. package/dist/kit/chart-canvas.d.ts +25 -36
  41. package/dist/kit/chart-canvas.d.ts.map +1 -1
  42. package/dist/kit/chart-canvas.js +13 -13
  43. package/dist/kit/chart-canvas.js.map +1 -1
  44. package/dist/kit/chart-legend.d.ts +14 -61
  45. package/dist/kit/chart-legend.d.ts.map +1 -1
  46. package/dist/kit/chart-legend.js +17 -65
  47. package/dist/kit/chart-legend.js.map +1 -1
  48. package/dist/kit/entries.d.ts +2 -0
  49. package/dist/kit/entries.d.ts.map +1 -1
  50. package/dist/kit/entries.js +2 -0
  51. package/dist/kit/entries.js.map +1 -1
  52. package/dist/kit/motion.d.ts +11 -3
  53. package/dist/kit/motion.d.ts.map +1 -1
  54. package/dist/kit/motion.js +7 -1
  55. package/dist/kit/motion.js.map +1 -1
  56. package/dist/kit/shared.d.ts +60 -175
  57. package/dist/kit/shared.d.ts.map +1 -1
  58. package/dist/kit/shared.js +40 -157
  59. package/dist/kit/shared.js.map +1 -1
  60. package/dist/kit/vertical-axis.d.ts +16 -45
  61. package/dist/kit/vertical-axis.d.ts.map +1 -1
  62. package/dist/kit/vertical-axis.js +17 -42
  63. package/dist/kit/vertical-axis.js.map +1 -1
  64. package/dist/line-chart/chart-line.d.ts +16 -41
  65. package/dist/line-chart/chart-line.d.ts.map +1 -1
  66. package/dist/line-chart/chart-line.js +14 -43
  67. package/dist/line-chart/chart-line.js.map +1 -1
  68. package/dist/line-chart/chart-region.d.ts +14 -27
  69. package/dist/line-chart/chart-region.d.ts.map +1 -1
  70. package/dist/line-chart/chart-region.js +8 -22
  71. package/dist/line-chart/chart-region.js.map +1 -1
  72. package/dist/line-chart/horizontal-axis.d.ts +16 -43
  73. package/dist/line-chart/horizontal-axis.d.ts.map +1 -1
  74. package/dist/line-chart/horizontal-axis.js +13 -42
  75. package/dist/line-chart/horizontal-axis.js.map +1 -1
  76. package/dist/line-chart/index.d.ts +1 -13
  77. package/dist/line-chart/index.d.ts.map +1 -1
  78. package/dist/line-chart/index.js +0 -12
  79. package/dist/line-chart/index.js.map +1 -1
  80. package/dist/line-chart/line-chart.d.ts +23 -109
  81. package/dist/line-chart/line-chart.d.ts.map +1 -1
  82. package/dist/line-chart/line-chart.js +45 -141
  83. package/dist/line-chart/line-chart.js.map +1 -1
  84. package/dist/line-chart/shared.d.ts +33 -107
  85. package/dist/line-chart/shared.d.ts.map +1 -1
  86. package/dist/line-chart/shared.js +28 -81
  87. package/dist/line-chart/shared.js.map +1 -1
  88. package/dist/line-chart/x-scale.d.ts +14 -55
  89. package/dist/line-chart/x-scale.d.ts.map +1 -1
  90. package/dist/line-chart/x-scale.js +29 -111
  91. package/dist/line-chart/x-scale.js.map +1 -1
  92. package/dist/nodes.d.ts +0 -12
  93. package/dist/nodes.d.ts.map +1 -1
  94. package/dist/nodes.js +0 -12
  95. package/dist/nodes.js.map +1 -1
  96. package/dist/pie-chart/index.d.ts +1 -12
  97. package/dist/pie-chart/index.d.ts.map +1 -1
  98. package/dist/pie-chart/index.js +0 -9
  99. package/dist/pie-chart/index.js.map +1 -1
  100. package/dist/pie-chart/pie-chart.d.ts +37 -71
  101. package/dist/pie-chart/pie-chart.d.ts.map +1 -1
  102. package/dist/pie-chart/pie-chart.js +31 -65
  103. package/dist/pie-chart/pie-chart.js.map +1 -1
  104. package/dist/pie-chart/pie-legend.d.ts +11 -26
  105. package/dist/pie-chart/pie-legend.d.ts.map +1 -1
  106. package/dist/pie-chart/pie-legend.js +14 -39
  107. package/dist/pie-chart/pie-legend.js.map +1 -1
  108. package/dist/pie-chart/pie-ring.d.ts +50 -192
  109. package/dist/pie-chart/pie-ring.d.ts.map +1 -1
  110. package/dist/pie-chart/pie-ring.js +75 -247
  111. package/dist/pie-chart/pie-ring.js.map +1 -1
  112. package/dist/pie-chart/shared.d.ts +45 -131
  113. package/dist/pie-chart/shared.d.ts.map +1 -1
  114. package/dist/pie-chart/shared.js +29 -72
  115. package/dist/pie-chart/shared.js.map +1 -1
  116. package/package.json +4 -4
  117. package/src/bar-chart/bar-chart.ts +51 -165
  118. package/src/bar-chart/category-axis.ts +16 -57
  119. package/src/bar-chart/chart-bars.ts +43 -120
  120. package/src/bar-chart/index.ts +2 -10
  121. package/src/bar-chart/shared.ts +29 -97
  122. package/src/engine.ts +4 -16
  123. package/src/kit/cartesian.ts +11 -26
  124. package/src/kit/chart-border.ts +6 -20
  125. package/src/kit/chart-canvas.ts +15 -40
  126. package/src/kit/chart-legend.ts +17 -86
  127. package/src/kit/entries.ts +4 -1
  128. package/src/kit/motion.ts +11 -2
  129. package/src/kit/shared.ts +58 -219
  130. package/src/kit/vertical-axis.ts +18 -71
  131. package/src/line-chart/chart-line.ts +16 -44
  132. package/src/line-chart/chart-region.ts +10 -23
  133. package/src/line-chart/horizontal-axis.ts +13 -42
  134. package/src/line-chart/index.ts +1 -13
  135. package/src/line-chart/line-chart.ts +50 -184
  136. package/src/line-chart/shared.ts +51 -145
  137. package/src/line-chart/x-scale.ts +31 -121
  138. package/src/nodes.ts +0 -12
  139. package/src/pie-chart/index.ts +1 -12
  140. package/src/pie-chart/pie-chart.ts +34 -102
  141. package/src/pie-chart/pie-legend.ts +14 -55
  142. package/src/pie-chart/pie-ring.ts +80 -307
  143. package/src/pie-chart/shared.ts +50 -139
  144. package/dist/browser/chunks/chunk-TJNHLQGV.js +0 -2
  145. package/dist/browser/chunks/chunk-TJNHLQGV.js.map +0 -7
@@ -1,2 +1,2 @@
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-TJNHLQGV.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};
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,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-4SMRCU24.js";export{q as CHART_PALETTE,Y as ChartBorder,Z as ChartCanvas,_ as ChartLegend,z as DEFAULT_LEGEND,e as DEFAULT_MARKERS,y as DEFAULT_PLOT_AREA,r as DEFAULT_SERIES_COLORS,B as DEFAULT_SERIES_FILLS,A as DEFAULT_SERIES_STROKES,w as DEFAULT_X_AXIS,x as DEFAULT_Y_AXIS,f as ENTER_SHARE,d as LEGEND_SLIDE,c as SERIES_ARG,s as SPOTLIGHT_DIM,T as VerticalAxis,k as armed,l as arrival,j as arrivalOf,i as arrivalsEntry,b as asParts,h as beats,U as cartesianFrame,V as cartesianViews,O as formatMarker,Q as formatPercent,g as frameEase,a as fresh,W as laidOutSize,D as lerpAxisConfig,n as lerpAxisDomain,o as lerpAxisEntry,H as lerpLegendConfig,F as lerpPlotArea,L as lerpSeriesFills,J as lerpSeriesStrokes,X as loadPaints,S as markerCaption,P as markerStep,R as markerValues,t as num,v as numericFields,C as resolveAxisConfig,m as resolveAxisDomain,G as resolveLegendConfig,E as resolvePlotArea,N as resolveSeriesFill,K as resolveSeriesFills,M as resolveSeriesStroke,I as resolveSeriesStrokes,p as settleAxisDomain,u 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.10",
3
+ "version": "0.1.0",
4
4
  "exports": {
5
5
  ".": "dist/browser/index.js",
6
6
  "./kit": "dist/browser/kit.js"
package/dist/engine.d.ts CHANGED
@@ -1,20 +1,8 @@
1
1
  /**
2
- * The chart **kit**: everything the three charts share, and the one thing a
3
- * copied chart does not copy.
4
- *
5
- * A copy of the line chart takes `line-chart/*` into your project and rewrites its
6
- * reach for these to `@motionscript/charts`, so the plot panel, the value
7
- * axis, the legend and the number formatting stay a real dependency. That is
8
- * not a size decision — it is the only arrangement that works.
9
- *
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
14
- * impossible rather than unlikely.
15
- *
16
- * It also means a fix to the axis reaches a forked chart without a re-add,
17
- * which is the half of the bargain you get back for it.
2
+ * The chart kit: what the three charts share, and what a copied chart does not
3
+ * copy. A chart finds its parts by component identity (`VerticalAxis.is`), so a
4
+ * second copy of `VerticalAxis` would be a second component that the chart never
5
+ * finds, with no error. Copies import the kit from `@motionscript/charts`.
18
6
  */
19
7
  export * from "./kit/shared.js";
20
8
  export * from "./kit/cartesian.js";
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;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
@@ -1,20 +1,8 @@
1
1
  /**
2
- * The chart **kit**: everything the three charts share, and the one thing a
3
- * copied chart does not copy.
4
- *
5
- * A copy of the line chart takes `line-chart/*` into your project and rewrites its
6
- * reach for these to `@motionscript/charts`, so the plot panel, the value
7
- * axis, the legend and the number formatting stay a real dependency. That is
8
- * not a size decision — it is the only arrangement that works.
9
- *
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
14
- * impossible rather than unlikely.
15
- *
16
- * It also means a fix to the axis reaches a forked chart without a re-add,
17
- * which is the half of the bargain you get back for it.
2
+ * The chart kit: what the three charts share, and what a copied chart does not
3
+ * copy. A chart finds its parts by component identity (`VerticalAxis.is`), so a
4
+ * second copy of `VerticalAxis` would be a second component that the chart never
5
+ * finds, with no error. Copies import the kit from `@motionscript/charts`.
18
6
  */
19
7
  export * from "./kit/shared.js";
20
8
  export * from "./kit/cartesian.js";
@@ -1 +1 @@
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":["/**\n * The chart **kit**: everything the three charts share, and the one thing a\n * copied chart does not copy.\n *\n * A copy of the line chart takes `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 by component identity (`VerticalAxis.is`).\n * Copy `VerticalAxis` alongside your fork and there are now two of it — two\n * components answering one name, and whichever one your chart did not get is\n * a part it never finds, 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/cartesian\"\nexport * from \"./kit/chart-border\"\nexport * from \"./kit/chart-canvas\"\nexport * from \"./kit/chart-legend\"\nexport * from \"./kit/entries\"\nexport * from \"./kit/motion\"\nexport * from \"./kit/paints\"\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;;;;;GAKG;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":["/**\n * The chart kit: what the three charts share, and what a copied chart does not\n * copy. A chart finds its parts by component identity (`VerticalAxis.is`), so a\n * second copy of `VerticalAxis` would be a second component that the chart never\n * finds, with no error. Copies import the kit from `@motionscript/charts`.\n */\nexport * from \"./kit/shared\"\nexport * from \"./kit/cartesian\"\nexport * from \"./kit/chart-border\"\nexport * from \"./kit/chart-canvas\"\nexport * from \"./kit/chart-legend\"\nexport * from \"./kit/entries\"\nexport * from \"./kit/motion\"\nexport * from \"./kit/paints\"\nexport * from \"./kit/vertical-axis\"\nexport * from \"@motionscript/sdk/component\"\n"]}
@@ -1,44 +1,24 @@
1
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. */
2
+ interface CartesianParts {
15
3
  readonly axis: Node2D;
16
- /** The plot panel: the box the grid and the marks share. */
4
+ /** The box the grid and the marks share. */
17
5
  readonly plot: Node2D;
18
6
  /** An invisible twin of the value axis, reserving its gutter under the plot. */
19
7
  readonly gutter: Node2D;
20
8
  /** What sits under the plot, top to bottom: the other axis, then the legend. */
21
9
  readonly below: readonly Node2D[];
22
10
  }
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
- */
11
+ /** The frame the line and bar charts share: the value axis beside the plot, and under them the gutter, so the rows below start at the plot's left edge. */
28
12
  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 {
13
+ interface CartesianViews {
31
14
  readonly axis: ChildView;
32
- /** The plot panel's own children: the grid, the marks, the border. */
15
+ /** The plot panel's own children: grid, marks, border. */
33
16
  readonly plot: readonly ChildView[];
34
17
  readonly below: readonly ChildView[];
35
18
  }
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
- */
19
+ /** The last child shaped as {@link cartesianFrame} builds it: the chart builds it after the children it was given and a document adds its own later, so it is found by shape. */
41
20
  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. */
21
+ /** A part's laid-out size; zero before it is built or laid out. */
43
22
  export declare function laidOutSize(node: Node2D | undefined): Size2D;
23
+ export {};
44
24
  //# sourceMappingURL=cartesian.d.ts.map
@@ -1 +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,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,iLAAiL;AACjL,wBAAgB,cAAc,CAAC,QAAQ,EAAE,SAAS,SAAS,EAAE,GAAG,cAAc,GAAG,IAAI,CAYpF;AAED,mEAAmE;AACnE,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAG5D"}
@@ -1,20 +1,12 @@
1
1
  import { Rect } from "@motionscript/sdk";
2
2
  import { VerticalAxis } from "./vertical-axis.js";
3
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.
4
+ * Headroom above the plot, in px. Real padding on the composition, so the top
5
+ * marker, centred on the top grid line, does not draw its upper half above the
6
+ * chart's own box.
17
7
  */
8
+ const TOP_HEADROOM = 24;
9
+ /** The frame the line and bar charts share: the value axis beside the plot, and under them the gutter, so the rows below start at the plot's left edge. */
18
10
  export function cartesianFrame(parts) {
19
11
  return new Rect({
20
12
  flow: "vertical",
@@ -31,11 +23,7 @@ export function cartesianFrame(parts) {
31
23
  ],
32
24
  });
33
25
  }
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
- */
26
+ /** The last child shaped as {@link cartesianFrame} builds it: the chart builds it after the children it was given and a document adds its own later, so it is found by shape. */
39
27
  export function cartesianViews(children) {
40
28
  for (let i = children.length - 1; i >= 0; i--) {
41
29
  const frame = children[i];
@@ -51,7 +39,7 @@ export function cartesianViews(children) {
51
39
  }
52
40
  return null;
53
41
  }
54
- /** A part's laid-out size, or nothing before it is built or laid out. */
42
+ /** A part's laid-out size; zero before it is built or laid out. */
55
43
  export function laidOutSize(node) {
56
44
  const bounds = node?.layoutBounds;
57
45
  return { width: bounds?.width ?? 0, height: bounds?.height ?? 0 };
@@ -1 +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\"\n\nimport { VerticalAxis } from \"./vertical-axis\"\n\n/**\n * Headroom above the plot, in px.\n *\n * Two jobs, and the second is why it is real padding on the composition rather\n * than a number the point-mapping math imagines: a series peaking at the top of\n * the scale isn't flush to the top edge, **and** the top marker, which is\n * centred on that top grid line, has somewhere to be. Without it the marker's\n * upper half is drawn above the chart's own box.\n */\nexport const TOP_HEADROOM = 24\n\n/** The parts of a cartesian chart's frame, as {@link cartesianFrame} arranges them. */\nexport interface CartesianParts {\n /** The value axis, left of the plot. */\n readonly axis: Node2D\n /** The plot panel: the box the grid and the marks share. */\n readonly plot: Node2D\n /** An invisible twin of the value axis, reserving its gutter under the plot. */\n readonly gutter: Node2D\n /** What sits under the plot, top to bottom: the other axis, then the legend. */\n readonly below: readonly Node2D[]\n}\n\n/**\n * The frame the line and bar charts share: the value axis beside the plot, and\n * under them the gutter beside the rows below the plot, so those rows start at\n * the plot's left edge rather than the chart's.\n */\nexport function cartesianFrame(parts: CartesianParts): Node2D {\n return new Rect({\n flow: \"vertical\",\n width: \"fill\",\n height: \"fill\",\n padding: { top: TOP_HEADROOM },\n children: [\n new Rect({ flow: \"horizontal\", height: \"fill\", width: \"fill\", children: [parts.axis, parts.plot] }),\n new Rect({\n flow: \"horizontal\",\n width: \"fill\",\n children: [parts.gutter, new Rect({ flow: \"vertical\", width: \"fill\", gap: 20, children: [...parts.below] })],\n }),\n ],\n }) as unknown as Node2D\n}\n\n/** A cartesian frame's parts, as a command reaches them through its chart's children. */\nexport interface CartesianViews {\n readonly axis: ChildView\n /** The plot panel's own children: the grid, the marks, the border. */\n readonly plot: readonly ChildView[]\n readonly below: readonly ChildView[]\n}\n\n/**\n * The frame among a chart's children: the last child shaped as\n * {@link cartesianFrame} builds it. The chart builds it after the children it\n * was given, and a document adds its own later still, so it is found by shape.\n */\nexport function cartesianViews(children: readonly ChildView[]): CartesianViews | null {\n for (let i = children.length - 1; i >= 0; i--) {\n const frame = children[i]\n if (!Rect.is(frame)) continue\n const [top, bottom] = frame.children\n const axis = top?.children[0]\n const plot = top?.children[1]\n const below = bottom?.children[1]\n if (!axis || !VerticalAxis.is(axis) || !plot || !below) continue\n return { axis, plot: plot.children, below: below.children }\n }\n return null\n}\n\n/** A part's laid-out size, or nothing before it is built or laid out. */\nexport function laidOutSize(node: Node2D | undefined): Size2D {\n const bounds = node?.layoutBounds\n return { width: bounds?.width ?? 0, height: bounds?.height ?? 0 }\n}\n"]}
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;;;;GAIG;AACH,MAAM,YAAY,GAAG,EAAE,CAAA;AAYvB,2JAA2J;AAC3J,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;AASD,iLAAiL;AACjL,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,mEAAmE;AACnE,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\"\n\nimport { VerticalAxis } from \"./vertical-axis\"\n\n/**\n * Headroom above the plot, in px. Real padding on the composition, so the top\n * marker, centred on the top grid line, does not draw its upper half above the\n * chart's own box.\n */\nconst TOP_HEADROOM = 24\n\ninterface CartesianParts {\n readonly axis: Node2D\n /** The box the grid and the marks share. */\n readonly plot: Node2D\n /** An invisible twin of the value axis, reserving its gutter under the plot. */\n readonly gutter: Node2D\n /** What sits under the plot, top to bottom: the other axis, then the legend. */\n readonly below: readonly Node2D[]\n}\n\n/** The frame the line and bar charts share: the value axis beside the plot, and under them the gutter, so the rows below start at the plot's left edge. */\nexport function cartesianFrame(parts: CartesianParts): Node2D {\n return new Rect({\n flow: \"vertical\",\n width: \"fill\",\n height: \"fill\",\n padding: { top: TOP_HEADROOM },\n children: [\n new Rect({ flow: \"horizontal\", height: \"fill\", width: \"fill\", children: [parts.axis, parts.plot] }),\n new Rect({\n flow: \"horizontal\",\n width: \"fill\",\n children: [parts.gutter, new Rect({ flow: \"vertical\", width: \"fill\", gap: 20, children: [...parts.below] })],\n }),\n ],\n }) as unknown as Node2D\n}\n\ninterface CartesianViews {\n readonly axis: ChildView\n /** The plot panel's own children: grid, marks, border. */\n readonly plot: readonly ChildView[]\n readonly below: readonly ChildView[]\n}\n\n/** The last child shaped as {@link cartesianFrame} builds it: the chart builds it after the children it was given and a document adds its own later, so it is found by shape. */\nexport function cartesianViews(children: readonly ChildView[]): CartesianViews | null {\n for (let i = children.length - 1; i >= 0; i--) {\n const frame = children[i]\n if (!Rect.is(frame)) continue\n const [top, bottom] = frame.children\n const axis = top?.children[0]\n const plot = top?.children[1]\n const below = bottom?.children[1]\n if (!axis || !VerticalAxis.is(axis) || !plot || !below) continue\n return { axis, plot: plot.children, below: below.children }\n }\n return null\n}\n\n/** A part's laid-out size; zero before it is built or laid out. */\nexport function laidOutSize(node: Node2D | undefined): Size2D {\n const bounds = node?.layoutBounds\n return { width: bounds?.width ?? 0, height: bounds?.height ?? 0 }\n}\n"]}
@@ -1,27 +1,18 @@
1
- import { type NodeOf, type Node2D as _Node2D, type Node2DProps, type Stroke, type StrokeResolved } from "@motionscript/sdk";
2
- export interface ChartBorderProps extends Node2DProps {
3
- /**
4
- * The plot's thick frame stroke. The stroke resolver's default `align` is
5
- * `'inside'`, so the whole weight sits within the layout box unless the theme
6
- * overrides it.
7
- */
8
- stroke: Stroke;
9
- }
1
+ import { type NodeOf, type Node2D as _Node2D, type Node2DProps as _Node2DProps, type Stroke, type StrokeResolved } from "@motionscript/sdk";
10
2
  /**
11
- * The thick **frame** around a cartesian chart's plot: an empty rect wearing an
12
- * inside stroke, sized from its box.
13
- *
14
- * Split out of {@link ChartCanvas} (the filled + gridded backdrop) so it can be
15
- * placed *after* the marks in the tree — the box then frames the plot **over**
16
- * them, so a line or a column running to the edge tucks cleanly under the border
17
- * rather than sitting on top of it.
3
+ * The frame around a cartesian plot: an empty rect with an inside stroke. Split
4
+ * from {@link ChartCanvas} so it is placed after the marks and frames the plot
5
+ * over them, tucking a line or column running to the edge under the border.
18
6
  */
19
7
  export declare const ChartBorder: import("@motionscript/sdk").Component<"chartBorder", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
8
+ /** The stroke resolver's default `align` is `'inside'`, so the whole weight sits within the box unless the theme overrides it. */
20
9
  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, {
10
+ }>, {}, null, _Node2D<_Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
11
+ /** The stroke resolver's default `align` is `'inside'`, so the whole weight sits within the box unless the theme overrides it. */
22
12
  readonly stroke: import("@motionscript/sdk").Type<Stroke, StrokeResolved[], false>;
23
13
  }>, null, import("@motionscript/sdk").BuiltNode<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
14
+ /** The stroke resolver's default `align` is `'inside'`, so the whole weight sits within the box unless the theme overrides it. */
24
15
  readonly stroke: import("@motionscript/sdk").Type<Stroke, StrokeResolved[], false>;
25
- }>, {}, _Node2D<Node2DProps>>>>;
16
+ }>, {}, _Node2D<_Node2DProps>>>>;
26
17
  export type ChartBorder = NodeOf<typeof ChartBorder>;
27
18
  //# 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,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;;;;;;+BAatB,CAAA;AAEF,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,WAAW,CAAC,CAAA"}
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,IAAI,YAAY,EAChC,KAAK,MAAM,EACX,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAA;AAK1B;;;;GAIG;AACH,eAAO,MAAM,WAAW;IAGpB,kIAAkI;;;IAAlI,kIAAkI;;;IAAlI,kIAAkI;;gCASpI,CAAA;AAEF,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,WAAW,CAAC,CAAA"}
@@ -2,17 +2,14 @@ import { Graphics2D, Types, component2d, strokeOps, } from "@motionscript/sdk";
2
2
  import { loadPaints } from "./paints.js";
3
3
  import { DEFAULT_PLOT_AREA } from "./shared.js";
4
4
  /**
5
- * The thick **frame** around a cartesian chart's plot: an empty rect wearing an
6
- * inside stroke, sized from its box.
7
- *
8
- * Split out of {@link ChartCanvas} (the filled + gridded backdrop) so it can be
9
- * placed *after* the marks in the tree — the box then frames the plot **over**
10
- * them, so a line or a column running to the edge tucks cleanly under the border
11
- * rather than sitting on top of it.
5
+ * The frame around a cartesian plot: an empty rect with an inside stroke. Split
6
+ * from {@link ChartCanvas} so it is placed after the marks and frames the plot
7
+ * over them, tucking a line or column running to the edge under the border.
12
8
  */
13
9
  export const ChartBorder = component2d({
14
10
  key: "chartBorder",
15
11
  state: {
12
+ /** The stroke resolver's default `align` is `'inside'`, so the whole weight sits within the box unless the theme overrides it. */
16
13
  stroke: Types.custom(DEFAULT_PLOT_AREA.stroke, { resolve: strokeOps.resolve, lerp: strokeOps.lerp }),
17
14
  },
18
15
  load: (loader, state) => loadPaints(loader, { strokes: [state.stroke] }),
@@ -20,8 +17,6 @@ export const ChartBorder = component2d({
20
17
  const { width, height } = ctx.size;
21
18
  if (width <= 0 || height <= 0)
22
19
  return;
23
- // Empty rect (no fill) with the themed stroke, so the frame sits over the
24
- // marks but the box interior stays clear.
25
20
  ctx.draw(new Graphics2D().rect({ x: 0, y: 0, width, height }).stroke(state.stroke));
26
21
  },
27
22
  });
@@ -1 +1 @@
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 {\n Graphics2D,\n Types,\n component2d,\n strokeOps,\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 Stroke,\n type StrokeResolved,\n} from \"@motionscript/sdk\"\n\nimport { loadPaints } from \"./paints\"\nimport { DEFAULT_PLOT_AREA } from \"./shared\"\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 box.\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 const ChartBorder = component2d({\n key: \"chartBorder\",\n state: {\n stroke: Types.custom<Stroke, StrokeResolved[]>(DEFAULT_PLOT_AREA.stroke, { resolve: strokeOps.resolve, lerp: strokeOps.lerp }),\n },\n load: (loader, state) => loadPaints(loader, { strokes: [state.stroke] }),\n render: (ctx, state) => {\n const { width, height } = ctx.size\n if (width <= 0 || height <= 0) return\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(new Graphics2D().rect({ x: 0, y: 0, width, height }).stroke(state.stroke))\n },\n})\n\nexport type ChartBorder = NodeOf<typeof ChartBorder>\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;AAE5C;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,WAAW,CAAC;IACrC,GAAG,EAAE,aAAa;IAClB,KAAK,EAAE;QACL,kIAAkI;QAClI,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,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 {\n Graphics2D,\n Types,\n component2d,\n strokeOps,\n type NodeOf,\n // Named so this component's emitted type reaches `Node2D` and its props through the sdk, not core.\n type Node2D as _Node2D,\n type Node2DProps as _Node2DProps,\n type Stroke,\n type StrokeResolved,\n} from \"@motionscript/sdk\"\n\nimport { loadPaints } from \"./paints\"\nimport { DEFAULT_PLOT_AREA } from \"./shared\"\n\n/**\n * The frame around a cartesian plot: an empty rect with an inside stroke. Split\n * from {@link ChartCanvas} so it is placed after the marks and frames the plot\n * over them, tucking a line or column running to the edge under the border.\n */\nexport const ChartBorder = component2d({\n key: \"chartBorder\",\n state: {\n /** The stroke resolver's default `align` is `'inside'`, so the whole weight sits within the box unless the theme overrides it. */\n stroke: Types.custom<Stroke, StrokeResolved[]>(DEFAULT_PLOT_AREA.stroke, { resolve: strokeOps.resolve, lerp: strokeOps.lerp }),\n },\n load: (loader, state) => loadPaints(loader, { strokes: [state.stroke] }),\n render: (ctx, state) => {\n const { width, height } = ctx.size\n if (width <= 0 || height <= 0) return\n ctx.draw(new Graphics2D().rect({ x: 0, y: 0, width, height }).stroke(state.stroke))\n },\n})\n\nexport type ChartBorder = NodeOf<typeof ChartBorder>\n"]}
@@ -1,56 +1,39 @@
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";
1
+ import { type Fill, type FillResolved, type NodeOf, type Node2D as _Node2D, type Node2DProps as _Node2DProps, type Shadow, type ShadowResolved, type Stroke, type StrokeResolved } from "@motionscript/sdk";
2
2
  import { type Range } from "./shared.js";
3
- export interface ChartCanvasProps extends Node2DProps {
4
- /** Fill of the plot panel behind the marks. */
5
- fill: Fill;
6
- /** Drop shadow of the panel. Default none. */
7
- shadow: Shadow;
8
- /** Stroke of the vertical grid lines (one per {@link xMarkers}). */
9
- xGridStroke: Stroke;
10
- /** Stroke of the horizontal grid lines (one per {@link yMarkers}). */
11
- yGridStroke: Stroke;
12
- /**
13
- * Data-unit x positions to draw a vertical grid line at — one per horizontal
14
- * axis marker, so a line lands under every marker regardless of spacing.
15
- * Positions at (or past) an {@link xExtent} edge coincide with the border and
16
- * are skipped. Pass an empty list for a chart whose horizontal axis is
17
- * categorical and so has no numeric position to rule at.
18
- */
19
- xMarkers: number[];
20
- /** Data-unit y positions to draw a horizontal grid line at. */
21
- yMarkers: number[];
22
- /** `[min, max]` of the horizontal scale — maps {@link xMarkers} into the panel. */
23
- xExtent: Range;
24
- /** `[min, max]` of the vertical scale — maps {@link yMarkers} into the panel. */
25
- yExtent: Range;
26
- }
27
3
  /**
28
- * The plot **backdrop** of a cartesian chart: a filled panel with a grid of
29
- * faint lines spanning both directions across it, sized from its box and centred
30
- * on its origin.
31
- *
32
- * The thick frame is a **separate** {@link ChartBorder} node so it can be drawn
33
- * *over* the marks while this panel sits under them. Grid lines are placed from
34
- * the axis marker positions (in data units) mapped into the panel through
35
- * {@link ChartCanvasProps.xExtent}/`yExtent` — so each line lands under its
36
- * marker whether or not the markers are evenly spaced.
4
+ * The plot backdrop: a filled panel and a grid, sized from its box. The frame is
5
+ * a separate {@link ChartBorder} drawn over the marks. Grid lines are placed from
6
+ * the axis markers' data-unit positions mapped through the extents, so each lands
7
+ * under its marker however the markers are spaced.
37
8
  */
38
9
  export declare const ChartCanvas: import("@motionscript/sdk").Component<"chartCanvas", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
39
10
  readonly fill: import("@motionscript/sdk").Type<Fill, FillResolved[], false>;
40
11
  readonly shadow: import("@motionscript/sdk").Type<Shadow, ShadowResolved[], false>;
41
12
  readonly xGridStroke: import("@motionscript/sdk").Type<Stroke, StrokeResolved[], false>;
42
13
  readonly yGridStroke: import("@motionscript/sdk").Type<Stroke, StrokeResolved[], false>;
14
+ /**
15
+ * Data-unit positions of the vertical grid lines, one per horizontal marker.
16
+ * Positions at or past an extent edge coincide with the border and are
17
+ * skipped. Empty for a categorical axis, which has no numeric position to rule at.
18
+ */
43
19
  readonly xMarkers: import("@motionscript/sdk").Type<number[], number[], false>;
44
20
  readonly yMarkers: import("@motionscript/sdk").Type<number[], number[], false>;
21
+ /** `[min, max]` of each scale, mapping the markers into the panel. */
45
22
  readonly xExtent: import("@motionscript/sdk").Type<Range, Range, false>;
46
23
  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, {
24
+ }>, {}, null, _Node2D<_Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
48
25
  readonly fill: import("@motionscript/sdk").Type<Fill, FillResolved[], false>;
49
26
  readonly shadow: import("@motionscript/sdk").Type<Shadow, ShadowResolved[], false>;
50
27
  readonly xGridStroke: import("@motionscript/sdk").Type<Stroke, StrokeResolved[], false>;
51
28
  readonly yGridStroke: import("@motionscript/sdk").Type<Stroke, StrokeResolved[], false>;
29
+ /**
30
+ * Data-unit positions of the vertical grid lines, one per horizontal marker.
31
+ * Positions at or past an extent edge coincide with the border and are
32
+ * skipped. Empty for a categorical axis, which has no numeric position to rule at.
33
+ */
52
34
  readonly xMarkers: import("@motionscript/sdk").Type<number[], number[], false>;
53
35
  readonly yMarkers: import("@motionscript/sdk").Type<number[], number[], false>;
36
+ /** `[min, max]` of each scale, mapping the markers into the panel. */
54
37
  readonly xExtent: import("@motionscript/sdk").Type<Range, Range, false>;
55
38
  readonly yExtent: import("@motionscript/sdk").Type<Range, Range, false>;
56
39
  }>, null, import("@motionscript/sdk").BuiltNode<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
@@ -58,10 +41,16 @@ export declare const ChartCanvas: import("@motionscript/sdk").Component<"chartCa
58
41
  readonly shadow: import("@motionscript/sdk").Type<Shadow, ShadowResolved[], false>;
59
42
  readonly xGridStroke: import("@motionscript/sdk").Type<Stroke, StrokeResolved[], false>;
60
43
  readonly yGridStroke: import("@motionscript/sdk").Type<Stroke, StrokeResolved[], false>;
44
+ /**
45
+ * Data-unit positions of the vertical grid lines, one per horizontal marker.
46
+ * Positions at or past an extent edge coincide with the border and are
47
+ * skipped. Empty for a categorical axis, which has no numeric position to rule at.
48
+ */
61
49
  readonly xMarkers: import("@motionscript/sdk").Type<number[], number[], false>;
62
50
  readonly yMarkers: import("@motionscript/sdk").Type<number[], number[], false>;
51
+ /** `[min, max]` of each scale, mapping the markers into the panel. */
63
52
  readonly xExtent: import("@motionscript/sdk").Type<Range, Range, false>;
64
53
  readonly yExtent: import("@motionscript/sdk").Type<Range, Range, false>;
65
- }>, {}, _Node2D<Node2DProps>>>>;
54
+ }>, {}, _Node2D<_Node2DProps>>>>;
66
55
  export type ChartCanvas = NodeOf<typeof ChartCanvas>;
67
56
  //# 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,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;;;;;;;;;;;;;;;;;;;;;;;;;;;+BAoDtB,CAAA;AAEF,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,WAAW,CAAC,CAAA"}
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,IAAI,YAAY,EAChC,KAAK,MAAM,EACX,KAAK,cAAc,EACnB,KAAK,MAAM,EACX,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAA;AAI1B,OAAO,EAIL,KAAK,KAAK,EACX,MAAM,UAAU,CAAA;AAKjB;;;;;GAKG;AACH,eAAO,MAAM,WAAW;;;;;IAOpB;;;;OAIG;;;IAGH,sEAAsE;;;;;;;;IAPtE;;;;OAIG;;;IAGH,sEAAsE;;;;;;;;IAPtE;;;;OAIG;;;IAGH,sEAAsE;;;gCA2CxE,CAAA;AAEF,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,WAAW,CAAC,CAAA"}
@@ -4,15 +4,10 @@ import { loadPaints } from "./paints.js";
4
4
  import { DEFAULT_PLOT_AREA, DEFAULT_X_AXIS, DEFAULT_Y_AXIS, } from "./shared.js";
5
5
  const strokeEntry = (initial) => Types.custom(initial, { resolve: strokeOps.resolve, lerp: strokeOps.lerp });
6
6
  /**
7
- * The plot **backdrop** of a cartesian chart: a filled panel with a grid of
8
- * faint lines spanning both directions across it, sized from its box and centred
9
- * on its origin.
10
- *
11
- * The thick frame is a **separate** {@link ChartBorder} node so it can be drawn
12
- * *over* the marks while this panel sits under them. Grid lines are placed from
13
- * the axis marker positions (in data units) mapped into the panel through
14
- * {@link ChartCanvasProps.xExtent}/`yExtent` — so each line lands under its
15
- * marker whether or not the markers are evenly spaced.
7
+ * The plot backdrop: a filled panel and a grid, sized from its box. The frame is
8
+ * a separate {@link ChartBorder} drawn over the marks. Grid lines are placed from
9
+ * the axis markers' data-unit positions mapped through the extents, so each lands
10
+ * under its marker however the markers are spaced.
16
11
  */
17
12
  export const ChartCanvas = component2d({
18
13
  key: "chartCanvas",
@@ -21,25 +16,30 @@ export const ChartCanvas = component2d({
21
16
  shadow: Types.custom(DEFAULT_PLOT_AREA.shadow, { resolve: shadowOps.resolve, lerp: shadowOps.lerp }),
22
17
  xGridStroke: strokeEntry(DEFAULT_X_AXIS.lineStyle),
23
18
  yGridStroke: strokeEntry(DEFAULT_Y_AXIS.lineStyle),
19
+ /**
20
+ * Data-unit positions of the vertical grid lines, one per horizontal marker.
21
+ * Positions at or past an extent edge coincide with the border and are
22
+ * skipped. Empty for a categorical axis, which has no numeric position to rule at.
23
+ */
24
24
  xMarkers: fresh(() => []),
25
25
  yMarkers: fresh(() => []),
26
+ /** `[min, max]` of each scale, mapping the markers into the panel. */
26
27
  xExtent: fresh(() => [0, 1]),
27
28
  yExtent: fresh(() => [0, 1]),
28
29
  },
29
- // The grid strokes are named past the conventional slots, so they are named here.
30
+ // The grid strokes sit past the conventional slots, so they are named here.
30
31
  load: (loader, state) => loadPaints(loader, { fills: [state.fill], shadows: [state.shadow], strokes: [state.xGridStroke, state.yGridStroke] }),
31
32
  render: (ctx, state) => {
32
33
  const { width: W, height: H } = ctx.size;
33
34
  if (W <= 0 || H <= 0)
34
35
  return;
35
- // Plot panel, centred on the origin (node space is y-up, origin centre).
36
36
  ctx.draw(new Graphics2D().rect({ x: 0, y: 0, width: W, height: H }).shadow(state.shadow).fill(state.fill));
37
37
  const [xMin, xMax] = state.xExtent;
38
38
  const [yMin, yMax] = state.yExtent;
39
- // Fraction of a marker across its extent; guard a zero-width extent.
39
+ // A zero-width extent maps to 0.
40
40
  const xFrac = (v) => (xMax <= xMin ? 0 : (v - xMin) / (xMax - xMin));
41
41
  const yFrac = (v) => (yMax <= yMin ? 0 : (v - yMin) / (yMax - yMin));
42
- // Skip markers landing on (or outside) the edges — they'd sit under the border.
42
+ // Markers on or past the edges would sit under the border.
43
43
  const interior = (f) => f > 1e-6 && f < 1 - 1e-6;
44
44
  const xStroke = state.xGridStroke[0];
45
45
  if (xStroke) {
@@ -1 +1 @@
1
- {"version":3,"file":"chart-canvas.js","sourceRoot":"","sources":["../../src/kit/chart-canvas.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,KAAK,EACL,WAAW,EACX,OAAO,EACP,SAAS,EACT,SAAS,GAWV,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAA;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,cAAc,GAEf,MAAM,UAAU,CAAA;AA2BjB,MAAM,WAAW,GAAG,CAAC,OAAe,EAAE,EAAE,CACtC,KAAK,CAAC,MAAM,CAA2B,OAAO,EAAE,EAAE,OAAO,EAAE,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,EAAE,CAAC,CAAA;AAEvG;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,WAAW,CAAC;IACrC,GAAG,EAAE,aAAa;IAClB,KAAK,EAAE;QACL,IAAI,EAAE,KAAK,CAAC,MAAM,CAAuB,iBAAiB,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC;QAClH,MAAM,EAAE,KAAK,CAAC,MAAM,CAA2B,iBAAiB,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,EAAE,CAAC;QAC9H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AAO,CAAC,IAAI,CAAC,CAAC,CAAA;QACpC,CAAC;QAED,MAAM,OAAO,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAA;QACpC,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,KAAK,GAAG,IAAI,UAAU,EAAE,CAAA;YAC9B,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;gBAC/B,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;gBAClB,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;oBAAE,SAAQ;gBAC1B,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;YAC3E,CAAC;YACD,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;QACpC,CAAC;IACH,CAAC;CACF,CAAC,CAAA","sourcesContent":["import {\n Graphics2D,\n Types,\n component2d,\n fillOps,\n shadowOps,\n strokeOps,\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} from \"@motionscript/sdk\"\n\nimport { fresh } from \"./entries\"\nimport { loadPaints } from \"./paints\"\nimport {\n DEFAULT_PLOT_AREA,\n DEFAULT_X_AXIS,\n DEFAULT_Y_AXIS,\n type Range,\n} from \"./shared\"\n\nexport interface ChartCanvasProps extends Node2DProps {\n /** Fill of the plot panel behind the marks. */\n fill: Fill\n /** Drop shadow of the panel. Default none. */\n shadow: Shadow\n /** Stroke of the vertical grid lines (one per {@link xMarkers}). */\n xGridStroke: Stroke\n /** Stroke of the horizontal grid lines (one per {@link yMarkers}). */\n yGridStroke: Stroke\n /**\n * Data-unit x positions to draw a vertical grid line at — one per horizontal\n * axis marker, so a line lands under every marker regardless of spacing.\n * Positions at (or past) an {@link xExtent} edge coincide with the border and\n * are skipped. Pass an empty list for a chart whose horizontal axis is\n * categorical and so has no numeric position to rule at.\n */\n xMarkers: number[]\n /** Data-unit y positions to draw a horizontal grid line at. */\n yMarkers: number[]\n /** `[min, max]` of the horizontal scale — maps {@link xMarkers} into the panel. */\n xExtent: Range\n /** `[min, max]` of the vertical scale — maps {@link yMarkers} into the panel. */\n yExtent: Range\n}\n\nconst strokeEntry = (initial: Stroke) =>\n Types.custom<Stroke, StrokeResolved[]>(initial, { resolve: strokeOps.resolve, lerp: strokeOps.lerp })\n\n/**\n * The plot **backdrop** of a cartesian chart: a filled panel with a grid of\n * faint lines spanning both directions across it, sized from its box and centred\n * on its origin.\n *\n * The thick frame is a **separate** {@link ChartBorder} node so it can be drawn\n * *over* the marks while this panel sits under them. Grid lines are placed from\n * the axis marker positions (in data units) mapped into the panel through\n * {@link ChartCanvasProps.xExtent}/`yExtent` — so each line lands under its\n * marker whether or not the markers are evenly spaced.\n */\nexport const ChartCanvas = component2d({\n key: \"chartCanvas\",\n state: {\n fill: Types.custom<Fill, FillResolved[]>(DEFAULT_PLOT_AREA.fill, { resolve: fillOps.resolve, lerp: fillOps.lerp }),\n shadow: Types.custom<Shadow, ShadowResolved[]>(DEFAULT_PLOT_AREA.shadow, { resolve: shadowOps.resolve, lerp: shadowOps.lerp }),\n xGridStroke: strokeEntry(DEFAULT_X_AXIS.lineStyle),\n yGridStroke: strokeEntry(DEFAULT_Y_AXIS.lineStyle),\n xMarkers: fresh<number[]>(() => []),\n yMarkers: fresh<number[]>(() => []),\n xExtent: fresh<Range>(() => [0, 1]),\n yExtent: fresh<Range>(() => [0, 1]),\n },\n // The grid strokes are named past the conventional slots, so they are named here.\n load: (loader, state) =>\n loadPaints(loader, { fills: [state.fill], shadows: [state.shadow], strokes: [state.xGridStroke, state.yGridStroke] }),\n render: (ctx, state) => {\n const { width: W, height: H } = ctx.size\n if (W <= 0 || H <= 0) return\n\n // Plot panel, centred on the origin (node space is y-up, origin centre).\n ctx.draw(new Graphics2D().rect({ x: 0, y: 0, width: W, height: H }).shadow(state.shadow).fill(state.fill))\n\n const [xMin, xMax] = state.xExtent\n const [yMin, yMax] = state.yExtent\n // Fraction of a marker across its extent; guard a zero-width extent.\n const xFrac = (v: number) => (xMax <= xMin ? 0 : (v - xMin) / (xMax - xMin))\n const yFrac = (v: number) => (yMax <= yMin ? 0 : (v - yMin) / (yMax - yMin))\n // Skip markers landing on (or outside) the edges — they'd sit under the border.\n const interior = (f: number) => f > 1e-6 && f < 1 - 1e-6\n\n const xStroke = state.xGridStroke[0]\n if (xStroke) {\n const xGrid = new Graphics2D()\n for (const v of state.xMarkers) {\n const f = xFrac(v)\n if (!interior(f)) continue\n xGrid.rect({ x: -W / 2 + f * W, y: 0, width: xStroke.weight, height: H })\n }\n ctx.draw(xGrid.fill(xStroke.fill))\n }\n\n const yStroke = state.yGridStroke[0]\n if (yStroke) {\n const yGrid = new Graphics2D()\n for (const v of state.yMarkers) {\n const f = yFrac(v)\n if (!interior(f)) continue\n yGrid.rect({ x: 0, y: -H / 2 + f * H, width: W, height: yStroke.weight })\n }\n ctx.draw(yGrid.fill(yStroke.fill))\n }\n },\n})\n\nexport type ChartCanvas = NodeOf<typeof ChartCanvas>\n"]}
1
+ {"version":3,"file":"chart-canvas.js","sourceRoot":"","sources":["../../src/kit/chart-canvas.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,KAAK,EACL,WAAW,EACX,OAAO,EACP,SAAS,EACT,SAAS,GAWV,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAA;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,c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ACD,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;QACpC,CAAC;IACH,CAAC;CACF,CAAC,CAAA","sourcesContent":["import {\n Graphics2D,\n Types,\n component2d,\n fillOps,\n shadowOps,\n strokeOps,\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 as _Node2D,\n type Node2DProps as _Node2DProps,\n type Shadow,\n type ShadowResolved,\n type Stroke,\n type StrokeResolved,\n} from \"@motionscript/sdk\"\n\nimport { fresh } from \"./entries\"\nimport { loadPaints } from \"./paints\"\nimport {\n DEFAULT_PLOT_AREA,\n DEFAULT_X_AXIS,\n DEFAULT_Y_AXIS,\n type Range,\n} from \"./shared\"\n\nconst strokeEntry = (initial: Stroke) =>\n Types.custom<Stroke, StrokeResolved[]>(initial, { resolve: strokeOps.resolve, lerp: strokeOps.lerp })\n\n/**\n * The plot backdrop: a filled panel and a grid, sized from its box. The frame is\n * a separate {@link ChartBorder} drawn over the marks. Grid lines are placed from\n * the axis markers' data-unit positions mapped through the extents, so each lands\n * under its marker however the markers are spaced.\n */\nexport const ChartCanvas = component2d({\n key: \"chartCanvas\",\n state: {\n fill: Types.custom<Fill, FillResolved[]>(DEFAULT_PLOT_AREA.fill, { resolve: fillOps.resolve, lerp: fillOps.lerp }),\n shadow: Types.custom<Shadow, ShadowResolved[]>(DEFAULT_PLOT_AREA.shadow, { resolve: shadowOps.resolve, lerp: shadowOps.lerp }),\n xGridStroke: strokeEntry(DEFAULT_X_AXIS.lineStyle),\n yGridStroke: strokeEntry(DEFAULT_Y_AXIS.lineStyle),\n /**\n * Data-unit positions of the vertical grid lines, one per horizontal marker.\n * Positions at or past an extent edge coincide with the border and are\n * skipped. Empty for a categorical axis, which has no numeric position to rule at.\n */\n xMarkers: fresh<number[]>(() => []),\n yMarkers: fresh<number[]>(() => []),\n /** `[min, max]` of each scale, mapping the markers into the panel. */\n xExtent: fresh<Range>(() => [0, 1]),\n yExtent: fresh<Range>(() => [0, 1]),\n },\n // The grid strokes sit past the conventional slots, so they are named here.\n load: (loader, state) =>\n loadPaints(loader, { fills: [state.fill], shadows: [state.shadow], strokes: [state.xGridStroke, state.yGridStroke] }),\n render: (ctx, state) => {\n const { width: W, height: H } = ctx.size\n if (W <= 0 || H <= 0) return\n\n ctx.draw(new Graphics2D().rect({ x: 0, y: 0, width: W, height: H }).shadow(state.shadow).fill(state.fill))\n\n const [xMin, xMax] = state.xExtent\n const [yMin, yMax] = state.yExtent\n // A zero-width extent maps to 0.\n const xFrac = (v: number) => (xMax <= xMin ? 0 : (v - xMin) / (xMax - xMin))\n const yFrac = (v: number) => (yMax <= yMin ? 0 : (v - yMin) / (yMax - yMin))\n // Markers on or past the edges would sit under the border.\n const interior = (f: number) => f > 1e-6 && f < 1 - 1e-6\n\n const xStroke = state.xGridStroke[0]\n if (xStroke) {\n const xGrid = new Graphics2D()\n for (const v of state.xMarkers) {\n const f = xFrac(v)\n if (!interior(f)) continue\n xGrid.rect({ x: -W / 2 + f * W, y: 0, width: xStroke.weight, height: H })\n }\n ctx.draw(xGrid.fill(xStroke.fill))\n }\n\n const yStroke = state.yGridStroke[0]\n if (yStroke) {\n const yGrid = new Graphics2D()\n for (const v of state.yMarkers) {\n const f = yFrac(v)\n if (!interior(f)) continue\n yGrid.rect({ x: 0, y: -H / 2 + f * H, width: W, height: yStroke.weight })\n }\n ctx.draw(yGrid.fill(yStroke.fill))\n }\n },\n})\n\nexport type ChartCanvas = NodeOf<typeof ChartCanvas>\n"]}