@motionscript/charts 0.0.0-stage → 0.1.0-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.
- package/CHANGELOG.md +5 -0
- package/LICENSE +201 -0
- package/dist/bar-chart/bar-chart.d.ts +286 -0
- package/dist/bar-chart/bar-chart.d.ts.map +1 -0
- package/dist/bar-chart/bar-chart.js +610 -0
- package/dist/bar-chart/bar-chart.js.map +1 -0
- package/dist/bar-chart/category-axis.d.ts +77 -0
- package/dist/bar-chart/category-axis.d.ts.map +1 -0
- package/dist/bar-chart/category-axis.js +141 -0
- package/dist/bar-chart/category-axis.js.map +1 -0
- package/dist/bar-chart/chart-bars.d.ts +149 -0
- package/dist/bar-chart/chart-bars.d.ts.map +1 -0
- package/dist/bar-chart/chart-bars.js +236 -0
- package/dist/bar-chart/chart-bars.js.map +1 -0
- package/dist/bar-chart/index.d.ts +16 -0
- package/dist/bar-chart/index.d.ts.map +1 -0
- package/dist/bar-chart/index.js +12 -0
- package/dist/bar-chart/index.js.map +1 -0
- package/dist/bar-chart/shared.d.ts +146 -0
- package/dist/bar-chart/shared.d.ts.map +1 -0
- package/dist/bar-chart/shared.js +182 -0
- package/dist/bar-chart/shared.js.map +1 -0
- package/dist/browser/chunks/chunk-ZMBOBHYL.js +2 -0
- package/dist/browser/chunks/chunk-ZMBOBHYL.js.map +7 -0
- package/dist/browser/index.js +2 -0
- package/dist/browser/index.js.map +7 -0
- package/dist/browser/kit.js +2 -0
- package/dist/browser/kit.js.map +7 -0
- package/dist/browser/manifest.json +12 -0
- package/dist/engine.d.ts +27 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +27 -0
- package/dist/engine.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/kit/chart-border.d.ts +28 -0
- package/dist/kit/chart-border.d.ts.map +1 -0
- package/dist/kit/chart-border.js +45 -0
- package/dist/kit/chart-border.js.map +1 -0
- package/dist/kit/chart-canvas.d.ts +56 -0
- package/dist/kit/chart-canvas.d.ts.map +1 -0
- package/dist/kit/chart-canvas.js +125 -0
- package/dist/kit/chart-canvas.js.map +1 -0
- package/dist/kit/chart-legend.d.ts +126 -0
- package/dist/kit/chart-legend.d.ts.map +1 -0
- package/dist/kit/chart-legend.js +212 -0
- package/dist/kit/chart-legend.js.map +1 -0
- package/dist/kit/shared.d.ts +251 -0
- package/dist/kit/shared.d.ts.map +1 -0
- package/dist/kit/shared.js +401 -0
- package/dist/kit/shared.js.map +1 -0
- package/dist/kit/vertical-axis.d.ts +99 -0
- package/dist/kit/vertical-axis.d.ts.map +1 -0
- package/dist/kit/vertical-axis.js +176 -0
- package/dist/kit/vertical-axis.js.map +1 -0
- package/dist/line-chart/chart-line.d.ts +91 -0
- package/dist/line-chart/chart-line.d.ts.map +1 -0
- package/dist/line-chart/chart-line.js +156 -0
- package/dist/line-chart/chart-line.js.map +1 -0
- package/dist/line-chart/chart-region.d.ts +47 -0
- package/dist/line-chart/chart-region.d.ts.map +1 -0
- package/dist/line-chart/chart-region.js +101 -0
- package/dist/line-chart/chart-region.js.map +1 -0
- package/dist/line-chart/horizontal-axis.d.ts +85 -0
- package/dist/line-chart/horizontal-axis.d.ts.map +1 -0
- package/dist/line-chart/horizontal-axis.js +158 -0
- package/dist/line-chart/horizontal-axis.js.map +1 -0
- package/dist/line-chart/index.d.ts +22 -0
- package/dist/line-chart/index.d.ts.map +1 -0
- package/dist/line-chart/index.js +19 -0
- package/dist/line-chart/index.js.map +1 -0
- package/dist/line-chart/line-chart.d.ts +347 -0
- package/dist/line-chart/line-chart.d.ts.map +1 -0
- package/dist/line-chart/line-chart.js +701 -0
- package/dist/line-chart/line-chart.js.map +1 -0
- package/dist/line-chart/shared.d.ts +171 -0
- package/dist/line-chart/shared.d.ts.map +1 -0
- package/dist/line-chart/shared.js +270 -0
- package/dist/line-chart/shared.js.map +1 -0
- package/dist/line-chart/x-scale.d.ts +84 -0
- package/dist/line-chart/x-scale.d.ts.map +1 -0
- package/dist/line-chart/x-scale.js +302 -0
- package/dist/line-chart/x-scale.js.map +1 -0
- package/dist/nodes.d.ts +20 -0
- package/dist/nodes.d.ts.map +1 -0
- package/dist/nodes.js +20 -0
- package/dist/nodes.js.map +1 -0
- package/dist/pie-chart/index.d.ts +18 -0
- package/dist/pie-chart/index.d.ts.map +1 -0
- package/dist/pie-chart/index.js +14 -0
- package/dist/pie-chart/index.js.map +1 -0
- package/dist/pie-chart/pie-chart.d.ts +170 -0
- package/dist/pie-chart/pie-chart.d.ts.map +1 -0
- package/dist/pie-chart/pie-chart.js +291 -0
- package/dist/pie-chart/pie-chart.js.map +1 -0
- package/dist/pie-chart/pie-legend.d.ts +60 -0
- package/dist/pie-chart/pie-legend.d.ts.map +1 -0
- package/dist/pie-chart/pie-legend.js +131 -0
- package/dist/pie-chart/pie-legend.js.map +1 -0
- package/dist/pie-chart/pie-ring.d.ts +266 -0
- package/dist/pie-chart/pie-ring.d.ts.map +1 -0
- package/dist/pie-chart/pie-ring.js +708 -0
- package/dist/pie-chart/pie-ring.js.map +1 -0
- package/dist/pie-chart/shared.d.ts +210 -0
- package/dist/pie-chart/shared.d.ts.map +1 -0
- package/dist/pie-chart/shared.js +240 -0
- package/dist/pie-chart/shared.js.map +1 -0
- package/package.json +69 -3
- package/registry.json +23 -0
- package/src/bar-chart/bar-chart.ts +804 -0
- package/src/bar-chart/category-axis.ts +177 -0
- package/src/bar-chart/chart-bars.ts +310 -0
- package/src/bar-chart/index.ts +31 -0
- package/src/bar-chart/shared.ts +354 -0
- package/src/engine.ts +26 -0
- package/src/index.ts +5 -0
- package/src/kit/chart-border.ts +61 -0
- package/src/kit/chart-canvas.ts +157 -0
- package/src/kit/chart-legend.ts +250 -0
- package/src/kit/shared.ts +675 -0
- package/src/kit/vertical-axis.ts +224 -0
- package/src/line-chart/chart-line.ts +208 -0
- package/src/line-chart/chart-region.ts +135 -0
- package/src/line-chart/horizontal-axis.ts +202 -0
- package/src/line-chart/index.ts +39 -0
- package/src/line-chart/line-chart.ts +894 -0
- package/src/line-chart/shared.ts +459 -0
- package/src/line-chart/x-scale.ts +367 -0
- package/src/nodes.ts +20 -0
- package/src/pie-chart/index.ts +37 -0
- package/src/pie-chart/pie-chart.ts +374 -0
- package/src/pie-chart/pie-legend.ts +159 -0
- package/src/pie-chart/pie-ring.ts +903 -0
- package/src/pie-chart/shared.ts +490 -0
- package/README.md +0 -4
package/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import { Node2D, type CommandArgs, type DataRecord, type Command, type NodeConfig, type Node2DProps } from "@motionscript/core";
|
|
2
|
+
import { type AxisDomainConfig } from "../kit/shared.js";
|
|
3
|
+
import { type Seekable } from "@motionscript/core/component";
|
|
4
|
+
import { type BarChartTheme, type BarSeries } from "./shared.js";
|
|
5
|
+
export interface BarChartProps extends Node2DProps {
|
|
6
|
+
/** One row per category — a plain record of field name to value. */
|
|
7
|
+
data: DataRecord[];
|
|
8
|
+
/**
|
|
9
|
+
* Key into each row for its category caption, drawn beneath the baseline.
|
|
10
|
+
* Named `categoryField` rather than `category` for the same reason the line
|
|
11
|
+
* chart's is `xField`: it names a *column*, not a value.
|
|
12
|
+
*/
|
|
13
|
+
categoryField: string;
|
|
14
|
+
/** One entry per bar series: which column it plots, its `label`, its `fill`. */
|
|
15
|
+
series: BarSeries[];
|
|
16
|
+
/**
|
|
17
|
+
* When `true` every category's series stack into one column; when `false`
|
|
18
|
+
* (the default) each series gets its own bar, grouped side by side within the
|
|
19
|
+
* category's slot.
|
|
20
|
+
*/
|
|
21
|
+
stacked?: boolean;
|
|
22
|
+
/** The value axis's domain: caption, scale range, and tick placement. */
|
|
23
|
+
valueAxis?: AxisDomainConfig;
|
|
24
|
+
/** The category axis's domain. Only its `label` is read — the slots are the rows. */
|
|
25
|
+
categoryAxis?: AxisDomainConfig;
|
|
26
|
+
/**
|
|
27
|
+
* The chart's visual theme — bar palette and geometry, axis furniture, plot
|
|
28
|
+
* panel paint, legend, value figures. Every branch is optional and deep-merged
|
|
29
|
+
* onto {@link DEFAULT_BAR_CHART_THEME}.
|
|
30
|
+
*/
|
|
31
|
+
theme?: BarChartTheme;
|
|
32
|
+
/** Whether the legend row below the plot is drawn at all. */
|
|
33
|
+
showLegend?: boolean;
|
|
34
|
+
/** Whether each column prints the figure it plots. */
|
|
35
|
+
showValues?: boolean;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* How {@link BarChart.enter} divides its duration between its three beats: the
|
|
39
|
+
* axes arriving, the columns rising, and the legend coming up. Shares of the
|
|
40
|
+
* whole, so they must sum to 1 — the entrance takes exactly the time it was
|
|
41
|
+
* given, for the reason spelt out on `LineChart.enter`.
|
|
42
|
+
*/
|
|
43
|
+
/**
|
|
44
|
+
* The signals the bar chart's own commands move, as props types.
|
|
45
|
+
*
|
|
46
|
+
* Written out rather than reusing `BarChartProps` because these are signals of
|
|
47
|
+
* the chart's own — how far the columns have risen, and which category is lit —
|
|
48
|
+
* rather than part of what an author states about it. Same reason the line chart
|
|
49
|
+
* types its `RegionState` separately.
|
|
50
|
+
*/
|
|
51
|
+
type CategorySpotlight = {
|
|
52
|
+
spotlight: number | null;
|
|
53
|
+
spotlightReveal: number;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* A grouped or stacked bar chart, composed from independent parts rather than
|
|
57
|
+
* one monolithic draw — the sibling of the {@link LineChart} family, built the
|
|
58
|
+
* same way and out of several of the same pieces:
|
|
59
|
+
*
|
|
60
|
+
* - `ChartCanvas` — the plot panel with a horizontal grid, under everything.
|
|
61
|
+
* - `VerticalAxis` — the numeric value markers, staggering in bottom-to-top.
|
|
62
|
+
* - {@link CategoryAxis} — the row of names beneath the baseline, one per row of
|
|
63
|
+
* the data, staggering in left-to-right.
|
|
64
|
+
* - {@link ChartBars} (one per series) — that series' column in every category,
|
|
65
|
+
* plus the figures printed on them.
|
|
66
|
+
* - `ChartLegend` — a row of entries below the chart, one per series.
|
|
67
|
+
*
|
|
68
|
+
* The parts are laid out from this node's `layoutBounds` exactly as the line
|
|
69
|
+
* chart's are: a left gutter for the value axis, a bottom gutter for the
|
|
70
|
+
* captions, the plot filling what's left, and the legend row beneath the whole
|
|
71
|
+
* thing. Every child's position and size is bound reactively, so the chart
|
|
72
|
+
* re-flows if its box changes, and the bars read the same resolved scale the
|
|
73
|
+
* axis does, so a column's end lands exactly on its marker.
|
|
74
|
+
*
|
|
75
|
+
* **Resting state is the finished chart** — the same bargain the line chart
|
|
76
|
+
* makes: the studio paints a node's Initial state on a paused canvas, so a chart
|
|
77
|
+
* that only appeared once a command had run would be edited blind. {@link enter}
|
|
78
|
+
* arms every part back to its pre-entrance state before animating.
|
|
79
|
+
*
|
|
80
|
+
* **Zero is always on the scale** (see `barValueExtent`), and the columns
|
|
81
|
+
* grow about it rather than about the plot floor, so a negative value draws
|
|
82
|
+
* downward out of the same `growth` signal that draws a positive one up.
|
|
83
|
+
*
|
|
84
|
+
* Past the entrance, two things move the chart:
|
|
85
|
+
* {@link showSeries}/{@link hideSeries}/{@link spotlightSeries} pick out a
|
|
86
|
+
* *series* — and hiding one **reflows the group**, the remaining columns
|
|
87
|
+
* widening into the space as it goes, rather than leaving a hole where it was —
|
|
88
|
+
* while {@link spotlightCategory}/{@link clearCategory} pick out a *column of
|
|
89
|
+
* the table*, dimming every other category and its caption with it.
|
|
90
|
+
*/
|
|
91
|
+
export declare class BarChart extends Node2D<BarChartProps> {
|
|
92
|
+
data: DataRecord[];
|
|
93
|
+
categoryField: string;
|
|
94
|
+
series: BarSeries[];
|
|
95
|
+
stacked: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* The value axis's domain (label/range/ticks), tweenable and mappable exactly
|
|
98
|
+
* as the line chart's axes are: the mapper merges a partial input onto the
|
|
99
|
+
* previous resolved domain and the tween interpolates numerically, so
|
|
100
|
+
* `chart.to({ data: { valueAxis: { range: [0, 10] } }, duration: 1 })` smoothly
|
|
101
|
+
* rescales every column. The axis *label* text is captured once at construction.
|
|
102
|
+
*/
|
|
103
|
+
valueAxis: AxisDomainConfig;
|
|
104
|
+
categoryAxis: AxisDomainConfig;
|
|
105
|
+
theme: BarChartTheme;
|
|
106
|
+
/**
|
|
107
|
+
* Global rise of every column in `[0, 1]`, measured about the baseline: 0
|
|
108
|
+
* collapses them all onto it, 1 draws them at full length. Each
|
|
109
|
+
* {@link ChartBars}' own `growth` is bound to this, so tweening this one
|
|
110
|
+
* signal raises the whole chart in proportion.
|
|
111
|
+
*/
|
|
112
|
+
growth: number;
|
|
113
|
+
/**
|
|
114
|
+
* How much of the slot each series currently claims, one entry per series.
|
|
115
|
+
*
|
|
116
|
+
* A *weight* rather than a boolean, because that is what makes hiding a series
|
|
117
|
+
* an animation instead of a jump: the grouped columns divide the slot in
|
|
118
|
+
* proportion to these, so tweening one to 0 has the remaining columns widen
|
|
119
|
+
* into the space as it shrinks away, and a stacked segment's contribution to
|
|
120
|
+
* the stack fades out with it. Seeded from each series' `enabled` field.
|
|
121
|
+
*/
|
|
122
|
+
weights: number[];
|
|
123
|
+
/**
|
|
124
|
+
* The category currently spotlit, or `null` for none. Held as a plain reactive
|
|
125
|
+
* value rather than a tweened one: the *choice* snaps, and the animation is
|
|
126
|
+
* {@link spotlightReveal} dimming everything else.
|
|
127
|
+
*/
|
|
128
|
+
spotlight: number | null;
|
|
129
|
+
/** How far the category spotlight is drawn in, `[0, 1]`. */
|
|
130
|
+
spotlightReveal: number;
|
|
131
|
+
private vAxis;
|
|
132
|
+
private cAxis;
|
|
133
|
+
private legend;
|
|
134
|
+
private barSets;
|
|
135
|
+
/**
|
|
136
|
+
* `this.theme` read back through its *resolved* shape — the same
|
|
137
|
+
* loose-declared/resolved-stored idiom as a shape's `fill`/`stroke`, and as
|
|
138
|
+
* the line chart's own theme.
|
|
139
|
+
*/
|
|
140
|
+
private get resolvedTheme();
|
|
141
|
+
/** Fallback marker count when the value axis states no ticks. */
|
|
142
|
+
private static readonly DEFAULT_MARKERS;
|
|
143
|
+
private get valueScale();
|
|
144
|
+
/**
|
|
145
|
+
* A value written down as this chart's value axis says — the axis ticks and
|
|
146
|
+
* the figures printed on the columns both read through here, so the two
|
|
147
|
+
* cannot disagree about what a number looks like.
|
|
148
|
+
*/
|
|
149
|
+
private valueLabel;
|
|
150
|
+
/** The value axis ticks: the explicit ones, else five across the scale. */
|
|
151
|
+
private get resolvedMarkers();
|
|
152
|
+
private get hasValueLabel();
|
|
153
|
+
private get hasCategoryLabel();
|
|
154
|
+
private get leftInset();
|
|
155
|
+
private get bottomInset();
|
|
156
|
+
/** The plot rectangle in node space: `{ left, right, top, bottom }` (y-up). */
|
|
157
|
+
private plotBox;
|
|
158
|
+
/** Width and height of the plot, in px. */
|
|
159
|
+
private plotSize;
|
|
160
|
+
/** Map a value onto the plot's **centred** pixel space (origin at its centre, y-up). */
|
|
161
|
+
private valueToY;
|
|
162
|
+
/**
|
|
163
|
+
* Pixel y of the line every column grows from.
|
|
164
|
+
*
|
|
165
|
+
* Zero, clamped onto the scale — so an author who *did* crop the axis to
|
|
166
|
+
* `[40, 100]` gets columns rising from the plot floor rather than from a
|
|
167
|
+
* baseline off the bottom of the panel.
|
|
168
|
+
*/
|
|
169
|
+
private get baselinePx();
|
|
170
|
+
/** Width of one category's slot across the plot. */
|
|
171
|
+
private get slotWidth();
|
|
172
|
+
/** Centre x of category `i`'s slot, in the plot's centred space. */
|
|
173
|
+
private slotCenter;
|
|
174
|
+
/** The part of a slot the columns fill — the rest is the channel between categories. */
|
|
175
|
+
private get slotInner();
|
|
176
|
+
/** Series `i`'s live share of the slot; 0 once it has been hidden. */
|
|
177
|
+
private weightAt;
|
|
178
|
+
/** Total live share across the series — the slot's inner width divides by this. */
|
|
179
|
+
private get totalWeight();
|
|
180
|
+
/** Live share of every series *before* `index`, for the grouped offset. */
|
|
181
|
+
private weightBefore;
|
|
182
|
+
/**
|
|
183
|
+
* Series `index`'s columns, mapped into the plot's centred pixel space.
|
|
184
|
+
*
|
|
185
|
+
* Both modes come out of one walk over the rows: a grouped series divides the
|
|
186
|
+
* slot with its siblings and every column runs from zero, a stacked one takes
|
|
187
|
+
* the whole slot and each column runs from the running total below it. The
|
|
188
|
+
* live {@link weights} scale the grouped widths and the stacked contributions
|
|
189
|
+
* alike, which is what lets `hideSeries` reflow rather than punch a hole.
|
|
190
|
+
*/
|
|
191
|
+
private seriesBars;
|
|
192
|
+
/**
|
|
193
|
+
* `row` with each series' value scaled by that series' live {@link weights}
|
|
194
|
+
* entry — what the stacked spans are measured from.
|
|
195
|
+
*/
|
|
196
|
+
private weightedRow;
|
|
197
|
+
/**
|
|
198
|
+
* How far each category is dimmed by the spotlight, one entry per row —
|
|
199
|
+
* 1 while nothing is spotlit, falling to the theme's `dimOpacity` for every
|
|
200
|
+
* category but the chosen one as the reveal climbs.
|
|
201
|
+
*/
|
|
202
|
+
private categoryDims;
|
|
203
|
+
constructor(props?: NodeConfig<BarChart, BarChartProps>);
|
|
204
|
+
/**
|
|
205
|
+
* Prime every part at its pre-entrance state — axis markers and captions
|
|
206
|
+
* shifted and transparent, columns collapsed onto the baseline, legend dropped
|
|
207
|
+
* and transparent.
|
|
208
|
+
*
|
|
209
|
+
* Called by {@link enter} before its first frame so nothing flashes ahead of
|
|
210
|
+
* its beat. Idempotent, and public so a scene can hide a chart ahead of time
|
|
211
|
+
* without starting the entrance.
|
|
212
|
+
*/
|
|
213
|
+
arm(): void;
|
|
214
|
+
/**
|
|
215
|
+
* Animate the whole chart in: the two axes stagger their markers and captions
|
|
216
|
+
* in, the columns rise from the baseline, and the legend fades up last.
|
|
217
|
+
*
|
|
218
|
+
* `duration` is the **whole** entrance. The phases are shares of it, not
|
|
219
|
+
* multiples — a command that declares 1.4 seconds has to take 1.4 seconds,
|
|
220
|
+
* because that is the slot the timeline lays out for it, the length its
|
|
221
|
+
* parallel siblings are timed against, and its contribution to the scene's own
|
|
222
|
+
* duration.
|
|
223
|
+
*/
|
|
224
|
+
enter(args: CommandArgs<Record<string, never>> & {
|
|
225
|
+
duration: number;
|
|
226
|
+
}): Seekable;
|
|
227
|
+
/** Tween {@link growth} `0 → 1`, raising every column about the baseline. */
|
|
228
|
+
private riseBars;
|
|
229
|
+
/**
|
|
230
|
+
* Show series `index`: bring its columns back, the group reflowing to make
|
|
231
|
+
* room as they arrive, in lockstep with its legend entry growing in.
|
|
232
|
+
*/
|
|
233
|
+
showSeries(args: CommandArgs<{
|
|
234
|
+
seriesIndex: number;
|
|
235
|
+
}>): Seekable;
|
|
236
|
+
/**
|
|
237
|
+
* Hide series `index`: its columns narrow away (or, stacked, sink out of the
|
|
238
|
+
* stack) while the rest of the group widens into the space, its legend entry
|
|
239
|
+
* shrinking beside them — the mirror of {@link showSeries}.
|
|
240
|
+
*/
|
|
241
|
+
hideSeries(args: CommandArgs<{
|
|
242
|
+
seriesIndex: number;
|
|
243
|
+
}>): Seekable;
|
|
244
|
+
/**
|
|
245
|
+
* Move series `index`'s slot share to `target`, with its legend entry.
|
|
246
|
+
*
|
|
247
|
+
* One method for both directions, so the pair cannot drift apart. `enabled`
|
|
248
|
+
* rides in the same value as the weight rather than being set before or after,
|
|
249
|
+
* which is what makes arriving at a time backwards show what arriving forwards
|
|
250
|
+
* does.
|
|
251
|
+
*/
|
|
252
|
+
private toggleSeries;
|
|
253
|
+
/**
|
|
254
|
+
* Fade out every other series — its columns **and its legend entry** — to
|
|
255
|
+
* focus attention on `index`, which comes back to full. Nothing moves, so the
|
|
256
|
+
* group doesn't reflow.
|
|
257
|
+
*/
|
|
258
|
+
spotlightSeries(args: CommandArgs<{
|
|
259
|
+
seriesIndex: number;
|
|
260
|
+
}>): Seekable;
|
|
261
|
+
/** Ease series `index`'s slot share toward `target`, reflowing the group. */
|
|
262
|
+
private tweenWeight;
|
|
263
|
+
/**
|
|
264
|
+
* Spotlight one **category** — one column of the table rather than one series:
|
|
265
|
+
* every other category's bars and its caption fade to the theme's
|
|
266
|
+
* `dimOpacity`, and the chosen one stays full.
|
|
267
|
+
*
|
|
268
|
+
* The counterpart of the line chart's `spotlightRegion`, and the same shape of
|
|
269
|
+
* thing: it picks out a slice of the plot without changing what is drawn.
|
|
270
|
+
* Calling it while another category is already lit moves the focus directly —
|
|
271
|
+
* only the dimming changes, so there is nothing to retract first.
|
|
272
|
+
*/
|
|
273
|
+
spotlightCategory(args: CommandArgs<{
|
|
274
|
+
categoryIndex: number;
|
|
275
|
+
}>): Command<CategorySpotlight>;
|
|
276
|
+
/**
|
|
277
|
+
* Drop the category spotlight, bringing every category back to full. A no-op
|
|
278
|
+
* when nothing is lit — but it still takes its slot on the timeline, for the
|
|
279
|
+
* reason `LineChart.clearRegion` does.
|
|
280
|
+
*/
|
|
281
|
+
clearCategory(args: CommandArgs<Record<string, never>>): Command<CategorySpotlight>;
|
|
282
|
+
/** The no-op both of the above return — see {@link hold}. */
|
|
283
|
+
private holdSpotlight;
|
|
284
|
+
}
|
|
285
|
+
export {};
|
|
286
|
+
//# sourceMappingURL=bar-chart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bar-chart.d.ts","sourceRoot":"","sources":["../../src/bar-chart/bar-chart.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,MAAM,EAIN,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,OAAO,EAEZ,KAAK,UAAU,EACf,KAAK,WAAW,EACjB,MAAM,oBAAoB,CAAA;AAM3B,OAAO,EAO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