@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.
- package/CHANGELOG.md +63 -0
- package/LICENSE +201 -201
- package/NOTICE +48 -0
- package/README.md +99 -0
- package/dist/bar-chart/bar-chart.d.ts +93 -231
- package/dist/bar-chart/bar-chart.d.ts.map +1 -1
- package/dist/bar-chart/bar-chart.js +378 -565
- package/dist/bar-chart/bar-chart.js.map +1 -1
- package/dist/bar-chart/category-axis.d.ts +24 -41
- package/dist/bar-chart/category-axis.d.ts.map +1 -1
- package/dist/bar-chart/category-axis.js +93 -115
- package/dist/bar-chart/category-axis.js.map +1 -1
- package/dist/bar-chart/chart-bars.d.ts +36 -70
- package/dist/bar-chart/chart-bars.d.ts.map +1 -1
- package/dist/bar-chart/chart-bars.js +156 -210
- package/dist/bar-chart/chart-bars.js.map +1 -1
- package/dist/bar-chart/index.d.ts +2 -2
- package/dist/bar-chart/index.d.ts.map +1 -1
- package/dist/bar-chart/index.js +1 -1
- package/dist/bar-chart/index.js.map +1 -1
- package/dist/bar-chart/shared.d.ts +6 -6
- package/dist/bar-chart/shared.d.ts.map +1 -1
- package/dist/bar-chart/shared.js +6 -6
- package/dist/bar-chart/shared.js.map +1 -1
- package/dist/browser/chunks/chunk-XROBIRQK.js +2 -0
- package/dist/browser/chunks/chunk-XROBIRQK.js.map +7 -0
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +3 -3
- package/dist/browser/kit.js +1 -1
- package/dist/browser/manifest.json +3 -2
- package/dist/engine.d.ts +8 -6
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +8 -6
- package/dist/engine.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/kit/cartesian.d.ts +44 -0
- package/dist/kit/cartesian.d.ts.map +1 -0
- package/dist/kit/cartesian.js +59 -0
- package/dist/kit/cartesian.js.map +1 -0
- package/dist/kit/chart-border.d.ts +8 -11
- package/dist/kit/chart-border.d.ts.map +1 -1
- package/dist/kit/chart-border.js +15 -32
- package/dist/kit/chart-border.js.map +1 -1
- package/dist/kit/chart-canvas.d.ts +23 -21
- package/dist/kit/chart-canvas.d.ts.map +1 -1
- package/dist/kit/chart-canvas.js +33 -90
- package/dist/kit/chart-canvas.js.map +1 -1
- package/dist/kit/chart-legend.d.ts +79 -88
- package/dist/kit/chart-legend.d.ts.map +1 -1
- package/dist/kit/chart-legend.js +137 -186
- package/dist/kit/chart-legend.js.map +1 -1
- package/dist/kit/entries.d.ts +17 -0
- package/dist/kit/entries.d.ts.map +1 -0
- package/dist/kit/entries.js +19 -0
- package/dist/kit/entries.js.map +1 -0
- package/dist/kit/motion.d.ts +48 -0
- package/dist/kit/motion.d.ts.map +1 -0
- package/dist/kit/motion.js +63 -0
- package/dist/kit/motion.js.map +1 -0
- package/dist/kit/paints.d.ts +10 -0
- package/dist/kit/paints.d.ts.map +1 -0
- package/dist/kit/paints.js +12 -0
- package/dist/kit/paints.js.map +1 -0
- package/dist/kit/shared.d.ts +59 -8
- package/dist/kit/shared.d.ts.map +1 -1
- package/dist/kit/shared.js +105 -10
- package/dist/kit/shared.js.map +1 -1
- package/dist/kit/vertical-axis.d.ts +36 -61
- package/dist/kit/vertical-axis.d.ts.map +1 -1
- package/dist/kit/vertical-axis.js +97 -132
- package/dist/kit/vertical-axis.js.map +1 -1
- package/dist/line-chart/chart-line.d.ts +27 -53
- package/dist/line-chart/chart-line.d.ts.map +1 -1
- package/dist/line-chart/chart-line.js +89 -120
- package/dist/line-chart/chart-line.js.map +1 -1
- package/dist/line-chart/chart-region.d.ts +14 -14
- package/dist/line-chart/chart-region.d.ts.map +1 -1
- package/dist/line-chart/chart-region.js +26 -64
- package/dist/line-chart/chart-region.js.map +1 -1
- package/dist/line-chart/horizontal-axis.d.ts +32 -56
- package/dist/line-chart/horizontal-axis.d.ts.map +1 -1
- package/dist/line-chart/horizontal-axis.js +85 -123
- package/dist/line-chart/horizontal-axis.js.map +1 -1
- package/dist/line-chart/index.d.ts +2 -2
- package/dist/line-chart/index.d.ts.map +1 -1
- package/dist/line-chart/index.js +1 -1
- package/dist/line-chart/index.js.map +1 -1
- package/dist/line-chart/line-chart.d.ts +111 -311
- package/dist/line-chart/line-chart.d.ts.map +1 -1
- package/dist/line-chart/line-chart.js +403 -639
- package/dist/line-chart/line-chart.js.map +1 -1
- package/dist/line-chart/shared.d.ts +6 -6
- package/dist/line-chart/shared.d.ts.map +1 -1
- package/dist/line-chart/shared.js +22 -7
- package/dist/line-chart/shared.js.map +1 -1
- package/dist/line-chart/x-scale.d.ts +1 -1
- package/dist/line-chart/x-scale.js +1 -1
- package/dist/line-chart/x-scale.js.map +1 -1
- package/dist/nodes.d.ts +6 -9
- package/dist/nodes.d.ts.map +1 -1
- package/dist/nodes.js +7 -9
- package/dist/nodes.js.map +1 -1
- package/dist/pie-chart/index.d.ts +2 -2
- package/dist/pie-chart/index.d.ts.map +1 -1
- package/dist/pie-chart/index.js +1 -1
- package/dist/pie-chart/index.js.map +1 -1
- package/dist/pie-chart/pie-chart.d.ts +77 -134
- package/dist/pie-chart/pie-chart.d.ts.map +1 -1
- package/dist/pie-chart/pie-chart.js +199 -268
- package/dist/pie-chart/pie-chart.js.map +1 -1
- package/dist/pie-chart/pie-legend.d.ts +54 -31
- package/dist/pie-chart/pie-legend.d.ts.map +1 -1
- package/dist/pie-chart/pie-legend.js +93 -107
- package/dist/pie-chart/pie-legend.js.map +1 -1
- package/dist/pie-chart/pie-ring.d.ts +142 -122
- package/dist/pie-chart/pie-ring.d.ts.map +1 -1
- package/dist/pie-chart/pie-ring.js +333 -361
- package/dist/pie-chart/pie-ring.js.map +1 -1
- package/dist/pie-chart/shared.d.ts +3 -3
- package/dist/pie-chart/shared.js +3 -3
- package/dist/pie-chart/shared.js.map +1 -1
- package/package.json +6 -5
- package/registry.json +23 -23
- package/src/bar-chart/bar-chart.ts +534 -814
- package/src/bar-chart/category-axis.ts +162 -177
- package/src/bar-chart/chart-bars.ts +288 -310
- package/src/bar-chart/index.ts +31 -31
- package/src/bar-chart/shared.ts +354 -354
- package/src/engine.ts +28 -26
- package/src/index.ts +5 -5
- package/src/kit/cartesian.ts +81 -0
- package/src/kit/chart-border.ts +50 -61
- package/src/kit/chart-canvas.ts +122 -157
- package/src/kit/chart-legend.ts +229 -250
- package/src/kit/entries.ts +20 -0
- package/src/kit/motion.ts +90 -0
- package/src/kit/paints.ts +15 -0
- package/src/kit/shared.ts +782 -675
- package/src/kit/vertical-axis.ts +194 -224
- package/src/line-chart/chart-line.ts +181 -208
- package/src/line-chart/chart-region.ts +106 -135
- package/src/line-chart/horizontal-axis.ts +166 -202
- package/src/line-chart/index.ts +39 -39
- package/src/line-chart/line-chart.ts +585 -929
- package/src/line-chart/shared.ts +473 -459
- package/src/line-chart/x-scale.ts +367 -367
- package/src/nodes.ts +18 -20
- package/src/pie-chart/index.ts +37 -37
- package/src/pie-chart/pie-chart.ts +293 -381
- package/src/pie-chart/pie-legend.ts +169 -159
- package/src/pie-chart/pie-ring.ts +848 -903
- package/src/pie-chart/shared.ts +490 -490
- package/dist/browser/chunks/chunk-RMHQ6GYU.js +0 -2
- package/dist/browser/chunks/chunk-RMHQ6GYU.js.map +0 -7
package/dist/browser/kit.js
CHANGED
|
@@ -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-
|
|
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
|
+
"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
|
|
11
|
-
*
|
|
12
|
-
* and
|
|
13
|
-
*
|
|
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
|
package/dist/engine.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA
|
|
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
|
|
11
|
-
*
|
|
12
|
-
* and
|
|
13
|
-
*
|
|
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
|
package/dist/engine.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA
|
|
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
|
|
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
|
|
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
|
|
20
|
-
stroke: Stroke
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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,
|
|
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"}
|
package/dist/kit/chart-border.js
CHANGED
|
@@ -1,45 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
|
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
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
|
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":"
|
|
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
|
|
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
|
|
30
|
-
*
|
|
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
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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,
|
|
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"}
|
package/dist/kit/chart-canvas.js
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
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
|
|
13
|
-
*
|
|
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
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
42
|
-
|
|
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 =
|
|
44
|
+
const xStroke = state.xGridStroke[0];
|
|
52
45
|
if (xStroke) {
|
|
53
46
|
const xGrid = new Graphics2D();
|
|
54
|
-
for (const v of
|
|
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 =
|
|
55
|
+
const yStroke = state.yGridStroke[0];
|
|
68
56
|
if (yStroke) {
|
|
69
57
|
const yGrid = new Graphics2D();
|
|
70
|
-
for (const v of
|
|
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
|