@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.
Files changed (246) hide show
  1. package/LICENSE +175 -0
  2. package/NOTICE +1 -0
  3. package/README.md +25 -0
  4. package/cartesian-chart/chart-cartesian-internal.d.ts +10 -0
  5. package/cartesian-chart/chart-cartesian-internal.js +99 -0
  6. package/cartesian-chart/chart-cartesian-internal.js.map +1 -0
  7. package/cartesian-chart/chart-series-cartesian.d.ts +7 -0
  8. package/cartesian-chart/chart-series-cartesian.js +95 -0
  9. package/cartesian-chart/chart-series-cartesian.js.map +1 -0
  10. package/cartesian-chart/index.d.ts +5 -0
  11. package/cartesian-chart/index.js +133 -0
  12. package/cartesian-chart/index.js.map +1 -0
  13. package/cartesian-chart/interfaces.d.ts +166 -0
  14. package/cartesian-chart/interfaces.js +4 -0
  15. package/cartesian-chart/interfaces.js.map +1 -0
  16. package/cartesian-chart/test-classes/styles.css.js +6 -0
  17. package/cartesian-chart/test-classes/styles.scoped.css +7 -0
  18. package/cartesian-chart/test-classes/styles.selectors.js +7 -0
  19. package/core/chart-api/chart-extra-axis-titles.d.ts +10 -0
  20. package/core/chart-api/chart-extra-axis-titles.js +42 -0
  21. package/core/chart-api/chart-extra-axis-titles.js.map +1 -0
  22. package/core/chart-api/chart-extra-context.d.ts +41 -0
  23. package/core/chart-api/chart-extra-context.js +93 -0
  24. package/core/chart-api/chart-extra-context.js.map +1 -0
  25. package/core/chart-api/chart-extra-highlight.d.ts +20 -0
  26. package/core/chart-api/chart-extra-highlight.js +205 -0
  27. package/core/chart-api/chart-extra-highlight.js.map +1 -0
  28. package/core/chart-api/chart-extra-legend.d.ts +27 -0
  29. package/core/chart-api/chart-extra-legend.js +118 -0
  30. package/core/chart-api/chart-extra-legend.js.map +1 -0
  31. package/core/chart-api/chart-extra-navigation.d.ts +84 -0
  32. package/core/chart-api/chart-extra-navigation.js +470 -0
  33. package/core/chart-api/chart-extra-navigation.js.map +1 -0
  34. package/core/chart-api/chart-extra-nodata.d.ts +15 -0
  35. package/core/chart-api/chart-extra-nodata.js +45 -0
  36. package/core/chart-api/chart-extra-nodata.js.map +1 -0
  37. package/core/chart-api/chart-extra-pointer.d.ts +33 -0
  38. package/core/chart-api/chart-extra-pointer.js +173 -0
  39. package/core/chart-api/chart-extra-pointer.js.map +1 -0
  40. package/core/chart-api/chart-extra-tooltip.d.ts +33 -0
  41. package/core/chart-api/chart-extra-tooltip.js +209 -0
  42. package/core/chart-api/chart-extra-tooltip.js.map +1 -0
  43. package/core/chart-api/index.d.ts +75 -0
  44. package/core/chart-api/index.js +383 -0
  45. package/core/chart-api/index.js.map +1 -0
  46. package/core/chart-container.d.ts +20 -0
  47. package/core/chart-container.js +55 -0
  48. package/core/chart-container.js.map +1 -0
  49. package/core/chart-core.d.ts +7 -0
  50. package/core/chart-core.js +287 -0
  51. package/core/chart-core.js.map +1 -0
  52. package/core/components/core-application.d.ts +6 -0
  53. package/core/components/core-application.js +16 -0
  54. package/core/components/core-application.js.map +1 -0
  55. package/core/components/core-filters.d.ts +9 -0
  56. package/core/components/core-filters.js +22 -0
  57. package/core/components/core-filters.js.map +1 -0
  58. package/core/components/core-legend.d.ts +13 -0
  59. package/core/components/core-legend.js +27 -0
  60. package/core/components/core-legend.js.map +1 -0
  61. package/core/components/core-no-data.d.ts +6 -0
  62. package/core/components/core-no-data.js +48 -0
  63. package/core/components/core-no-data.js.map +1 -0
  64. package/core/components/core-slots.d.ts +7 -0
  65. package/core/components/core-slots.js +11 -0
  66. package/core/components/core-slots.js.map +1 -0
  67. package/core/components/core-tooltip.d.ts +7 -0
  68. package/core/components/core-tooltip.js +183 -0
  69. package/core/components/core-tooltip.js.map +1 -0
  70. package/core/components/core-vertical-axis-title.d.ts +5 -0
  71. package/core/components/core-vertical-axis-title.js +15 -0
  72. package/core/components/core-vertical-axis-title.js.map +1 -0
  73. package/core/formatters.d.ts +2 -0
  74. package/core/formatters.js +113 -0
  75. package/core/formatters.js.map +1 -0
  76. package/core/i18n-utils.d.ts +21 -0
  77. package/core/i18n-utils.js +18 -0
  78. package/core/i18n-utils.js.map +1 -0
  79. package/core/interfaces.d.ts +436 -0
  80. package/core/interfaces.js +4 -0
  81. package/core/interfaces.js.map +1 -0
  82. package/core/styles.css.js +25 -0
  83. package/core/styles.scoped.css +115 -0
  84. package/core/styles.selectors.js +26 -0
  85. package/core/test-classes/styles.css.js +33 -0
  86. package/core/test-classes/styles.scoped.css +34 -0
  87. package/core/test-classes/styles.selectors.js +34 -0
  88. package/core/utils.d.ts +45 -0
  89. package/core/utils.js +262 -0
  90. package/core/utils.js.map +1 -0
  91. package/index.d.ts +4 -0
  92. package/index.js +5 -0
  93. package/index.js.map +1 -0
  94. package/internal/api-docs/components/cartesian-chart.js +571 -0
  95. package/internal/api-docs/components/index.d.ts +3 -0
  96. package/internal/api-docs/components/index.js +4 -0
  97. package/internal/api-docs/components/interfaces.d.ts +81 -0
  98. package/internal/api-docs/components/pie-chart.js +430 -0
  99. package/internal/api-docs/test-utils-doc/dom.js +4 -0
  100. package/internal/api-docs/test-utils-doc/selectors.js +4 -0
  101. package/internal/base-component/get-data-attributes.d.ts +1 -0
  102. package/internal/base-component/get-data-attributes.js +12 -0
  103. package/internal/base-component/get-data-attributes.js.map +1 -0
  104. package/internal/base-component/use-base-component.d.ts +13 -0
  105. package/internal/base-component/use-base-component.js +18 -0
  106. package/internal/base-component/use-base-component.js.map +1 -0
  107. package/internal/base-component/use-telemetry.d.ts +2 -0
  108. package/internal/base-component/use-telemetry.js +8 -0
  109. package/internal/base-component/use-telemetry.js.map +1 -0
  110. package/internal/chart-styles.d.ts +88 -0
  111. package/internal/chart-styles.js +145 -0
  112. package/internal/chart-styles.js.map +1 -0
  113. package/internal/components/chart-legend/index.d.ts +14 -0
  114. package/internal/components/chart-legend/index.js +245 -0
  115. package/internal/components/chart-legend/index.js.map +1 -0
  116. package/internal/components/chart-legend/styles.css.js +22 -0
  117. package/internal/components/chart-legend/styles.scoped.css +233 -0
  118. package/internal/components/chart-legend/styles.selectors.js +23 -0
  119. package/internal/components/chart-legend/test-classes/styles.css.js +11 -0
  120. package/internal/components/chart-legend/test-classes/styles.scoped.css +12 -0
  121. package/internal/components/chart-legend/test-classes/styles.selectors.js +12 -0
  122. package/internal/components/chart-series-filter/index.d.ts +17 -0
  123. package/internal/components/chart-series-filter/index.js +14 -0
  124. package/internal/components/chart-series-filter/index.js.map +1 -0
  125. package/internal/components/interfaces.d.ts +17 -0
  126. package/internal/components/interfaces.js +4 -0
  127. package/internal/components/interfaces.js.map +1 -0
  128. package/internal/components/series-details/index.d.ts +23 -0
  129. package/internal/components/series-details/index.js +45 -0
  130. package/internal/components/series-details/index.js.map +1 -0
  131. package/internal/components/series-details/styles.css.js +22 -0
  132. package/internal/components/series-details/styles.scoped.css +150 -0
  133. package/internal/components/series-details/styles.selectors.js +23 -0
  134. package/internal/components/series-details/test-classes/styles.css.js +10 -0
  135. package/internal/components/series-details/test-classes/styles.scoped.css +11 -0
  136. package/internal/components/series-details/test-classes/styles.selectors.js +11 -0
  137. package/internal/components/series-marker/index.d.ts +8 -0
  138. package/internal/components/series-marker/index.js +45 -0
  139. package/internal/components/series-marker/index.js.map +1 -0
  140. package/internal/components/series-marker/interfaces.d.ts +1 -0
  141. package/internal/components/series-marker/interfaces.js +4 -0
  142. package/internal/components/series-marker/interfaces.js.map +1 -0
  143. package/internal/components/series-marker/render-marker.d.ts +3 -0
  144. package/internal/components/series-marker/render-marker.js +74 -0
  145. package/internal/components/series-marker/render-marker.js.map +1 -0
  146. package/internal/components/series-marker/styles.css.js +7 -0
  147. package/internal/components/series-marker/styles.scoped.css +55 -0
  148. package/internal/components/series-marker/styles.selectors.js +8 -0
  149. package/internal/environment.d.ts +4 -0
  150. package/internal/environment.js +5 -0
  151. package/internal/environment.json +7 -0
  152. package/internal/events/index.d.ts +23 -0
  153. package/internal/events/index.js +41 -0
  154. package/internal/events/index.js.map +1 -0
  155. package/internal/generated/styles/tokens.d.ts +756 -0
  156. package/internal/generated/styles/tokens.js +756 -0
  157. package/internal/generated/theming/index.cjs +12584 -0
  158. package/internal/generated/theming/index.cjs.d.ts +2399 -0
  159. package/internal/generated/theming/index.d.ts +2399 -0
  160. package/internal/generated/theming/index.js +12584 -0
  161. package/internal/manifest.json +3 -0
  162. package/internal/styles.css.js +6 -0
  163. package/internal/styles.scoped.css +13 -0
  164. package/internal/styles.selectors.js +7 -0
  165. package/internal/utils/apply-display-name.d.ts +1 -0
  166. package/internal/utils/apply-display-name.js +6 -0
  167. package/internal/utils/apply-display-name.js.map +1 -0
  168. package/internal/utils/async-store.d.ts +19 -0
  169. package/internal/utils/async-store.js +58 -0
  170. package/internal/utils/async-store.js.map +1 -0
  171. package/internal/utils/chart-series.d.ts +8 -0
  172. package/internal/utils/chart-series.js +11 -0
  173. package/internal/utils/chart-series.js.map +1 -0
  174. package/internal/utils/renderer-utils.d.ts +17 -0
  175. package/internal/utils/renderer-utils.js +95 -0
  176. package/internal/utils/renderer-utils.js.map +1 -0
  177. package/internal/utils/series-data.d.ts +2 -0
  178. package/internal/utils/series-data.js +8 -0
  179. package/internal/utils/series-data.js.map +1 -0
  180. package/internal/utils/test-i18n-provider.d.ts +8 -0
  181. package/internal/utils/test-i18n-provider.js +8 -0
  182. package/internal/utils/test-i18n-provider.js.map +1 -0
  183. package/internal/utils/use-previous.d.ts +4 -0
  184. package/internal/utils/use-previous.js +14 -0
  185. package/internal/utils/use-previous.js.map +1 -0
  186. package/internal/utils/utils.d.ts +16 -0
  187. package/internal/utils/utils.js +49 -0
  188. package/internal/utils/utils.js.map +1 -0
  189. package/internal-do-not-use/core-chart/index.d.ts +4 -0
  190. package/internal-do-not-use/core-chart/index.js +13 -0
  191. package/internal-do-not-use/core-chart/index.js.map +1 -0
  192. package/internal-do-not-use/core-legend/index.d.ts +2 -0
  193. package/internal-do-not-use/core-legend/index.js +11 -0
  194. package/internal-do-not-use/core-legend/index.js.map +1 -0
  195. package/package.json +106 -0
  196. package/pie-chart/chart-inner-area.d.ts +10 -0
  197. package/pie-chart/chart-inner-area.js +63 -0
  198. package/pie-chart/chart-inner-area.js.map +1 -0
  199. package/pie-chart/chart-pie-internal.d.ts +11 -0
  200. package/pie-chart/chart-pie-internal.js +103 -0
  201. package/pie-chart/chart-pie-internal.js.map +1 -0
  202. package/pie-chart/index.d.ts +5 -0
  203. package/pie-chart/index.js +48 -0
  204. package/pie-chart/index.js.map +1 -0
  205. package/pie-chart/interfaces.d.ts +101 -0
  206. package/pie-chart/interfaces.js +4 -0
  207. package/pie-chart/interfaces.js.map +1 -0
  208. package/pie-chart/test-classes/styles.css.js +8 -0
  209. package/pie-chart/test-classes/styles.scoped.css +9 -0
  210. package/pie-chart/test-classes/styles.selectors.js +9 -0
  211. package/test-utils/dom/cartesian-chart/index.d.ts +14 -0
  212. package/test-utils/dom/cartesian-chart/index.js +24 -0
  213. package/test-utils/dom/cartesian-chart/index.js.map +1 -0
  214. package/test-utils/dom/cartesian-chart/tooltip.d.ts +28 -0
  215. package/test-utils/dom/cartesian-chart/tooltip.js +48 -0
  216. package/test-utils/dom/cartesian-chart/tooltip.js.map +1 -0
  217. package/test-utils/dom/index.d.ts +46 -0
  218. package/test-utils/dom/index.js +35 -0
  219. package/test-utils/dom/index.js.map +1 -0
  220. package/test-utils/dom/internal/base.d.ts +93 -0
  221. package/test-utils/dom/internal/base.js +146 -0
  222. package/test-utils/dom/internal/base.js.map +1 -0
  223. package/test-utils/dom/internal/core.d.ts +14 -0
  224. package/test-utils/dom/internal/core.js +37 -0
  225. package/test-utils/dom/internal/core.js.map +1 -0
  226. package/test-utils/dom/pie-chart/index.d.ts +17 -0
  227. package/test-utils/dom/pie-chart/index.js +29 -0
  228. package/test-utils/dom/pie-chart/index.js.map +1 -0
  229. package/test-utils/selectors/cartesian-chart/index.d.ts +14 -0
  230. package/test-utils/selectors/cartesian-chart/index.js +24 -0
  231. package/test-utils/selectors/cartesian-chart/index.js.map +1 -0
  232. package/test-utils/selectors/cartesian-chart/tooltip.d.ts +28 -0
  233. package/test-utils/selectors/cartesian-chart/tooltip.js +48 -0
  234. package/test-utils/selectors/cartesian-chart/tooltip.js.map +1 -0
  235. package/test-utils/selectors/index.d.ts +46 -0
  236. package/test-utils/selectors/index.js +32 -0
  237. package/test-utils/selectors/index.js.map +1 -0
  238. package/test-utils/selectors/internal/base.d.ts +93 -0
  239. package/test-utils/selectors/internal/base.js +146 -0
  240. package/test-utils/selectors/internal/base.js.map +1 -0
  241. package/test-utils/selectors/internal/core.d.ts +14 -0
  242. package/test-utils/selectors/internal/core.js +37 -0
  243. package/test-utils/selectors/internal/core.js.map +1 -0
  244. package/test-utils/selectors/pie-chart/index.d.ts +17 -0
  245. package/test-utils/selectors/pie-chart/index.js +29 -0
  246. package/test-utils/selectors/pie-chart/index.js.map +1 -0
