@cloudscape-design/chart-components 1.0.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/LICENSE +175 -0
- package/NOTICE +1 -0
- package/README.md +25 -0
- package/cartesian-chart/chart-cartesian-internal.d.ts +10 -0
- package/cartesian-chart/chart-cartesian-internal.js +99 -0
- package/cartesian-chart/chart-cartesian-internal.js.map +1 -0
- package/cartesian-chart/chart-series-cartesian.d.ts +7 -0
- package/cartesian-chart/chart-series-cartesian.js +95 -0
- package/cartesian-chart/chart-series-cartesian.js.map +1 -0
- package/cartesian-chart/index.d.ts +5 -0
- package/cartesian-chart/index.js +133 -0
- package/cartesian-chart/index.js.map +1 -0
- package/cartesian-chart/interfaces.d.ts +166 -0
- package/cartesian-chart/interfaces.js +4 -0
- package/cartesian-chart/interfaces.js.map +1 -0
- package/cartesian-chart/test-classes/styles.css.js +6 -0
- package/cartesian-chart/test-classes/styles.scoped.css +7 -0
- package/cartesian-chart/test-classes/styles.selectors.js +7 -0
- package/core/chart-api/chart-extra-axis-titles.d.ts +10 -0
- package/core/chart-api/chart-extra-axis-titles.js +42 -0
- package/core/chart-api/chart-extra-axis-titles.js.map +1 -0
- package/core/chart-api/chart-extra-context.d.ts +41 -0
- package/core/chart-api/chart-extra-context.js +93 -0
- package/core/chart-api/chart-extra-context.js.map +1 -0
- package/core/chart-api/chart-extra-highlight.d.ts +20 -0
- package/core/chart-api/chart-extra-highlight.js +205 -0
- package/core/chart-api/chart-extra-highlight.js.map +1 -0
- package/core/chart-api/chart-extra-legend.d.ts +27 -0
- package/core/chart-api/chart-extra-legend.js +118 -0
- package/core/chart-api/chart-extra-legend.js.map +1 -0
- package/core/chart-api/chart-extra-navigation.d.ts +84 -0
- package/core/chart-api/chart-extra-navigation.js +470 -0
- package/core/chart-api/chart-extra-navigation.js.map +1 -0
- package/core/chart-api/chart-extra-nodata.d.ts +15 -0
- package/core/chart-api/chart-extra-nodata.js +45 -0
- package/core/chart-api/chart-extra-nodata.js.map +1 -0
- package/core/chart-api/chart-extra-pointer.d.ts +33 -0
- package/core/chart-api/chart-extra-pointer.js +173 -0
- package/core/chart-api/chart-extra-pointer.js.map +1 -0
- package/core/chart-api/chart-extra-tooltip.d.ts +33 -0
- package/core/chart-api/chart-extra-tooltip.js +209 -0
- package/core/chart-api/chart-extra-tooltip.js.map +1 -0
- package/core/chart-api/index.d.ts +75 -0
- package/core/chart-api/index.js +383 -0
- package/core/chart-api/index.js.map +1 -0
- package/core/chart-container.d.ts +20 -0
- package/core/chart-container.js +55 -0
- package/core/chart-container.js.map +1 -0
- package/core/chart-core.d.ts +7 -0
- package/core/chart-core.js +287 -0
- package/core/chart-core.js.map +1 -0
- package/core/components/core-application.d.ts +6 -0
- package/core/components/core-application.js +16 -0
- package/core/components/core-application.js.map +1 -0
- package/core/components/core-filters.d.ts +9 -0
- package/core/components/core-filters.js +22 -0
- package/core/components/core-filters.js.map +1 -0
- package/core/components/core-legend.d.ts +13 -0
- package/core/components/core-legend.js +27 -0
- package/core/components/core-legend.js.map +1 -0
- package/core/components/core-no-data.d.ts +6 -0
- package/core/components/core-no-data.js +48 -0
- package/core/components/core-no-data.js.map +1 -0
- package/core/components/core-slots.d.ts +7 -0
- package/core/components/core-slots.js +11 -0
- package/core/components/core-slots.js.map +1 -0
- package/core/components/core-tooltip.d.ts +7 -0
- package/core/components/core-tooltip.js +183 -0
- package/core/components/core-tooltip.js.map +1 -0
- package/core/components/core-vertical-axis-title.d.ts +5 -0
- package/core/components/core-vertical-axis-title.js +15 -0
- package/core/components/core-vertical-axis-title.js.map +1 -0
- package/core/formatters.d.ts +2 -0
- package/core/formatters.js +113 -0
- package/core/formatters.js.map +1 -0
- package/core/i18n-utils.d.ts +21 -0
- package/core/i18n-utils.js +18 -0
- package/core/i18n-utils.js.map +1 -0
- package/core/interfaces.d.ts +436 -0
- package/core/interfaces.js +4 -0
- package/core/interfaces.js.map +1 -0
- package/core/styles.css.js +25 -0
- package/core/styles.scoped.css +115 -0
- package/core/styles.selectors.js +26 -0
- package/core/test-classes/styles.css.js +33 -0
- package/core/test-classes/styles.scoped.css +34 -0
- package/core/test-classes/styles.selectors.js +34 -0
- package/core/utils.d.ts +45 -0
- package/core/utils.js +262 -0
- package/core/utils.js.map +1 -0
- package/index.d.ts +4 -0
- package/index.js +5 -0
- package/index.js.map +1 -0
- package/internal/api-docs/components/cartesian-chart.js +571 -0
- package/internal/api-docs/components/index.d.ts +3 -0
- package/internal/api-docs/components/index.js +4 -0
- package/internal/api-docs/components/interfaces.d.ts +81 -0
- package/internal/api-docs/components/pie-chart.js +430 -0
- package/internal/api-docs/test-utils-doc/dom.js +4 -0
- package/internal/api-docs/test-utils-doc/selectors.js +4 -0
- package/internal/base-component/get-data-attributes.d.ts +1 -0
- package/internal/base-component/get-data-attributes.js +12 -0
- package/internal/base-component/get-data-attributes.js.map +1 -0
- package/internal/base-component/use-base-component.d.ts +13 -0
- package/internal/base-component/use-base-component.js +18 -0
- package/internal/base-component/use-base-component.js.map +1 -0
- package/internal/base-component/use-telemetry.d.ts +2 -0
- package/internal/base-component/use-telemetry.js +8 -0
- package/internal/base-component/use-telemetry.js.map +1 -0
- package/internal/chart-styles.d.ts +88 -0
- package/internal/chart-styles.js +145 -0
- package/internal/chart-styles.js.map +1 -0
- package/internal/components/chart-legend/index.d.ts +14 -0
- package/internal/components/chart-legend/index.js +245 -0
- package/internal/components/chart-legend/index.js.map +1 -0
- package/internal/components/chart-legend/styles.css.js +22 -0
- package/internal/components/chart-legend/styles.scoped.css +233 -0
- package/internal/components/chart-legend/styles.selectors.js +23 -0
- package/internal/components/chart-legend/test-classes/styles.css.js +11 -0
- package/internal/components/chart-legend/test-classes/styles.scoped.css +12 -0
- package/internal/components/chart-legend/test-classes/styles.selectors.js +12 -0
- package/internal/components/chart-series-filter/index.d.ts +17 -0
- package/internal/components/chart-series-filter/index.js +14 -0
- package/internal/components/chart-series-filter/index.js.map +1 -0
- package/internal/components/interfaces.d.ts +17 -0
- package/internal/components/interfaces.js +4 -0
- package/internal/components/interfaces.js.map +1 -0
- package/internal/components/series-details/index.d.ts +23 -0
- package/internal/components/series-details/index.js +45 -0
- package/internal/components/series-details/index.js.map +1 -0
- package/internal/components/series-details/styles.css.js +22 -0
- package/internal/components/series-details/styles.scoped.css +150 -0
- package/internal/components/series-details/styles.selectors.js +23 -0
- package/internal/components/series-details/test-classes/styles.css.js +10 -0
- package/internal/components/series-details/test-classes/styles.scoped.css +11 -0
- package/internal/components/series-details/test-classes/styles.selectors.js +11 -0
- package/internal/components/series-marker/index.d.ts +8 -0
- package/internal/components/series-marker/index.js +45 -0
- package/internal/components/series-marker/index.js.map +1 -0
- package/internal/components/series-marker/interfaces.d.ts +1 -0
- package/internal/components/series-marker/interfaces.js +4 -0
- package/internal/components/series-marker/interfaces.js.map +1 -0
- package/internal/components/series-marker/render-marker.d.ts +3 -0
- package/internal/components/series-marker/render-marker.js +74 -0
- package/internal/components/series-marker/render-marker.js.map +1 -0
- package/internal/components/series-marker/styles.css.js +7 -0
- package/internal/components/series-marker/styles.scoped.css +55 -0
- package/internal/components/series-marker/styles.selectors.js +8 -0
- package/internal/environment.d.ts +4 -0
- package/internal/environment.js +5 -0
- package/internal/environment.json +7 -0
- package/internal/events/index.d.ts +23 -0
- package/internal/events/index.js +41 -0
- package/internal/events/index.js.map +1 -0
- package/internal/generated/styles/tokens.d.ts +756 -0
- package/internal/generated/styles/tokens.js +756 -0
- package/internal/generated/theming/index.cjs +12584 -0
- package/internal/generated/theming/index.cjs.d.ts +2399 -0
- package/internal/generated/theming/index.d.ts +2399 -0
- package/internal/generated/theming/index.js +12584 -0
- package/internal/manifest.json +3 -0
- package/internal/styles.css.js +6 -0
- package/internal/styles.scoped.css +13 -0
- package/internal/styles.selectors.js +7 -0
- package/internal/utils/apply-display-name.d.ts +1 -0
- package/internal/utils/apply-display-name.js +6 -0
- package/internal/utils/apply-display-name.js.map +1 -0
- package/internal/utils/async-store.d.ts +19 -0
- package/internal/utils/async-store.js +58 -0
- package/internal/utils/async-store.js.map +1 -0
- package/internal/utils/chart-series.d.ts +8 -0
- package/internal/utils/chart-series.js +11 -0
- package/internal/utils/chart-series.js.map +1 -0
- package/internal/utils/renderer-utils.d.ts +17 -0
- package/internal/utils/renderer-utils.js +95 -0
- package/internal/utils/renderer-utils.js.map +1 -0
- package/internal/utils/series-data.d.ts +2 -0
- package/internal/utils/series-data.js +8 -0
- package/internal/utils/series-data.js.map +1 -0
- package/internal/utils/test-i18n-provider.d.ts +8 -0
- package/internal/utils/test-i18n-provider.js +8 -0
- package/internal/utils/test-i18n-provider.js.map +1 -0
- package/internal/utils/use-previous.d.ts +4 -0
- package/internal/utils/use-previous.js +14 -0
- package/internal/utils/use-previous.js.map +1 -0
- package/internal/utils/utils.d.ts +16 -0
- package/internal/utils/utils.js +49 -0
- package/internal/utils/utils.js.map +1 -0
- package/internal-do-not-use/core-chart/index.d.ts +4 -0
- package/internal-do-not-use/core-chart/index.js +13 -0
- package/internal-do-not-use/core-chart/index.js.map +1 -0
- package/internal-do-not-use/core-legend/index.d.ts +2 -0
- package/internal-do-not-use/core-legend/index.js +11 -0
- package/internal-do-not-use/core-legend/index.js.map +1 -0
- package/package.json +106 -0
- package/pie-chart/chart-inner-area.d.ts +10 -0
- package/pie-chart/chart-inner-area.js +63 -0
- package/pie-chart/chart-inner-area.js.map +1 -0
- package/pie-chart/chart-pie-internal.d.ts +11 -0
- package/pie-chart/chart-pie-internal.js +103 -0
- package/pie-chart/chart-pie-internal.js.map +1 -0
- package/pie-chart/index.d.ts +5 -0
- package/pie-chart/index.js +48 -0
- package/pie-chart/index.js.map +1 -0
- package/pie-chart/interfaces.d.ts +101 -0
- package/pie-chart/interfaces.js +4 -0
- package/pie-chart/interfaces.js.map +1 -0
- package/pie-chart/test-classes/styles.css.js +8 -0
- package/pie-chart/test-classes/styles.scoped.css +9 -0
- package/pie-chart/test-classes/styles.selectors.js +9 -0
- package/test-utils/dom/cartesian-chart/index.d.ts +14 -0
- package/test-utils/dom/cartesian-chart/index.js +24 -0
- package/test-utils/dom/cartesian-chart/index.js.map +1 -0
- package/test-utils/dom/cartesian-chart/tooltip.d.ts +28 -0
- package/test-utils/dom/cartesian-chart/tooltip.js +48 -0
- package/test-utils/dom/cartesian-chart/tooltip.js.map +1 -0
- package/test-utils/dom/index.d.ts +46 -0
- package/test-utils/dom/index.js +35 -0
- package/test-utils/dom/index.js.map +1 -0
- package/test-utils/dom/internal/base.d.ts +93 -0
- package/test-utils/dom/internal/base.js +146 -0
- package/test-utils/dom/internal/base.js.map +1 -0
- package/test-utils/dom/internal/core.d.ts +14 -0
- package/test-utils/dom/internal/core.js +37 -0
- package/test-utils/dom/internal/core.js.map +1 -0
- package/test-utils/dom/pie-chart/index.d.ts +17 -0
- package/test-utils/dom/pie-chart/index.js +29 -0
- package/test-utils/dom/pie-chart/index.js.map +1 -0
- package/test-utils/selectors/cartesian-chart/index.d.ts +14 -0
- package/test-utils/selectors/cartesian-chart/index.js +24 -0
- package/test-utils/selectors/cartesian-chart/index.js.map +1 -0
- package/test-utils/selectors/cartesian-chart/tooltip.d.ts +28 -0
- package/test-utils/selectors/cartesian-chart/tooltip.js +48 -0
- package/test-utils/selectors/cartesian-chart/tooltip.js.map +1 -0
- package/test-utils/selectors/index.d.ts +46 -0
- package/test-utils/selectors/index.js +32 -0
- package/test-utils/selectors/index.js.map +1 -0
- package/test-utils/selectors/internal/base.d.ts +93 -0
- package/test-utils/selectors/internal/base.js +146 -0
- package/test-utils/selectors/internal/base.js.map +1 -0
- package/test-utils/selectors/internal/core.d.ts +14 -0
- package/test-utils/selectors/internal/core.js +37 -0
- package/test-utils/selectors/internal/core.js.map +1 -0
- package/test-utils/selectors/pie-chart/index.d.ts +17 -0
- package/test-utils/selectors/pie-chart/index.js +29 -0
- package/test-utils/selectors/pie-chart/index.js.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
package/NOTICE
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
package/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
## React components for Cloudscape Design System
|
|
2
|
+
|
|
3
|
+
This package contains the source code of chart components in the [Cloudscape Design System](https://cloudscape.design/).
|
|
4
|
+
For more information about chart components, see [the documentation](https://cloudscape.design/components/charts/).
|
|
5
|
+
|
|
6
|
+
Cloudscape is an open source design system for building intuitive, engaging, and inclusive user experiences at scale. It consists of an extensive set of guidelines to create web applications, along with the design resources and front-end components to streamline implementation.
|
|
7
|
+
|
|
8
|
+
Cloudscape was built for and is used by Amazon Web Services (AWS) products and services. We created it in 2016 to improve the user experience across AWS web applications, and also to help teams implement those applications faster. Since then, we have continued enhancing the system based on customer feedback and research.
|
|
9
|
+
|
|
10
|
+
## Getting help
|
|
11
|
+
|
|
12
|
+
You can [create bug reports or feature requests](https://github.com/cloudscape-design/chart-components/issues/new/choose), or [start a discussion](https://github.com/cloudscape-design/components/discussions) to ask a question. To minimize duplicates, we recommend that you search for existing bug reports, feature requests, or discussions before initiating a new thread.
|
|
13
|
+
|
|
14
|
+
## Contributing
|
|
15
|
+
|
|
16
|
+
The [contribution guidelines](/CONTRIBUTING.md) contains information on how to contribute, as well as our support model and versioning strategy.
|
|
17
|
+
|
|
18
|
+
## Security
|
|
19
|
+
|
|
20
|
+
See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information.
|
|
21
|
+
|
|
22
|
+
## License
|
|
23
|
+
|
|
24
|
+
This project is licensed under the Apache-2.0 License.
|
|
25
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { InternalBaseComponentProps } from "../internal/base-component/use-base-component";
|
|
3
|
+
import { SomeRequired } from "../internal/utils/utils";
|
|
4
|
+
import { CartesianChartProps } from "./interfaces";
|
|
5
|
+
interface InternalCartesianChartProps extends InternalBaseComponentProps, CartesianChartProps {
|
|
6
|
+
tooltip: SomeRequired<CartesianChartProps.TooltipOptions, "enabled" | "placement" | "size">;
|
|
7
|
+
legend: SomeRequired<CartesianChartProps.LegendOptions, "enabled">;
|
|
8
|
+
}
|
|
9
|
+
export declare const InternalCartesianChart: import("react").ForwardRefExoticComponent<InternalCartesianChartProps & import("react").RefAttributes<CartesianChartProps.Ref>>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
import { forwardRef, useImperativeHandle, useRef, useState } from "react";
|
|
5
|
+
import { useControllableState } from "@cloudscape-design/component-toolkit";
|
|
6
|
+
import { InternalCoreChart } from "../core/chart-core";
|
|
7
|
+
import { getOptionsId, isXThreshold } from "../core/utils";
|
|
8
|
+
import { fireNonCancelableEvent } from "../internal/events";
|
|
9
|
+
import { castArray } from "../internal/utils/utils";
|
|
10
|
+
import { transformCartesianSeries } from "./chart-series-cartesian";
|
|
11
|
+
import testClasses from "./test-classes/styles.css.js";
|
|
12
|
+
export const InternalCartesianChart = forwardRef(({ tooltip, ...props }, ref) => {
|
|
13
|
+
var _a, _b, _c, _d;
|
|
14
|
+
const apiRef = useRef(null);
|
|
15
|
+
// When visibleSeries and onVisibleSeriesChange are provided - the series visibility can be controlled from the outside.
|
|
16
|
+
// Otherwise - the component handles series visibility using its internal state.
|
|
17
|
+
useControllableState(props.visibleSeries, props.onVisibleSeriesChange, undefined, {
|
|
18
|
+
componentName: "CartesianChart",
|
|
19
|
+
propertyName: "visibleSeries",
|
|
20
|
+
changeHandlerName: "onVisibleSeriesChange",
|
|
21
|
+
});
|
|
22
|
+
const allSeriesIds = props.series.map((s) => getOptionsId(s));
|
|
23
|
+
// We keep local visible series state to compute threshold series data, that depends on series visibility.
|
|
24
|
+
const [visibleSeriesLocal, setVisibleSeriesLocal] = useState((_a = props.visibleSeries) !== null && _a !== void 0 ? _a : allSeriesIds);
|
|
25
|
+
const visibleSeriesState = (_b = props.visibleSeries) !== null && _b !== void 0 ? _b : visibleSeriesLocal;
|
|
26
|
+
const onVisibleSeriesChange = ({ detail: { items } }) => {
|
|
27
|
+
const visibleSeries = items.filter((i) => i.visible).map((i) => i.id);
|
|
28
|
+
if (props.visibleSeries) {
|
|
29
|
+
fireNonCancelableEvent(props.onVisibleSeriesChange, { visibleSeries });
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
setVisibleSeriesLocal(visibleSeries);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
// We convert cartesian tooltip options to the core chart's getTooltipContent callback,
|
|
36
|
+
// ensuring no internal types are exposed to the consumer-defined render functions.
|
|
37
|
+
const getTooltipContent = () => {
|
|
38
|
+
// We use point.series.userOptions to get the series options that were passed down to Highcharts,
|
|
39
|
+
// assuming Highcharts makes no modifications for those. These options are not referentially equal
|
|
40
|
+
// to the ones we get from the consumer due to the internal validation/transformation we run on them.
|
|
41
|
+
// See: https://api.highcharts.com/class-reference/Highcharts.Chart#userOptions.
|
|
42
|
+
const transformItem = (item) => {
|
|
43
|
+
var _a;
|
|
44
|
+
return ({
|
|
45
|
+
x: item.point.x,
|
|
46
|
+
y: isXThreshold(item.point.series) ? null : ((_a = item.point.y) !== null && _a !== void 0 ? _a : null),
|
|
47
|
+
series: item.point.series.userOptions,
|
|
48
|
+
errorRanges: item.errorRanges.map((point) => {
|
|
49
|
+
var _a, _b;
|
|
50
|
+
return ({
|
|
51
|
+
low: (_a = point.options.low) !== null && _a !== void 0 ? _a : 0,
|
|
52
|
+
high: (_b = point.options.high) !== null && _b !== void 0 ? _b : 0,
|
|
53
|
+
series: point.series.userOptions,
|
|
54
|
+
});
|
|
55
|
+
}),
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
const transformSeriesProps = (props) => ({
|
|
59
|
+
item: transformItem(props.item),
|
|
60
|
+
});
|
|
61
|
+
const transformSlotProps = (props) => ({
|
|
62
|
+
x: props.x,
|
|
63
|
+
items: props.items.map(transformItem),
|
|
64
|
+
});
|
|
65
|
+
return {
|
|
66
|
+
point: tooltip.point ? (props) => tooltip.point(transformSeriesProps(props)) : undefined,
|
|
67
|
+
header: tooltip.header ? (props) => tooltip.header(transformSlotProps(props)) : undefined,
|
|
68
|
+
body: tooltip.body ? (props) => tooltip.body(transformSlotProps(props)) : undefined,
|
|
69
|
+
footer: tooltip.footer ? (props) => tooltip.footer(transformSlotProps(props)) : undefined,
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
// Converting x-, and y-threshold series to Highcharts series and plot lines.
|
|
73
|
+
const { series, xPlotLines, yPlotLines } = transformCartesianSeries(props.series, visibleSeriesState);
|
|
74
|
+
// Cartesian chart imperative API.
|
|
75
|
+
useImperativeHandle(ref, () => ({
|
|
76
|
+
setVisibleSeries: (visibleSeriesIds) => { var _a; return (_a = apiRef.current) === null || _a === void 0 ? void 0 : _a.setItemsVisible(visibleSeriesIds); },
|
|
77
|
+
showAllSeries: () => { var _a; return (_a = apiRef.current) === null || _a === void 0 ? void 0 : _a.setItemsVisible(allSeriesIds); },
|
|
78
|
+
}));
|
|
79
|
+
return (_jsx(InternalCoreChart, { ...props, callback: (api) => (apiRef.current = api), options: {
|
|
80
|
+
chart: {
|
|
81
|
+
inverted: props.inverted,
|
|
82
|
+
},
|
|
83
|
+
plotOptions: {
|
|
84
|
+
series: { stacking: props.stacking },
|
|
85
|
+
},
|
|
86
|
+
series,
|
|
87
|
+
xAxis: (_c = castArray(props.xAxis)) === null || _c === void 0 ? void 0 : _c.map((xAxisProps) => ({
|
|
88
|
+
...xAxisProps,
|
|
89
|
+
title: { text: xAxisProps.title },
|
|
90
|
+
plotLines: xPlotLines,
|
|
91
|
+
})),
|
|
92
|
+
yAxis: (_d = castArray(props.yAxis)) === null || _d === void 0 ? void 0 : _d.map((yAxisProps) => ({
|
|
93
|
+
...yAxisProps,
|
|
94
|
+
title: { text: yAxisProps.title },
|
|
95
|
+
plotLines: yPlotLines,
|
|
96
|
+
})),
|
|
97
|
+
}, tooltip: tooltip, getTooltipContent: getTooltipContent, visibleItems: props.visibleSeries, onVisibleItemsChange: onVisibleSeriesChange, className: testClasses.root }));
|
|
98
|
+
});
|
|
99
|
+
//# sourceMappingURL=chart-cartesian-internal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chart-cartesian-internal.js","sourceRoot":"","sources":["../../../src/cartesian-chart/chart-cartesian-internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE1E,OAAO,EAAE,oBA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C,CAAA,EAAA;QACzF,aAAa,EAAE,GAAG,EAAE,WAAC,OAAA,MAAA,MAAM,CAAC,OAAO,0CAAE,eAAe,CAAC,YAAY,CAAC,CAAA,EAAA;KACnE,CAAC,CAAC,CAAC;IAEJ,OAAO,CACL,KAAC,iBAAiB,OACZ,KAAK,EACT,QAAQ,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,GAAG,GAAG,CAAC,EACzC,OAAO,EAAE;YACP,KAAK,EAAE;gBACL,QAAQ,EAAE,KAAK,CAAC,QAAQ;aACzB;YACD,WAAW,EAAE;gBACX,MAAM,EAAE,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE;aACrC;YACD,MAAM;YACN,KAAK,EAAE,MAAA,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,0CAAE,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;gBAClD,GAAG,UAAU;gBACb,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,CAAC,KAAK,EAAE;gBACjC,SAAS,EAAE,UAAU;aACtB,CAAC,CAAC;YACH,KAAK,EAAE,MAAA,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,0CAAE,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;gBAClD,GAAG,UAAU;gBACb,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,CAAC,KAAK,EAAE;gBACjC,SAAS,EAAE,UAAU;aACtB,CAAC,CAAC;SACJ,EACD,OAAO,EAAE,OAAO,EAChB,iBAAiB,EAAE,iBAAiB,EACpC,YAAY,EAAE,KAAK,CAAC,aAAa,EACjC,oBAAoB,EAAE,qBAAqB,EAC3C,SAAS,EAAE,WAAW,CAAC,IAAI,GAC3B,CACH,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { forwardRef, useImperativeHandle, useRef, useState } from \"react\";\n\nimport { useControllableState } from \"@cloudscape-design/component-toolkit\";\n\nimport { InternalCoreChart } from \"../core/chart-core\";\nimport { CoreChartProps, ErrorBarSeriesOptions } from \"../core/interfaces\";\nimport { getOptionsId, isXThreshold } from \"../core/utils\";\nimport { InternalBaseComponentProps } from \"../internal/base-component/use-base-component\";\nimport { fireNonCancelableEvent } from \"../internal/events\";\nimport { castArray, SomeRequired } from \"../internal/utils/utils\";\nimport { transformCartesianSeries } from \"./chart-series-cartesian\";\nimport { CartesianChartProps, NonErrorBarSeriesOptions } from \"./interfaces\";\n\nimport testClasses from \"./test-classes/styles.css.js\";\n\ninterface InternalCartesianChartProps extends InternalBaseComponentProps, CartesianChartProps {\n tooltip: SomeRequired<CartesianChartProps.TooltipOptions, \"enabled\" | \"placement\" | \"size\">;\n legend: SomeRequired<CartesianChartProps.LegendOptions, \"enabled\">;\n}\n\nexport const InternalCartesianChart = forwardRef(\n ({ tooltip, ...props }: InternalCartesianChartProps, ref: React.Ref<CartesianChartProps.Ref>) => {\n const apiRef = useRef<null | CoreChartProps.ChartAPI>(null);\n\n // When visibleSeries and onVisibleSeriesChange are provided - the series visibility can be controlled from the outside.\n // Otherwise - the component handles series visibility using its internal state.\n useControllableState(props.visibleSeries, props.onVisibleSeriesChange, undefined, {\n componentName: \"CartesianChart\",\n propertyName: \"visibleSeries\",\n changeHandlerName: \"onVisibleSeriesChange\",\n });\n const allSeriesIds = props.series.map((s) => getOptionsId(s));\n // We keep local visible series state to compute threshold series data, that depends on series visibility.\n const [visibleSeriesLocal, setVisibleSeriesLocal] = useState(props.visibleSeries ?? allSeriesIds);\n const visibleSeriesState = props.visibleSeries ?? visibleSeriesLocal;\n const onVisibleSeriesChange: CoreChartProps[\"onVisibleItemsChange\"] = ({ detail: { items } }) => {\n const visibleSeries = items.filter((i) => i.visible).map((i) => i.id);\n if (props.visibleSeries) {\n fireNonCancelableEvent(props.onVisibleSeriesChange, { visibleSeries });\n } else {\n setVisibleSeriesLocal(visibleSeries);\n }\n };\n\n // We convert cartesian tooltip options to the core chart's getTooltipContent callback,\n // ensuring no internal types are exposed to the consumer-defined render functions.\n const getTooltipContent: CoreChartProps[\"getTooltipContent\"] = () => {\n // We use point.series.userOptions to get the series options that were passed down to Highcharts,\n // assuming Highcharts makes no modifications for those. These options are not referentially equal\n // to the ones we get from the consumer due to the internal validation/transformation we run on them.\n // See: https://api.highcharts.com/class-reference/Highcharts.Chart#userOptions.\n const transformItem = (item: CoreChartProps.TooltipContentItem): CartesianChartProps.TooltipPointItem => ({\n x: item.point.x,\n y: isXThreshold(item.point.series) ? null : (item.point.y ?? null),\n series: item.point.series.userOptions as NonErrorBarSeriesOptions,\n errorRanges: item.errorRanges.map((point) => ({\n low: point.options.low ?? 0,\n high: point.options.high ?? 0,\n series: point.series.userOptions as ErrorBarSeriesOptions,\n })),\n });\n const transformSeriesProps = (\n props: CoreChartProps.TooltipPointProps,\n ): CartesianChartProps.TooltipPointRenderProps => ({\n item: transformItem(props.item),\n });\n const transformSlotProps = (\n props: CoreChartProps.TooltipSlotProps,\n ): CartesianChartProps.TooltipSlotRenderProps => ({\n x: props.x,\n items: props.items.map(transformItem),\n });\n return {\n point: tooltip.point ? (props) => tooltip.point!(transformSeriesProps(props)) : undefined,\n header: tooltip.header ? (props) => tooltip.header!(transformSlotProps(props)) : undefined,\n body: tooltip.body ? (props) => tooltip.body!(transformSlotProps(props)) : undefined,\n footer: tooltip.footer ? (props) => tooltip.footer!(transformSlotProps(props)) : undefined,\n };\n };\n\n // Converting x-, and y-threshold series to Highcharts series and plot lines.\n const { series, xPlotLines, yPlotLines } = transformCartesianSeries(props.series, visibleSeriesState);\n\n // Cartesian chart imperative API.\n useImperativeHandle(ref, () => ({\n setVisibleSeries: (visibleSeriesIds) => apiRef.current?.setItemsVisible(visibleSeriesIds),\n showAllSeries: () => apiRef.current?.setItemsVisible(allSeriesIds),\n }));\n\n return (\n <InternalCoreChart\n {...props}\n callback={(api) => (apiRef.current = api)}\n options={{\n chart: {\n inverted: props.inverted,\n },\n plotOptions: {\n series: { stacking: props.stacking },\n },\n series,\n xAxis: castArray(props.xAxis)?.map((xAxisProps) => ({\n ...xAxisProps,\n title: { text: xAxisProps.title },\n plotLines: xPlotLines,\n })),\n yAxis: castArray(props.yAxis)?.map((yAxisProps) => ({\n ...yAxisProps,\n title: { text: yAxisProps.title },\n plotLines: yPlotLines,\n })),\n }}\n tooltip={tooltip}\n getTooltipContent={getTooltipContent}\n visibleItems={props.visibleSeries}\n onVisibleItemsChange={onVisibleSeriesChange}\n className={testClasses.root}\n />\n );\n },\n);\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type Highcharts from "highcharts";
|
|
2
|
+
import { CartesianChartProps } from "./interfaces";
|
|
3
|
+
export declare const transformCartesianSeries: (originalSeries: readonly CartesianChartProps.SeriesOptions[], visibleSeries: readonly string[]) => {
|
|
4
|
+
series: Highcharts.SeriesOptionsType[];
|
|
5
|
+
xPlotLines: Highcharts.XAxisPlotLinesOptions[];
|
|
6
|
+
yPlotLines: Highcharts.YAxisPlotLinesOptions[];
|
|
7
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { colorChartsErrorBarMarker } from "@cloudscape-design/design-tokens";
|
|
4
|
+
import { createThresholdMetadata, getOptionsId } from "../core/utils";
|
|
5
|
+
import * as Styles from "../internal/chart-styles";
|
|
6
|
+
// The utility transforms cartesian chart component's series to Highcharts series. This includes transforming
|
|
7
|
+
// custom x- and y-threshold series types, that are represented as a combination of invisible line series, and plot lines.
|
|
8
|
+
// The plot lines, unlike series, are rendered across the entire chart plot width or height.
|
|
9
|
+
export const transformCartesianSeries = (originalSeries, visibleSeries) => {
|
|
10
|
+
var _a;
|
|
11
|
+
// The injected plot lines have IDs matching the IDs of the threshold series. This is used by the core chart
|
|
12
|
+
// to manage visibility and highlight state for them, when the corresponding threshold series are toggled
|
|
13
|
+
// or highlighted in the legend or filter.
|
|
14
|
+
const xPlotLines = [];
|
|
15
|
+
const yPlotLines = [];
|
|
16
|
+
for (const s of originalSeries) {
|
|
17
|
+
const seriesId = getOptionsId(s);
|
|
18
|
+
const style = { ...Styles.thresholdPlotLine, color: (_a = s.color) !== null && _a !== void 0 ? _a : Styles.thresholdPlotLine.color };
|
|
19
|
+
if (s.type === "x-threshold" && visibleSeries.includes(seriesId)) {
|
|
20
|
+
xPlotLines.push({ id: seriesId, value: s.value, ...style });
|
|
21
|
+
}
|
|
22
|
+
if (s.type === "y-threshold" && visibleSeries.includes(seriesId)) {
|
|
23
|
+
yPlotLines.push({ id: seriesId, value: s.value, ...style });
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// The threshold series require data points to enable keyboard navigation and hover effects.
|
|
27
|
+
const thresholdX = getThresholdX(originalSeries, visibleSeries);
|
|
28
|
+
const thresholdY = getThresholdY(originalSeries, visibleSeries);
|
|
29
|
+
function transformSeriesToHighcharts(s) {
|
|
30
|
+
var _a, _b;
|
|
31
|
+
if (s.type === "x-threshold" || s.type === "y-threshold") {
|
|
32
|
+
const data = s.type === "x-threshold"
|
|
33
|
+
? thresholdY.map((y) => ({ x: s.value, y }))
|
|
34
|
+
: thresholdX.map((x) => ({ x, y: s.value }));
|
|
35
|
+
const { custom } = createThresholdMetadata(s.type, s.value);
|
|
36
|
+
const enableMouseTracking = s.type === "y-threshold";
|
|
37
|
+
const style = { ...Styles.thresholdSeries, color: (_a = s.color) !== null && _a !== void 0 ? _a : Styles.thresholdSeries.color };
|
|
38
|
+
return { type: "line", id: s.id, name: s.name, data, custom, enableMouseTracking, ...style };
|
|
39
|
+
}
|
|
40
|
+
if (s.type === "errorbar") {
|
|
41
|
+
const color = (_b = s.color) !== null && _b !== void 0 ? _b : colorChartsErrorBarMarker;
|
|
42
|
+
// In Highcharts, the error-bar series graphic color is represented as stem-, and whisker colors.
|
|
43
|
+
// We simplify that, and only expose a single color prop that sets both of those.
|
|
44
|
+
const colors = { stemColor: color, whiskerColor: color };
|
|
45
|
+
return { ...s, data: s.data, ...colors };
|
|
46
|
+
}
|
|
47
|
+
return { ...s, data: s.data };
|
|
48
|
+
}
|
|
49
|
+
const series = originalSeries.map(transformSeriesToHighcharts);
|
|
50
|
+
// We inject a fake empty series so that the empty state still shows axes, if defined.
|
|
51
|
+
if (series.length === 0) {
|
|
52
|
+
series.push({ type: "line", data: [], showInLegend: false });
|
|
53
|
+
}
|
|
54
|
+
return { series, xPlotLines, yPlotLines };
|
|
55
|
+
};
|
|
56
|
+
// For x-threshold the point-based navigation is disabled as irrelevant. However, we still need at least
|
|
57
|
+
// one data point for core chart to work correctly, so we find the first visible y value from other series.
|
|
58
|
+
function getThresholdY(series, visibleSeries) {
|
|
59
|
+
for (const s of getVisibleDataSeries(series, visibleSeries)) {
|
|
60
|
+
for (const d of s.data) {
|
|
61
|
+
const y = d === null ? null : typeof d === "number" ? d : d.y;
|
|
62
|
+
if (y !== null) {
|
|
63
|
+
return [y];
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return [];
|
|
68
|
+
}
|
|
69
|
+
// For y-threshold we find all defined x values from other series and use it those to create an array of
|
|
70
|
+
// data points. As result, the y-threshold series becomes properly navigable.
|
|
71
|
+
function getThresholdX(series, visibleSeries) {
|
|
72
|
+
var _a;
|
|
73
|
+
const allX = new Set();
|
|
74
|
+
for (const s of getVisibleDataSeries(series, visibleSeries)) {
|
|
75
|
+
for (let i = 0; i < s.data.length; i++) {
|
|
76
|
+
const d = s.data[i];
|
|
77
|
+
const x = (_a = (typeof d === "object" ? d === null || d === void 0 ? void 0 : d.x : i)) !== null && _a !== void 0 ? _a : i;
|
|
78
|
+
allX.add(x);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return [...allX].sort((a, b) => a - b);
|
|
82
|
+
}
|
|
83
|
+
function getVisibleDataSeries(series, visibleSeries) {
|
|
84
|
+
const dataSeries = [];
|
|
85
|
+
for (const s of series) {
|
|
86
|
+
if (s.type !== "x-threshold" &&
|
|
87
|
+
s.type !== "y-threshold" &&
|
|
88
|
+
s.type !== "errorbar" &&
|
|
89
|
+
visibleSeries.includes(getOptionsId(s))) {
|
|
90
|
+
dataSeries.push(s);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return dataSeries;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=chart-series-cartesian.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chart-series-cartesian.js","sourceRoot":"","sources":["../../../src/cartesian-chart/chart-series-cartesian.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAItC,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAG7E,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,KAAK,MAAM,MAAM,0BAA0B,CAAC;AAInD,6GAA6G;AAC7G,0HAA0H;AAC1H,4FAA4F;AAC5F,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,cAA4D,EAC5D,aAAgC,EAChC,EAAE;;IACF,4GAA4G;IAC5G,yGAAyG;IACzG,0CAA0C;IAC1C,MAAM,UAAU,GAAuC,EAAE,CAAC;IAC1D,MAAM,UAAU,GAAuC,EAAE,CAAC;IAC1D,KAAK,MAAM,CAAC,IAAI,cAAc,EAAE;QAC9B,MAAM,QAAQ,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;QACjC,MAAM,KAAK,GAAG,EAAE,GAAG,MAAM,CAAC,iBAAiB,EAAE,KAAK,EAAE,MAAA,CAAC,CAAC,KAAK,mCAAI,MAAM,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC;QAChG,IAAI,CAAC,CAAC,IAAI,KAAK,aAAa,IAAI,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;YAChE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C,CAAC,IAAI,KAAK,UAAU;YACrB,aAAa,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EACvC;YACA,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACpB;KACF;IACD,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type Highcharts from \"highcharts\";\n\nimport { colorChartsErrorBarMarker } from \"@cloudscape-design/design-tokens\";\n\nimport { PointDataItemType, RangeDataItemOptions } from \"../core/interfaces\";\nimport { createThresholdMetadata, getOptionsId } from \"../core/utils\";\nimport * as Styles from \"../internal/chart-styles\";\nimport { Writeable } from \"../internal/utils/utils\";\nimport { CartesianChartProps } from \"./interfaces\";\n\n// The utility transforms cartesian chart component's series to Highcharts series. This includes transforming\n// custom x- and y-threshold series types, that are represented as a combination of invisible line series, and plot lines.\n// The plot lines, unlike series, are rendered across the entire chart plot width or height.\nexport const transformCartesianSeries = (\n originalSeries: readonly CartesianChartProps.SeriesOptions[],\n visibleSeries: readonly string[],\n) => {\n // The injected plot lines have IDs matching the IDs of the threshold series. This is used by the core chart\n // to manage visibility and highlight state for them, when the corresponding threshold series are toggled\n // or highlighted in the legend or filter.\n const xPlotLines: Highcharts.XAxisPlotLinesOptions[] = [];\n const yPlotLines: Highcharts.YAxisPlotLinesOptions[] = [];\n for (const s of originalSeries) {\n const seriesId = getOptionsId(s);\n const style = { ...Styles.thresholdPlotLine, color: s.color ?? Styles.thresholdPlotLine.color };\n if (s.type === \"x-threshold\" && visibleSeries.includes(seriesId)) {\n xPlotLines.push({ id: seriesId, value: s.value, ...style });\n }\n if (s.type === \"y-threshold\" && visibleSeries.includes(seriesId)) {\n yPlotLines.push({ id: seriesId, value: s.value, ...style });\n }\n }\n // The threshold series require data points to enable keyboard navigation and hover effects.\n const thresholdX = getThresholdX(originalSeries, visibleSeries);\n const thresholdY = getThresholdY(originalSeries, visibleSeries);\n function transformSeriesToHighcharts(s: CartesianChartProps.SeriesOptions): Highcharts.SeriesOptionsType {\n if (s.type === \"x-threshold\" || s.type === \"y-threshold\") {\n const data =\n s.type === \"x-threshold\"\n ? thresholdY.map((y) => ({ x: s.value, y }))\n : thresholdX.map((x) => ({ x, y: s.value }));\n const { custom } = createThresholdMetadata(s.type, s.value);\n const enableMouseTracking = s.type === \"y-threshold\";\n const style = { ...Styles.thresholdSeries, color: s.color ?? Styles.thresholdSeries.color };\n return { type: \"line\", id: s.id, name: s.name, data, custom, enableMouseTracking, ...style };\n }\n if (s.type === \"errorbar\") {\n const color = s.color ?? colorChartsErrorBarMarker;\n // In Highcharts, the error-bar series graphic color is represented as stem-, and whisker colors.\n // We simplify that, and only expose a single color prop that sets both of those.\n const colors = { stemColor: color, whiskerColor: color };\n return { ...s, data: s.data as Writeable<RangeDataItemOptions[]>, ...colors };\n }\n return { ...s, data: s.data as Writeable<PointDataItemType[]> };\n }\n const series = originalSeries.map(transformSeriesToHighcharts);\n // We inject a fake empty series so that the empty state still shows axes, if defined.\n if (series.length === 0) {\n series.push({ type: \"line\", data: [], showInLegend: false });\n }\n return { series, xPlotLines, yPlotLines };\n};\n\n// For x-threshold the point-based navigation is disabled as irrelevant. However, we still need at least\n// one data point for core chart to work correctly, so we find the first visible y value from other series.\nfunction getThresholdY(series: readonly CartesianChartProps.SeriesOptions[], visibleSeries: readonly string[]) {\n for (const s of getVisibleDataSeries(series, visibleSeries)) {\n for (const d of s.data) {\n const y = d === null ? null : typeof d === \"number\" ? d : d.y;\n if (y !== null) {\n return [y];\n }\n }\n }\n return [];\n}\n\n// For y-threshold we find all defined x values from other series and use it those to create an array of\n// data points. As result, the y-threshold series becomes properly navigable.\nfunction getThresholdX(series: readonly CartesianChartProps.SeriesOptions[], visibleSeries: readonly string[]) {\n const allX = new Set<number>();\n for (const s of getVisibleDataSeries(series, visibleSeries)) {\n for (let i = 0; i < s.data.length; i++) {\n const d = s.data[i];\n const x = (typeof d === \"object\" ? d?.x : i) ?? i;\n allX.add(x);\n }\n }\n return [...allX].sort((a, b) => a - b);\n}\n\nfunction getVisibleDataSeries(series: readonly CartesianChartProps.SeriesOptions[], visibleSeries: readonly string[]) {\n const dataSeries: Exclude<\n CartesianChartProps.SeriesOptions,\n | CartesianChartProps.XThresholdSeriesOptions\n | CartesianChartProps.YThresholdSeriesOptions\n | CartesianChartProps.ErrorBarSeriesOptions\n >[] = [];\n for (const s of series) {\n if (\n s.type !== \"x-threshold\" &&\n s.type !== \"y-threshold\" &&\n s.type !== \"errorbar\" &&\n visibleSeries.includes(getOptionsId(s))\n ) {\n dataSeries.push(s);\n }\n }\n return dataSeries;\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { CartesianChartProps } from "./interfaces";
|
|
3
|
+
export type { CartesianChartProps };
|
|
4
|
+
declare const CartesianChart: import("react").ForwardRefExoticComponent<CartesianChartProps & import("react").RefAttributes<CartesianChartProps.Ref>>;
|
|
5
|
+
export default CartesianChart;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
import { forwardRef } from "react";
|
|
5
|
+
import { warnOnce } from "@cloudscape-design/component-toolkit/internal";
|
|
6
|
+
import { getDataAttributes } from "../internal/base-component/get-data-attributes";
|
|
7
|
+
import useBaseComponent from "../internal/base-component/use-base-component";
|
|
8
|
+
import { applyDisplayName } from "../internal/utils/apply-display-name";
|
|
9
|
+
import { InternalCartesianChart } from "./chart-cartesian-internal";
|
|
10
|
+
const CartesianChart = forwardRef(({ fitHeight = false, inverted = false, stacking = undefined, emphasizeBaseline = true, verticalAxisTitlePlacement = "top", ...props }, ref) => {
|
|
11
|
+
// We transform options before propagating them to the internal chart to ensure only those
|
|
12
|
+
// defined in the component's contract can be propagated down to the underlying Highcharts.
|
|
13
|
+
// Additionally, we assign all default options, including the nested ones.
|
|
14
|
+
const series = transformSeries(props.series, stacking);
|
|
15
|
+
const xAxis = transformXAxisOptions(props.xAxis);
|
|
16
|
+
const yAxis = transformYAxisOptions(props.yAxis);
|
|
17
|
+
const tooltip = transformTooltip(props.tooltip);
|
|
18
|
+
const legend = transformLegend(props.legend);
|
|
19
|
+
const baseComponentProps = useBaseComponent("CartesianChart", {
|
|
20
|
+
props: { fitHeight, inverted, stacking, emphasizeBaseline, verticalAxisTitlePlacement },
|
|
21
|
+
metadata: {},
|
|
22
|
+
});
|
|
23
|
+
return (_jsx(InternalCartesianChart, { ref: ref, ...props, fitHeight: fitHeight, inverted: inverted, stacking: stacking, emphasizeBaseline: emphasizeBaseline, verticalAxisTitlePlacement: verticalAxisTitlePlacement, series: series, xAxis: xAxis, yAxis: yAxis, tooltip: tooltip, legend: legend, ...getDataAttributes(props), ...baseComponentProps }));
|
|
24
|
+
});
|
|
25
|
+
applyDisplayName(CartesianChart, "CartesianChart");
|
|
26
|
+
export default CartesianChart;
|
|
27
|
+
function transformSeries(untransformedSeries, stacking) {
|
|
28
|
+
const transformedSeries = [];
|
|
29
|
+
function transformSingleSeries(s) {
|
|
30
|
+
switch (s.type) {
|
|
31
|
+
case "area":
|
|
32
|
+
case "areaspline":
|
|
33
|
+
case "line":
|
|
34
|
+
case "spline":
|
|
35
|
+
return transformLineLikeSeries(s);
|
|
36
|
+
case "column":
|
|
37
|
+
return transformColumnSeries(s);
|
|
38
|
+
case "scatter":
|
|
39
|
+
return transformScatterSeries(s);
|
|
40
|
+
case "errorbar":
|
|
41
|
+
return transformErrorBarSeries(s, untransformedSeries, stacking);
|
|
42
|
+
case "x-threshold":
|
|
43
|
+
case "y-threshold":
|
|
44
|
+
return transformThresholdSeries(s);
|
|
45
|
+
default:
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
for (const series of untransformedSeries) {
|
|
50
|
+
const transformed = transformSingleSeries(series);
|
|
51
|
+
if (transformed) {
|
|
52
|
+
transformedSeries.push(transformed);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return transformedSeries;
|
|
56
|
+
}
|
|
57
|
+
function transformLineLikeSeries(s) {
|
|
58
|
+
const data = transformPointData(s.data);
|
|
59
|
+
return { type: s.type, id: s.id, name: s.name, color: s.color, data };
|
|
60
|
+
}
|
|
61
|
+
function transformColumnSeries(s) {
|
|
62
|
+
const data = transformPointData(s.data);
|
|
63
|
+
return { type: s.type, id: s.id, name: s.name, color: s.color, data };
|
|
64
|
+
}
|
|
65
|
+
function transformScatterSeries(s) {
|
|
66
|
+
var _a;
|
|
67
|
+
const data = transformPointData(s.data);
|
|
68
|
+
const marker = (_a = s.marker) !== null && _a !== void 0 ? _a : {};
|
|
69
|
+
return { type: s.type, id: s.id, name: s.name, color: s.color, data, marker };
|
|
70
|
+
}
|
|
71
|
+
function transformThresholdSeries(s) {
|
|
72
|
+
return { type: s.type, id: s.id, name: s.name, color: s.color, value: s.value };
|
|
73
|
+
}
|
|
74
|
+
function transformErrorBarSeries(series, allSeries, stacking) {
|
|
75
|
+
// Highcharts only supports error bars for non-stacked series.
|
|
76
|
+
// See: https://github.com/highcharts/highcharts/issues/23080.
|
|
77
|
+
if (stacking) {
|
|
78
|
+
warnOnce("CartesianChart", "Error bars are not supported for stacked series.");
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
// We only support error bars that are linked to some other series. It is only possible to link it
|
|
82
|
+
// using series ID (but not name), or by using ":previous" pseudo-selector.
|
|
83
|
+
// See: https://api.highcharts.com/highcharts/series.errorbar.linkedTo.
|
|
84
|
+
const linkedSeries = series.linkedTo === ":previous"
|
|
85
|
+
? allSeries[allSeries.indexOf(series) - 1]
|
|
86
|
+
: allSeries.find(({ id }) => id === series.linkedTo);
|
|
87
|
+
// The non-linked error bars are not supported: those will not appear in our custom legend and tooltip,
|
|
88
|
+
// so we remove them from the series array. We also do not support linking them to other error bars,
|
|
89
|
+
// or our custom threshold series.
|
|
90
|
+
if (!linkedSeries || ["errorbar", "x-threshold", "y-threshold"].includes(linkedSeries.type)) {
|
|
91
|
+
warnOnce("CartesianChart", 'The `linkedTo` property of "errorbar" series points to a missing, or unsupported series.');
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
const data = transformRangeData(series.data);
|
|
95
|
+
return { type: series.type, id: series.id, name: series.name, color: series.color, linkedTo: series.linkedTo, data };
|
|
96
|
+
}
|
|
97
|
+
function transformPointData(data) {
|
|
98
|
+
return data.map((d) => (d && typeof d === "object" ? { x: d.x, y: d.y } : d));
|
|
99
|
+
}
|
|
100
|
+
function transformRangeData(data) {
|
|
101
|
+
return data.map((d) => ({ x: d.x, low: d.low, high: d.high }));
|
|
102
|
+
}
|
|
103
|
+
function transformXAxisOptions(axis) {
|
|
104
|
+
return transformAxisOptions(axis);
|
|
105
|
+
}
|
|
106
|
+
function transformYAxisOptions(axis) {
|
|
107
|
+
return { ...transformAxisOptions(axis), reversedStacks: axis === null || axis === void 0 ? void 0 : axis.reversedStacks };
|
|
108
|
+
}
|
|
109
|
+
function transformAxisOptions(axis) {
|
|
110
|
+
return {
|
|
111
|
+
type: axis === null || axis === void 0 ? void 0 : axis.type,
|
|
112
|
+
title: axis === null || axis === void 0 ? void 0 : axis.title,
|
|
113
|
+
min: axis === null || axis === void 0 ? void 0 : axis.min,
|
|
114
|
+
max: axis === null || axis === void 0 ? void 0 : axis.max,
|
|
115
|
+
tickInterval: axis === null || axis === void 0 ? void 0 : axis.tickInterval,
|
|
116
|
+
categories: axis === null || axis === void 0 ? void 0 : axis.categories,
|
|
117
|
+
valueFormatter: axis === null || axis === void 0 ? void 0 : axis.valueFormatter,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function transformTooltip(tooltip) {
|
|
121
|
+
var _a, _b, _c;
|
|
122
|
+
return {
|
|
123
|
+
...tooltip,
|
|
124
|
+
enabled: (_a = tooltip === null || tooltip === void 0 ? void 0 : tooltip.enabled) !== null && _a !== void 0 ? _a : true,
|
|
125
|
+
placement: (_b = tooltip === null || tooltip === void 0 ? void 0 : tooltip.placement) !== null && _b !== void 0 ? _b : "middle",
|
|
126
|
+
size: (_c = tooltip === null || tooltip === void 0 ? void 0 : tooltip.size) !== null && _c !== void 0 ? _c : "medium",
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function transformLegend(legend) {
|
|
130
|
+
var _a;
|
|
131
|
+
return { ...legend, enabled: (_a = legend === null || legend === void 0 ? void 0 : legend.enabled) !== null && _a !== void 0 ? _a : true };
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=index.js.map
|