@@ -0,0 +1,33 @@
1
+
2
+ import './styles.scoped.css';
3
+ export default {
4
+ "root": "awsui_root_m8vem_lm70d_5",
5
+ "fallback": "awsui_fallback_m8vem_lm70d_6",
6
+ "no-data": "awsui_no-data_m8vem_lm70d_7",
7
+ "legend-item-warning": "awsui_legend-item-warning_m8vem_lm70d_8",
8
+ "chart-plot": "awsui_chart-plot_m8vem_lm70d_9",
9
+ "chart-plot-wrapper": "awsui_chart-plot-wrapper_m8vem_lm70d_10",
10
+ "chart-filters": "awsui_chart-filters_m8vem_lm70d_11",
11
+ "chart-filters-series": "awsui_chart-filters-series_m8vem_lm70d_12",
12
+ "chart-filters-additional": "awsui_chart-filters-additional_m8vem_lm70d_13",
13
+ "chart-header": "awsui_chart-header_m8vem_lm70d_14",
14
+ "chart-footer": "awsui_chart-footer_m8vem_lm70d_15",
15
+ "chart-navigator": "awsui_chart-navigator_m8vem_lm70d_16",
16
+ "axis-x": "awsui_axis-x_m8vem_lm70d_17",
17
+ "axis-x-title": "awsui_axis-x-title_m8vem_lm70d_18",
18
+ "axis-y": "awsui_axis-y_m8vem_lm70d_19",
19
+ "axis-y-title": "awsui_axis-y-title_m8vem_lm70d_20",
20
+ "axis-vertical": "awsui_axis-vertical_m8vem_lm70d_21",
21
+ "axis-vertical-title": "awsui_axis-vertical-title_m8vem_lm70d_22",
22
+ "axis-horizontal": "awsui_axis-horizontal_m8vem_lm70d_23",
23
+ "no-data-empty": "awsui_no-data-empty_m8vem_lm70d_24",
24
+ "no-data-no-match": "awsui_no-data-no-match_m8vem_lm70d_25",
25
+ "no-data-loading": "awsui_no-data-loading_m8vem_lm70d_26",
26
+ "no-data-error": "awsui_no-data-error_m8vem_lm70d_27",
27
+ "no-data-retry": "awsui_no-data-retry_m8vem_lm70d_28",
28
+ "emphasized-baseline": "awsui_emphasized-baseline_m8vem_lm70d_29",
29
+ "application": "awsui_application_m8vem_lm70d_30",
30
+ "highlight-marker": "awsui_highlight-marker_m8vem_lm70d_31",
31
+ "highlight-marker-selected": "awsui_highlight-marker-selected_m8vem_lm70d_32"
32
+ };
33
+
@@ -0,0 +1,34 @@
1
+ /*
2
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ .awsui_root_m8vem_lm70d_5:not(#\9),
6
+ .awsui_fallback_m8vem_lm70d_6:not(#\9),
7
+ .awsui_no-data_m8vem_lm70d_7:not(#\9),
8
+ .awsui_legend-item-warning_m8vem_lm70d_8:not(#\9),
9
+ .awsui_chart-plot_m8vem_lm70d_9:not(#\9),
10
+ .awsui_chart-plot-wrapper_m8vem_lm70d_10:not(#\9),
11
+ .awsui_chart-filters_m8vem_lm70d_11:not(#\9),
12
+ .awsui_chart-filters-series_m8vem_lm70d_12:not(#\9),
13
+ .awsui_chart-filters-additional_m8vem_lm70d_13:not(#\9),
14
+ .awsui_chart-header_m8vem_lm70d_14:not(#\9),
15
+ .awsui_chart-footer_m8vem_lm70d_15:not(#\9),
16
+ .awsui_chart-navigator_m8vem_lm70d_16:not(#\9),
17
+ .awsui_axis-x_m8vem_lm70d_17:not(#\9),
18
+ .awsui_axis-x-title_m8vem_lm70d_18:not(#\9),
19
+ .awsui_axis-y_m8vem_lm70d_19:not(#\9),
20
+ .awsui_axis-y-title_m8vem_lm70d_20:not(#\9),
21
+ .awsui_axis-vertical_m8vem_lm70d_21:not(#\9),
22
+ .awsui_axis-vertical-title_m8vem_lm70d_22:not(#\9),
23
+ .awsui_axis-horizontal_m8vem_lm70d_23:not(#\9),
24
+ .awsui_no-data-empty_m8vem_lm70d_24:not(#\9),
25
+ .awsui_no-data-no-match_m8vem_lm70d_25:not(#\9),
26
+ .awsui_no-data-loading_m8vem_lm70d_26:not(#\9),
27
+ .awsui_no-data-error_m8vem_lm70d_27:not(#\9),
28
+ .awsui_no-data-retry_m8vem_lm70d_28:not(#\9),
29
+ .awsui_emphasized-baseline_m8vem_lm70d_29:not(#\9),
30
+ .awsui_application_m8vem_lm70d_30:not(#\9),
31
+ .awsui_highlight-marker_m8vem_lm70d_31:not(#\9),
32
+ .awsui_highlight-marker-selected_m8vem_lm70d_32:not(#\9) {
33
+ /* used in test-utils */
34
+ }
@@ -0,0 +1,34 @@
1
+
2
+ // es-module interop with Babel and Typescript
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ module.exports.default = {
5
+ "root": "awsui_root_m8vem_lm70d_5",
6
+ "fallback": "awsui_fallback_m8vem_lm70d_6",
7
+ "no-data": "awsui_no-data_m8vem_lm70d_7",
8
+ "legend-item-warning": "awsui_legend-item-warning_m8vem_lm70d_8",
9
+ "chart-plot": "awsui_chart-plot_m8vem_lm70d_9",
10
+ "chart-plot-wrapper": "awsui_chart-plot-wrapper_m8vem_lm70d_10",
11
+ "chart-filters": "awsui_chart-filters_m8vem_lm70d_11",
12
+ "chart-filters-series": "awsui_chart-filters-series_m8vem_lm70d_12",
13
+ "chart-filters-additional": "awsui_chart-filters-additional_m8vem_lm70d_13",
14
+ "chart-header": "awsui_chart-header_m8vem_lm70d_14",
15
+ "chart-footer": "awsui_chart-footer_m8vem_lm70d_15",
16
+ "chart-navigator": "awsui_chart-navigator_m8vem_lm70d_16",
17
+ "axis-x": "awsui_axis-x_m8vem_lm70d_17",
18
+ "axis-x-title": "awsui_axis-x-title_m8vem_lm70d_18",
19
+ "axis-y": "awsui_axis-y_m8vem_lm70d_19",
20
+ "axis-y-title": "awsui_axis-y-title_m8vem_lm70d_20",
21
+ "axis-vertical": "awsui_axis-vertical_m8vem_lm70d_21",
22
+ "axis-vertical-title": "awsui_axis-vertical-title_m8vem_lm70d_22",
23
+ "axis-horizontal": "awsui_axis-horizontal_m8vem_lm70d_23",
24
+ "no-data-empty": "awsui_no-data-empty_m8vem_lm70d_24",
25
+ "no-data-no-match": "awsui_no-data-no-match_m8vem_lm70d_25",
26
+ "no-data-loading": "awsui_no-data-loading_m8vem_lm70d_26",
27
+ "no-data-error": "awsui_no-data-error_m8vem_lm70d_27",
28
+ "no-data-retry": "awsui_no-data-retry_m8vem_lm70d_28",
29
+ "emphasized-baseline": "awsui_emphasized-baseline_m8vem_lm70d_29",
30
+ "application": "awsui_application_m8vem_lm70d_30",
31
+ "highlight-marker": "awsui_highlight-marker_m8vem_lm70d_31",
32
+ "highlight-marker-selected": "awsui_highlight-marker-selected_m8vem_lm70d_32"
33
+ };
34
+
@@ -0,0 +1,45 @@
1
+ import type Highcharts from "highcharts";
2
+ import { ChartSeriesMarkerType } from "../internal/components/series-marker";
3
+ import { ChartLabels } from "./i18n-utils";
4
+ import { Rect } from "./interfaces";
5
+ export interface LegendItemSpec {
6
+ id: string;
7
+ name: string;
8
+ markerType: ChartSeriesMarkerType;
9
+ color: string;
10
+ visible: boolean;
11
+ }
12
+ export declare function getSeriesId(series: Highcharts.Series): string;
13
+ export declare function getPointId(point: Highcharts.Point): string;
14
+ export declare function getOptionsId(options: {
15
+ id?: string;
16
+ name?: string;
17
+ }): string;
18
+ export declare function isSeriesStacked(series: Highcharts.Series): boolean;
19
+ interface ThresholdOptions<T extends "x-threshold" | "y-threshold"> {
20
+ custom: {
21
+ awsui: {
22
+ type: T;
23
+ threshold: number;
24
+ };
25
+ };
26
+ }
27
+ export declare function createThresholdMetadata<T extends "x-threshold" | "y-threshold">(type: T, value: number): ThresholdOptions<T>;
28
+ export declare function isXThreshold(s: Highcharts.Series): s is Highcharts.Series & {
29
+ options: ThresholdOptions<"x-threshold">;
30
+ };
31
+ export declare function isYThreshold(s: Highcharts.Series): s is Highcharts.Series & {
32
+ options: ThresholdOptions<"y-threshold">;
33
+ };
34
+ export declare function isPointVisible(point: Highcharts.Point): boolean;
35
+ export declare function getSeriesMarkerType(series?: Highcharts.Series): ChartSeriesMarkerType;
36
+ export declare function getSeriesColor(series?: Highcharts.Series): string;
37
+ export declare function getPointColor(point?: Highcharts.Point): string;
38
+ export declare function getChartLegendItems(chart: Highcharts.Chart): readonly LegendItemSpec[];
39
+ export declare function hasVisibleLegendItems(options: Highcharts.Options): boolean;
40
+ export declare function getPointRect(point: Highcharts.Point): Rect;
41
+ export declare function getGroupRect(points: readonly Highcharts.Point[]): Rect;
42
+ export declare function getChartAccessibleDescription(chart: Highcharts.Chart): string;
43
+ export declare function getPointAccessibleDescription(point: Highcharts.Point, labels: ChartLabels): string;
44
+ export declare function getGroupAccessibleDescription(group: readonly Highcharts.Point[]): string;
45
+ export {};
package/core/utils.js ADDED
@@ -0,0 +1,262 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { getChartSeries } from "../internal/utils/chart-series";
4
+ import { getFormatter } from "./formatters";
5
+ // The below functions extract unique identifier from series, point, or options. The identifier can be item's ID or name.
6
+ // We expect that items requiring referencing (e.g. in order to control their visibility) have the unique identifier defined.
7
+ // Otherwise, we return a randomized id that is to ensure no accidental matches.
8
+ export function getSeriesId(series) {
9
+ return getOptionsId(series.options);
10
+ }
11
+ export function getPointId(point) {
12
+ return getOptionsId(point.options);
13
+ }
14
+ export function getOptionsId(options) {
15
+ var _a, _b;
16
+ return (_b = (_a = options.id) !== null && _a !== void 0 ? _a : options.name) !== null && _b !== void 0 ? _b : noIdPlaceholder();
17
+ }
18
+ function noIdPlaceholder() {
19
+ const rand = (Math.random() * 1000000).toFixed(0).padStart(6, "0");
20
+ return "awsui-no-id-placeholder-" + rand;
21
+ }
22
+ // There are more possible values that series.stacking can take, but we only explicitly support "normal".
23
+ export function isSeriesStacked(series) {
24
+ return series.options.stacking === "normal";
25
+ }
26
+ export function createThresholdMetadata(type, value) {
27
+ return { custom: { awsui: { type, threshold: value } } };
28
+ }
29
+ export function isXThreshold(s) {
30
+ var _a;
31
+ return typeof s.options.custom === "object" && ((_a = s.options.custom.awsui) === null || _a === void 0 ? void 0 : _a.type) === "x-threshold";
32
+ }
33
+ export function isYThreshold(s) {
34
+ var _a;
35
+ return typeof s.options.custom === "object" && ((_a = s.options.custom.awsui) === null || _a === void 0 ? void 0 : _a.type) === "y-threshold";
36
+ }
37
+ // We check point.series explicitly because Highcharts can destroy point objects, replacing the
38
+ // contents with { destroyed: true }, violating the point's TS contract.
39
+ // See: https://github.com/highcharts/highcharts/issues/23175.
40
+ export function isPointVisible(point) {
41
+ return point.visible && point.series && point.series.visible;
42
+ }
43
+ export function getSeriesMarkerType(series) {
44
+ if (!series) {
45
+ return "large-square";
46
+ }
47
+ const seriesSymbol = "symbol" in series && typeof series.symbol === "string" ? series.symbol : "circle";
48
+ // In Highcharts, dashStyle supports different types of dashes: https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-dashstyle-all/
49
+ // Return a dashed legend symbol for all of these dashes, excluding the default "Solid" option
50
+ if ("dashStyle" in series.options && series.options.dashStyle && series.options.dashStyle !== "Solid") {
51
+ return "dashed";
52
+ }
53
+ switch (series.type) {
54
+ case "area":
55
+ case "areaspline":
56
+ return "hollow-square";
57
+ case "line":
58
+ case "spline":
59
+ return "line";
60
+ case "scatter":
61
+ switch (seriesSymbol) {
62
+ case "square":
63
+ return "square";
64
+ case "diamond":
65
+ return "diamond";
66
+ case "triangle":
67
+ return "triangle";
68
+ case "triangle-down":
69
+ return "triangle-down";
70
+ case "circle":
71
+ default:
72
+ return "circle";
73
+ }
74
+ case "column":
75
+ case "pie":
76
+ return "large-square";
77
+ case "errorbar":
78
+ default:
79
+ return "large-square";
80
+ }
81
+ }
82
+ // Highcharts supports color objects to represent gradients and more, but we only support string
83
+ // colors in our markers. In case a non-string color is defined, we use black color as as fallback.
84
+ export function getSeriesColor(series) {
85
+ return typeof (series === null || series === void 0 ? void 0 : series.color) === "string" ? series.color : "black";
86
+ }
87
+ export function getPointColor(point) {
88
+ return typeof (point === null || point === void 0 ? void 0 : point.color) === "string" ? point.color : "black";
89
+ }
90
+ // The custom legend implementation does not rely on the Highcharts legend. When Highcharts legend is disabled,
91
+ // the chart object does not include information on legend items. Instead, we collect series and pie segments
92
+ // using this custom function, respecting Highcharts' showInLegend flag (defined for series only).
93
+ // There exists a Highcharts APIs to access legend items, but it is unfortunately not available, when
94
+ // Highcharts legend is disabled. Instead, we use this custom method to collect legend items from the chart.
95
+ export function getChartLegendItems(chart) {
96
+ const legendItems = [];
97
+ const addSeriesItem = (series) => {
98
+ // The pie series is not shown in the legend. Instead, we show pie segments.
99
+ if (series.type === "pie") {
100
+ return;
101
+ }
102
+ // We only support errorbar series that are linked to other series. Those are not represented separately
103
+ // in the legend, but can be controlled from the outside, using controllable items visibility API.
104
+ if (series.type === "errorbar") {
105
+ return;
106
+ }
107
+ // We respect Highcharts showInLegend option to allow hiding certain series from the legend.
108
+ // The same is not supported for pie chart segments.
109
+ if (series.options.showInLegend !== false) {
110
+ legendItems.push({
111
+ id: getSeriesId(series),
112
+ name: series.name,
113
+ markerType: getSeriesMarkerType(series),
114
+ color: getSeriesColor(series),
115
+ visible: series.visible,
116
+ });
117
+ }
118
+ };
119
+ const addPointItem = (point) => {
120
+ if (point.series.type === "pie") {
121
+ legendItems.push({
122
+ id: getPointId(point),
123
+ name: point.name,
124
+ markerType: getSeriesMarkerType(point.series),
125
+ color: getPointColor(point),
126
+ visible: point.visible,
127
+ });
128
+ }
129
+ };
130
+ for (const s of getChartSeries(chart.series)) {
131
+ addSeriesItem(s);
132
+ s.data.forEach(addPointItem);
133
+ }
134
+ return legendItems;
135
+ }
136
+ export function hasVisibleLegendItems(options) {
137
+ var _a;
138
+ return !!((_a = options.series) === null || _a === void 0 ? void 0 : _a.some((series) => {
139
+ // The pie series is not shown in the legend, but their segments are always shown.
140
+ if (series.type === "pie") {
141
+ return Array.isArray(series.data) && series.data.length > 0;
142
+ }
143
+ // We only support errorbar series that are linked to other series. Those are not represented separately
144
+ // in the legend, but can be controlled from the outside, using controllable items visibility API.
145
+ if (series.type === "errorbar") {
146
+ return false;
147
+ }
148
+ return series.showInLegend !== false;
149
+ }));
150
+ }
151
+ // This function returns coordinates of a rectangle, including the target point.
152
+ // There are differences in how the rectangle is computed, but in all cases it is supposed to
153
+ // enclose the point's visual representation in the chart, with no extra offsets.
154
+ export function getPointRect(point) {
155
+ switch (point.series.type) {
156
+ case "column":
157
+ return getColumnPointRect(point);
158
+ case "errorbar":
159
+ return getErrorBarPointRect(point);
160
+ default:
161
+ return getDefaultPointRect(point);
162
+ }
163
+ }
164
+ // The group rect is only used for cartesian charts. It returns coordinates of a rectangle,
165
+ // which includes all given points, but also stretched vertically or horizontally (in inverted charts)
166
+ // to the entire chart's height or width.
167
+ export function getGroupRect(points) {
168
+ if (points.length === 0) {
169
+ return { x: 0, y: 0, width: 0, height: 0 };
170
+ }
171
+ const chart = points[0].series.chart;
172
+ const rects = points.map(getPointRect);
173
+ const [first, ...rest] = rects;
174
+ let minX = first.x, minY = first.y, maxX = first.x + first.width, maxY = first.y + first.height;
175
+ for (const r of rest) {
176
+ minX = Math.min(minX, r.x);
177
+ minY = Math.min(minY, r.y);
178
+ maxX = Math.max(maxX, r.x + r.width);
179
+ maxY = Math.max(maxY, r.y + r.height);
180
+ }
181
+ return chart.inverted
182
+ ? { x: chart.plotLeft, y: minY, width: chart.plotWidth, height: maxY - minY }
183
+ : { x: minX, y: chart.plotTop, width: maxX - minX, height: chart.plotHeight };
184
+ }
185
+ export function getChartAccessibleDescription(chart) {
186
+ var _a, _b, _c;
187
+ return (_c = (_b = (_a = chart.options.lang) === null || _a === void 0 ? void 0 : _a.accessibility) === null || _b === void 0 ? void 0 : _b.chartContainerLabel) !== null && _c !== void 0 ? _c : "";
188
+ }
189
+ export function getPointAccessibleDescription(point, labels) {
190
+ if (point.series.xAxis && point.series.yAxis) {
191
+ const formattedX = getFormatter(point.series.xAxis)(point.x);
192
+ const formattedY = getFormatter(point.series.yAxis)(point.y);
193
+ return `${formattedX} ${formattedY}, ${point.series.name}`;
194
+ }
195
+ else if (point.series.type === "pie") {
196
+ const segmentLabel = labels.chartSegmentLabel ? `${labels.chartSegmentLabel} ` : "";
197
+ return `${segmentLabel}${point.name}, ${point.y}. ${point.series.name}`;
198
+ }
199
+ else {
200
+ return "";
201
+ }
202
+ }
203
+ export function getGroupAccessibleDescription(group) {
204
+ const firstPoint = group[0];
205
+ return getFormatter(firstPoint.series.xAxis)(firstPoint.x);
206
+ }
207
+ // The area-, line-, or scatter series markers are rendered as single graphic elements,
208
+ // and we can use their respective b-boxes to compute rects.
209
+ function getDefaultPointRect(point) {
210
+ const chart = point.series.chart;
211
+ if (point.graphic) {
212
+ const box = point.graphic.getBBox();
213
+ return getChartRect(box, chart, false);
214
+ }
215
+ return getPointRectFromCoordinates(point);
216
+ }
217
+ // The column series graphic elements are rectangles, and they are inverted if the chart is inverted,
218
+ // so that rect's width becomes height and vice-versa.
219
+ function getColumnPointRect(point) {
220
+ const chart = point.series.chart;
221
+ if (point.graphic) {
222
+ return getChartRect(point.graphic.getBBox(), chart, true);
223
+ }
224
+ return getPointRectFromCoordinates(point);
225
+ }
226
+ // The errorbar series point rect cannot be computed from the respective graphic element (it gives wrong position).
227
+ // Instead, we have to rely on the internal "whiskers" element b-box, which can be inverted, too.
228
+ function getErrorBarPointRect(point) {
229
+ const chart = point.series.chart;
230
+ if ("whiskers" in point) {
231
+ return getChartRect(point.whiskers.getBBox(), chart, true);
232
+ }
233
+ return getPointRectFromCoordinates(point);
234
+ }
235
+ // The point graphic is not present in large charts to optimize performance.
236
+ // In that case we compute point rects from their coordinates. We also assume the point
237
+ // size is small, and thereby give it 0 width and height, which is alright as there is a
238
+ // small offset that we use for focus outline anyways.
239
+ // See: https://www.highcharts.com/blog/news/175-highcharts-performance-boost/
240
+ function getPointRectFromCoordinates(point) {
241
+ var _a, _b;
242
+ const chart = point.series.chart;
243
+ const plotX = (_a = point.plotX) !== null && _a !== void 0 ? _a : 0;
244
+ const plotY = (_b = point.plotY) !== null && _b !== void 0 ? _b : 0;
245
+ return getChartRect({ x: plotX, y: plotY, width: 0, height: 0 }, chart, true);
246
+ }
247
+ function getChartRect(rect, chart, canBeInverted) {
248
+ return canBeInverted && chart.inverted
249
+ ? {
250
+ x: chart.plotWidth + chart.plotLeft - (rect.y + rect.height),
251
+ y: chart.plotHeight + chart.plotTop - (rect.x + rect.width),
252
+ width: rect.height,
253
+ height: rect.width,
254
+ }
255
+ : {
256
+ x: chart.plotLeft + rect.x,
257
+ y: chart.plotTop + rect.y,
258
+ width: rect.width,
259
+ height: rect.height,
260
+ };
261
+ }
262
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/core/utils.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAKtC,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAY5C,yHAAyH;AACzH,6HAA6H;AAC7H,gFAAgF;AAChF,MAAM,UAAU,WAAW,CAAC,MAAyB;IACnD,OAAO,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AACtC,CAAC;AACD,MAAM,UAAU,UAAU,CAAC,KAAuB;IAChD,OAAO,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AACrC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C9E,SAAS,2BAA2B,CAAC,KAAuB;;IAC1D,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;IACjC,MAAM,KAAK,GAAG,MAAA,KAAK,CAAC,KAAK,mCAAI,CAAC,CAAC;IAC/B,MAAM,KAAK,GAAG,MAAA,KAAK,CAAC,KAAK,mCAAI,CAAC,CAAC;IAC/B,OAAO,YAAY,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;AAChF,CAAC;AAED,SAAS,YAAY,CAAC,IAAU,EAAE,KAAuB,EAAE,aAAsB;IAC/E,OAAO,aAAa,IAAI,KAAK,CAAC,QAAQ;QACpC,CAAC,CAAC;YACE,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,QAAQ,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;YAC5D,CAAC,EAAE,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;YAC3D,KAAK,EAAE,IAAI,CAAC,MAAM;YAClB,MAAM,EAAE,IAAI,CAAC,KAAK;SACnB;QACH,CAAC,CAAC;YACE,CAAC,EAAE,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;YAC1B,CAAC,EAAE,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;YACzB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC;AACR,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 { ChartSeriesMarkerType } from \"../internal/components/series-marker\";\nimport { getChartSeries } from \"../internal/utils/chart-series\";\nimport { getFormatter } from \"./formatters\";\nimport { ChartLabels } from \"./i18n-utils\";\nimport { Rect } from \"./interfaces\";\n\nexport interface LegendItemSpec {\n id: string;\n name: string;\n markerType: ChartSeriesMarkerType;\n color: string;\n visible: boolean;\n}\n\n// The below functions extract unique identifier from series, point, or options. The identifier can be item's ID or name.\n// We expect that items requiring referencing (e.g. in order to control their visibility) have the unique identifier defined.\n// Otherwise, we return a randomized id that is to ensure no accidental matches.\nexport function getSeriesId(series: Highcharts.Series): string {\n return getOptionsId(series.options);\n}\nexport function getPointId(point: Highcharts.Point): string {\n return getOptionsId(point.options);\n}\nexport function getOptionsId(options: { id?: string; name?: string }): string {\n return options.id ?? options.name ?? noIdPlaceholder();\n}\nfunction noIdPlaceholder(): string {\n const rand = (Math.random() * 1_000_000).toFixed(0).padStart(6, \"0\");\n return \"awsui-no-id-placeholder-\" + rand;\n}\n\n// There are more possible values that series.stacking can take, but we only explicitly support \"normal\".\nexport function isSeriesStacked(series: Highcharts.Series) {\n return (series.options as any).stacking === \"normal\";\n}\n\n// The threshold series are custom series, implemented as a combination of line series, and plot lines.\n// As Highcharts does not support custom series declaration, we annotate threshold series by using the\n// series.custom property. This is then used in our utilities to recognize threshold series, and retrieve\n// the associated threshold value.\ninterface ThresholdOptions<T extends \"x-threshold\" | \"y-threshold\"> {\n custom: {\n awsui: {\n type: T;\n threshold: number;\n };\n };\n}\nexport function createThresholdMetadata<T extends \"x-threshold\" | \"y-threshold\">(\n type: T,\n value: number,\n): ThresholdOptions<T> {\n return { custom: { awsui: { type, threshold: value } } };\n}\nexport function isXThreshold(\n s: Highcharts.Series,\n): s is Highcharts.Series & { options: ThresholdOptions<\"x-threshold\"> } {\n return typeof s.options.custom === \"object\" && s.options.custom.awsui?.type === \"x-threshold\";\n}\nexport function isYThreshold(\n s: Highcharts.Series,\n): s is Highcharts.Series & { options: ThresholdOptions<\"y-threshold\"> } {\n return typeof s.options.custom === \"object\" && s.options.custom.awsui?.type === \"y-threshold\";\n}\n\n// We check point.series explicitly because Highcharts can destroy point objects, replacing the\n// contents with { destroyed: true }, violating the point's TS contract.\n// See: https://github.com/highcharts/highcharts/issues/23175.\nexport function isPointVisible(point: Highcharts.Point) {\n return point.visible && point.series && point.series.visible;\n}\n\nexport function getSeriesMarkerType(series?: Highcharts.Series): ChartSeriesMarkerType {\n if (!series) {\n return \"large-square\";\n }\n const seriesSymbol = \"symbol\" in series && typeof series.symbol === \"string\" ? series.symbol : \"circle\";\n // In Highcharts, dashStyle supports different types of dashes: https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-dashstyle-all/\n // Return a dashed legend symbol for all of these dashes, excluding the default \"Solid\" option\n if (\"dashStyle\" in series.options && series.options.dashStyle && series.options.dashStyle !== \"Solid\") {\n return \"dashed\";\n }\n switch (series.type) {\n case \"area\":\n case \"areaspline\":\n return \"hollow-square\";\n case \"line\":\n case \"spline\":\n return \"line\";\n case \"scatter\":\n switch (seriesSymbol) {\n case \"square\":\n return \"square\";\n case \"diamond\":\n return \"diamond\";\n case \"triangle\":\n return \"triangle\";\n case \"triangle-down\":\n return \"triangle-down\";\n case \"circle\":\n default:\n return \"circle\";\n }\n case \"column\":\n case \"pie\":\n return \"large-square\";\n case \"errorbar\":\n default:\n return \"large-square\";\n }\n}\n\n// Highcharts supports color objects to represent gradients and more, but we only support string\n// colors in our markers. In case a non-string color is defined, we use black color as as fallback.\nexport function getSeriesColor(series?: Highcharts.Series): string {\n return typeof series?.color === \"string\" ? series.color : \"black\";\n}\nexport function getPointColor(point?: Highcharts.Point): string {\n return typeof point?.color === \"string\" ? point.color : \"black\";\n}\n\n// The custom legend implementation does not rely on the Highcharts legend. When Highcharts legend is disabled,\n// the chart object does not include information on legend items. Instead, we collect series and pie segments\n// using this custom function, respecting Highcharts' showInLegend flag (defined for series only).\n\n// There exists a Highcharts APIs to access legend items, but it is unfortunately not available, when\n// Highcharts legend is disabled. Instead, we use this custom method to collect legend items from the chart.\nexport function getChartLegendItems(chart: Highcharts.Chart): readonly LegendItemSpec[] {\n const legendItems: LegendItemSpec[] = [];\n const addSeriesItem = (series: Highcharts.Series) => {\n // The pie series is not shown in the legend. Instead, we show pie segments.\n if (series.type === \"pie\") {\n return;\n }\n // We only support errorbar series that are linked to other series. Those are not represented separately\n // in the legend, but can be controlled from the outside, using controllable items visibility API.\n if (series.type === \"errorbar\") {\n return;\n }\n // We respect Highcharts showInLegend option to allow hiding certain series from the legend.\n // The same is not supported for pie chart segments.\n if (series.options.showInLegend !== false) {\n legendItems.push({\n id: getSeriesId(series),\n name: series.name,\n markerType: getSeriesMarkerType(series),\n color: getSeriesColor(series),\n visible: series.visible,\n });\n }\n };\n const addPointItem = (point: Highcharts.Point) => {\n if (point.series.type === \"pie\") {\n legendItems.push({\n id: getPointId(point),\n name: point.name,\n markerType: getSeriesMarkerType(point.series),\n color: getPointColor(point),\n visible: point.visible,\n });\n }\n };\n for (const s of getChartSeries(chart.series)) {\n addSeriesItem(s);\n s.data.forEach(addPointItem);\n }\n return legendItems;\n}\n\nexport function hasVisibleLegendItems(options: Highcharts.Options) {\n return !!options.series?.some((series) => {\n // The pie series is not shown in the legend, but their segments are always shown.\n if (series.type === \"pie\") {\n return Array.isArray(series.data) && series.data.length > 0;\n }\n // We only support errorbar series that are linked to other series. Those are not represented separately\n // in the legend, but can be controlled from the outside, using controllable items visibility API.\n if (series.type === \"errorbar\") {\n return false;\n }\n return series.showInLegend !== false;\n });\n}\n\n// This function returns coordinates of a rectangle, including the target point.\n// There are differences in how the rectangle is computed, but in all cases it is supposed to\n// enclose the point's visual representation in the chart, with no extra offsets.\nexport function getPointRect(point: Highcharts.Point): Rect {\n switch (point.series.type) {\n case \"column\":\n return getColumnPointRect(point);\n case \"errorbar\":\n return getErrorBarPointRect(point);\n default:\n return getDefaultPointRect(point);\n }\n}\n\n// The group rect is only used for cartesian charts. It returns coordinates of a rectangle,\n// which includes all given points, but also stretched vertically or horizontally (in inverted charts)\n// to the entire chart's height or width.\nexport function getGroupRect(points: readonly Highcharts.Point[]): Rect {\n if (points.length === 0) {\n return { x: 0, y: 0, width: 0, height: 0 };\n }\n const chart = points[0].series.chart;\n const rects = points.map(getPointRect);\n const [first, ...rest] = rects;\n let minX = first.x,\n minY = first.y,\n maxX = first.x + first.width,\n maxY = first.y + first.height;\n for (const r of rest) {\n minX = Math.min(minX, r.x);\n minY = Math.min(minY, r.y);\n maxX = Math.max(maxX, r.x + r.width);\n maxY = Math.max(maxY, r.y + r.height);\n }\n return chart.inverted\n ? { x: chart.plotLeft, y: minY, width: chart.plotWidth, height: maxY - minY }\n : { x: minX, y: chart.plotTop, width: maxX - minX, height: chart.plotHeight };\n}\n\nexport function getChartAccessibleDescription(chart: Highcharts.Chart) {\n return chart.options.lang?.accessibility?.chartContainerLabel ?? \"\";\n}\n\nexport function getPointAccessibleDescription(point: Highcharts.Point, labels: ChartLabels) {\n if (point.series.xAxis && point.series.yAxis) {\n const formattedX = getFormatter(point.series.xAxis)(point.x);\n const formattedY = getFormatter(point.series.yAxis)(point.y);\n return `${formattedX} ${formattedY}, ${point.series.name}`;\n } else if (point.series.type === \"pie\") {\n const segmentLabel = labels.chartSegmentLabel ? `${labels.chartSegmentLabel} ` : \"\";\n return `${segmentLabel}${point.name}, ${point.y}. ${point.series.name}`;\n } else {\n return \"\";\n }\n}\n\nexport function getGroupAccessibleDescription(group: readonly Highcharts.Point[]) {\n const firstPoint = group[0];\n return getFormatter(firstPoint.series.xAxis)(firstPoint.x);\n}\n\n// The area-, line-, or scatter series markers are rendered as single graphic elements,\n// and we can use their respective b-boxes to compute rects.\nfunction getDefaultPointRect(point: Highcharts.Point): Rect {\n const chart = point.series.chart;\n if (point.graphic) {\n const box = point.graphic.getBBox();\n return getChartRect(box, chart, false);\n }\n return getPointRectFromCoordinates(point);\n}\n\n// The column series graphic elements are rectangles, and they are inverted if the chart is inverted,\n// so that rect's width becomes height and vice-versa.\nfunction getColumnPointRect(point: Highcharts.Point): Rect {\n const chart = point.series.chart;\n if (point.graphic) {\n return getChartRect(point.graphic.getBBox(), chart, true);\n }\n return getPointRectFromCoordinates(point);\n}\n\n// The errorbar series point rect cannot be computed from the respective graphic element (it gives wrong position).\n// Instead, we have to rely on the internal \"whiskers\" element b-box, which can be inverted, too.\nfunction getErrorBarPointRect(point: Highcharts.Point): Rect {\n const chart = point.series.chart;\n if (\"whiskers\" in point) {\n return getChartRect((point.whiskers as Highcharts.SVGElement).getBBox(), chart, true);\n }\n return getPointRectFromCoordinates(point);\n}\n\n// The point graphic is not present in large charts to optimize performance.\n// In that case we compute point rects from their coordinates. We also assume the point\n// size is small, and thereby give it 0 width and height, which is alright as there is a\n// small offset that we use for focus outline anyways.\n// See: https://www.highcharts.com/blog/news/175-highcharts-performance-boost/\nfunction getPointRectFromCoordinates(point: Highcharts.Point) {\n const chart = point.series.chart;\n const plotX = point.plotX ?? 0;\n const plotY = point.plotY ?? 0;\n return getChartRect({ x: plotX, y: plotY, width: 0, height: 0 }, chart, true);\n}\n\nfunction getChartRect(rect: Rect, chart: Highcharts.Chart, canBeInverted: boolean): Rect {\n return canBeInverted && chart.inverted\n ? {\n x: chart.plotWidth + chart.plotLeft - (rect.y + rect.height),\n y: chart.plotHeight + chart.plotTop - (rect.x + rect.width),\n width: rect.height,\n height: rect.width,\n }\n : {\n x: chart.plotLeft + rect.x,\n y: chart.plotTop + rect.y,\n width: rect.width,\n height: rect.height,\n };\n}\n"]}
package/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export { default as CartesianChart } from "./cartesian-chart";
2
+ export type { CartesianChartProps } from "./cartesian-chart";
3
+ export { default as PieChart } from "./pie-chart";
4
+ export type { PieChartProps } from "./pie-chart";
package/index.js ADDED
@@ -0,0 +1,5 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ export { default as CartesianChart } from "./cartesian-chart";
4
+ export { default as PieChart } from "./pie-chart";
5
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAE9D,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,aAAa,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nexport { default as CartesianChart } from \"./cartesian-chart\";\nexport type { CartesianChartProps } from \"./cartesian-chart\";\nexport { default as PieChart } from \"./pie-chart\";\nexport type { PieChartProps } from \"./pie-chart\";\n"]}