@watermarkinsights/ripple 3.26.1-2 → 3.26.1

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 (276) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/{chartFunctions-d746b939.js → chartFunctions-b7452189.js} +596 -596
  3. package/dist/cjs/{functions-68f637b4.js → functions-a047a8ea.js} +503 -503
  4. package/dist/cjs/{global-69514290.js → global-15dfd5ba.js} +72 -72
  5. package/dist/cjs/{http-service-9e8c4dd5.js → http-service-494d81de.js} +49 -49
  6. package/dist/cjs/{interfaces-30a74c1f.js → interfaces-a3338581.js} +29 -29
  7. package/dist/cjs/{intl-d9ffc76c.js → intl-47d63c8f.js} +131 -131
  8. package/dist/cjs/loader.cjs.js +1 -1
  9. package/dist/cjs/priv-chart-popover.cjs.entry.js +91 -91
  10. package/dist/cjs/priv-datepicker.cjs.entry.js +657 -657
  11. package/dist/cjs/priv-navigator-button.cjs.entry.js +19 -19
  12. package/dist/cjs/priv-navigator-item.cjs.entry.js +23 -23
  13. package/dist/cjs/ripple.cjs.js +1 -1
  14. package/dist/cjs/wm-action-menu_2.cjs.entry.js +334 -334
  15. package/dist/cjs/wm-button.cjs.entry.js +260 -260
  16. package/dist/cjs/wm-chart-slice.cjs.entry.js +18 -18
  17. package/dist/cjs/wm-chart.cjs.entry.js +183 -183
  18. package/dist/cjs/wm-datepicker.cjs.entry.js +263 -263
  19. package/dist/cjs/wm-file-list.cjs.entry.js +35 -35
  20. package/dist/cjs/wm-file.cjs.entry.js +181 -181
  21. package/dist/cjs/wm-input.cjs.entry.js +136 -136
  22. package/dist/cjs/wm-modal-footer.cjs.entry.js +33 -33
  23. package/dist/cjs/wm-modal-header.cjs.entry.js +32 -32
  24. package/dist/cjs/wm-modal.cjs.entry.js +152 -152
  25. package/dist/cjs/wm-navigation_3.cjs.entry.js +225 -225
  26. package/dist/cjs/wm-navigator.cjs.entry.js +264 -264
  27. package/dist/cjs/wm-network-uploader.cjs.entry.js +465 -465
  28. package/dist/cjs/wm-option_2.cjs.entry.js +768 -768
  29. package/dist/cjs/wm-pagination.cjs.entry.js +179 -179
  30. package/dist/cjs/wm-progress-indicator_3.cjs.entry.js +155 -155
  31. package/dist/cjs/wm-search.cjs.entry.js +184 -184
  32. package/dist/cjs/wm-snackbar.cjs.entry.js +155 -155
  33. package/dist/cjs/wm-tab-item_3.cjs.entry.js +264 -264
  34. package/dist/cjs/wm-tag-input-row.cjs.entry.js +14 -14
  35. package/dist/cjs/wm-tag-input.cjs.entry.js +940 -940
  36. package/dist/cjs/wm-timepicker.cjs.entry.js +385 -385
  37. package/dist/cjs/wm-toggletip.cjs.entry.js +130 -130
  38. package/dist/cjs/wm-uploader.cjs.entry.js +441 -441
  39. package/dist/cjs/wm-wrapper.cjs.entry.js +12 -12
  40. package/dist/collection/components/charts/chartFunctions.js +562 -562
  41. package/dist/collection/components/charts/priv-chart-popover/priv-chart-popover.js +267 -267
  42. package/dist/collection/components/charts/wm-chart/wm-chart-slice.js +125 -125
  43. package/dist/collection/components/charts/wm-chart/wm-chart.js +450 -450
  44. package/dist/collection/components/charts/wm-progress-monitor/wm-progress-indicator.js +207 -207
  45. package/dist/collection/components/charts/wm-progress-monitor/wm-progress-monitor.js +143 -143
  46. package/dist/collection/components/charts/wm-progress-monitor/wm-progress-slice.js +121 -121
  47. package/dist/collection/components/wm-action-menu/wm-action-menu.js +472 -472
  48. package/dist/collection/components/wm-button/wm-button.js +575 -575
  49. package/dist/collection/components/wm-datepicker/priv-datepicker/priv-datepicker.js +983 -983
  50. package/dist/collection/components/wm-datepicker/wm-datepicker.js +491 -491
  51. package/dist/collection/components/wm-file/wm-file.js +313 -313
  52. package/dist/collection/components/wm-file-list/wm-file-list.js +152 -152
  53. package/dist/collection/components/wm-input/wm-input.js +509 -509
  54. package/dist/collection/components/wm-menuitem/wm-menuitem.js +454 -454
  55. package/dist/collection/components/wm-modal/wm-modal-footer.js +138 -138
  56. package/dist/collection/components/wm-modal/wm-modal-header.js +82 -82
  57. package/dist/collection/components/wm-modal/wm-modal.js +462 -462
  58. package/dist/collection/components/wm-navigation/wm-navigation-hamburger.js +176 -176
  59. package/dist/collection/components/wm-navigation/wm-navigation-item.js +130 -130
  60. package/dist/collection/components/wm-navigation/wm-navigation.js +217 -217
  61. package/dist/collection/components/wm-navigator/priv-navigator-button/priv-navigator-button.js +106 -106
  62. package/dist/collection/components/wm-navigator/priv-navigator-item/priv-navigator-item.js +123 -123
  63. package/dist/collection/components/wm-navigator/wm-navigator.js +467 -467
  64. package/dist/collection/components/wm-option/wm-option.js +435 -435
  65. package/dist/collection/components/wm-pagination/wm-pagination.js +370 -370
  66. package/dist/collection/components/wm-search/wm-search.js +439 -439
  67. package/dist/collection/components/wm-select/wm-select.js +1054 -1054
  68. package/dist/collection/components/wm-snackbar/wm-snackbar.js +282 -282
  69. package/dist/collection/components/wm-tabs/wm-tab-item/wm-tab-item.js +211 -211
  70. package/dist/collection/components/wm-tabs/wm-tab-list/wm-tab-list.js +327 -327
  71. package/dist/collection/components/wm-tabs/wm-tab-panel/wm-tab-panel.js +108 -108
  72. package/dist/collection/components/wm-tag-input/wm-tag-input-row/wm-tag-input-row.js +122 -122
  73. package/dist/collection/components/wm-tag-input/wm-tag-input.js +1295 -1295
  74. package/dist/collection/components/wm-timepicker/wm-timepicker.js +605 -605
  75. package/dist/collection/components/wm-toggletip/wm-toggletip.js +253 -253
  76. package/dist/collection/components/wm-uploader/wm-network-uploader/wm-network-uploader.js +772 -772
  77. package/dist/collection/components/wm-uploader/wm-uploader.js +964 -964
  78. package/dist/collection/components/wm-wrapper/wm-wrapper.js +28 -28
  79. package/dist/collection/dev/scripts.js +20 -20
  80. package/dist/collection/global/__mocks__/functions.js +6 -6
  81. package/dist/collection/global/functions.js +546 -546
  82. package/dist/collection/global/global.js +79 -79
  83. package/dist/collection/global/interfaces.js +49 -49
  84. package/dist/collection/global/intl.js +132 -132
  85. package/dist/collection/global/services/__mocks__/http-service.js +130 -130
  86. package/dist/collection/global/services/http-service.js +50 -50
  87. package/dist/collection/lang/lang.js +5 -5
  88. package/dist/collection/lang/missing.js +43 -43
  89. package/dist/collection/lang/piglatin.js +93 -93
  90. package/dist/esm/{chartFunctions-5c1ad085.js → chartFunctions-9d629e09.js} +596 -596
  91. package/dist/esm/{functions-b2582352.js → functions-3b813e0c.js} +503 -503
  92. package/dist/esm/{global-315bd16c.js → global-937b39b4.js} +72 -72
  93. package/dist/esm/{http-service-5d037e16.js → http-service-3dc3b3e7.js} +49 -49
  94. package/dist/esm/{interfaces-61c6305b.js → interfaces-2b97fab2.js} +29 -29
  95. package/dist/esm/{intl-6732dd5b.js → intl-d544f922.js} +131 -131
  96. package/dist/esm/loader.js +1 -1
  97. package/dist/esm/polyfills/core-js.js +0 -0
  98. package/dist/esm/polyfills/dom.js +0 -0
  99. package/dist/esm/polyfills/es5-html-element.js +0 -0
  100. package/dist/esm/polyfills/index.js +0 -0
  101. package/dist/esm/polyfills/system.js +0 -0
  102. package/dist/esm/priv-chart-popover.entry.js +91 -91
  103. package/dist/esm/priv-datepicker.entry.js +657 -657
  104. package/dist/esm/priv-navigator-button.entry.js +19 -19
  105. package/dist/esm/priv-navigator-item.entry.js +23 -23
  106. package/dist/esm/ripple.js +1 -1
  107. package/dist/esm/wm-action-menu_2.entry.js +334 -334
  108. package/dist/esm/wm-button.entry.js +260 -260
  109. package/dist/esm/wm-chart-slice.entry.js +18 -18
  110. package/dist/esm/wm-chart.entry.js +183 -183
  111. package/dist/esm/wm-datepicker.entry.js +263 -263
  112. package/dist/esm/wm-file-list.entry.js +35 -35
  113. package/dist/esm/wm-file.entry.js +181 -181
  114. package/dist/esm/wm-input.entry.js +136 -136
  115. package/dist/esm/wm-modal-footer.entry.js +33 -33
  116. package/dist/esm/wm-modal-header.entry.js +32 -32
  117. package/dist/esm/wm-modal.entry.js +152 -152
  118. package/dist/esm/wm-navigation_3.entry.js +225 -225
  119. package/dist/esm/wm-navigator.entry.js +264 -264
  120. package/dist/esm/wm-network-uploader.entry.js +465 -465
  121. package/dist/esm/wm-option_2.entry.js +768 -768
  122. package/dist/esm/wm-pagination.entry.js +179 -179
  123. package/dist/esm/wm-progress-indicator_3.entry.js +155 -155
  124. package/dist/esm/wm-search.entry.js +184 -184
  125. package/dist/esm/wm-snackbar.entry.js +155 -155
  126. package/dist/esm/wm-tab-item_3.entry.js +264 -264
  127. package/dist/esm/wm-tag-input-row.entry.js +14 -14
  128. package/dist/esm/wm-tag-input.entry.js +940 -940
  129. package/dist/esm/wm-timepicker.entry.js +385 -385
  130. package/dist/esm/wm-toggletip.entry.js +130 -130
  131. package/dist/esm/wm-uploader.entry.js +441 -441
  132. package/dist/esm/wm-wrapper.entry.js +12 -12
  133. package/dist/esm-es5/{chartFunctions-5c1ad085.js → chartFunctions-9d629e09.js} +1 -1
  134. package/dist/esm-es5/global-937b39b4.js +1 -0
  135. package/dist/esm-es5/{intl-6732dd5b.js → intl-d544f922.js} +1 -1
  136. package/dist/esm-es5/loader.js +1 -1
  137. package/dist/esm-es5/priv-chart-popover.entry.js +1 -1
  138. package/dist/esm-es5/priv-datepicker.entry.js +1 -1
  139. package/dist/esm-es5/ripple.js +1 -1
  140. package/dist/esm-es5/wm-action-menu_2.entry.js +1 -1
  141. package/dist/esm-es5/wm-button.entry.js +1 -1
  142. package/dist/esm-es5/wm-chart.entry.js +1 -1
  143. package/dist/esm-es5/wm-datepicker.entry.js +1 -1
  144. package/dist/esm-es5/wm-file.entry.js +1 -1
  145. package/dist/esm-es5/wm-input.entry.js +1 -1
  146. package/dist/esm-es5/wm-modal-header.entry.js +1 -1
  147. package/dist/esm-es5/wm-modal.entry.js +1 -1
  148. package/dist/esm-es5/wm-navigation_3.entry.js +1 -1
  149. package/dist/esm-es5/wm-navigator.entry.js +1 -1
  150. package/dist/esm-es5/wm-network-uploader.entry.js +1 -1
  151. package/dist/esm-es5/wm-option_2.entry.js +1 -1
  152. package/dist/esm-es5/wm-pagination.entry.js +1 -1
  153. package/dist/esm-es5/wm-progress-indicator_3.entry.js +1 -1
  154. package/dist/esm-es5/wm-search.entry.js +1 -1
  155. package/dist/esm-es5/wm-snackbar.entry.js +1 -1
  156. package/dist/esm-es5/wm-tab-item_3.entry.js +1 -1
  157. package/dist/esm-es5/wm-tag-input.entry.js +1 -1
  158. package/dist/esm-es5/wm-timepicker.entry.js +1 -1
  159. package/dist/esm-es5/wm-toggletip.entry.js +1 -1
  160. package/dist/esm-es5/wm-uploader.entry.js +1 -1
  161. package/dist/ripple/{p-d5a420fa.entry.js → p-05563588.entry.js} +1 -1
  162. package/dist/ripple/{p-061914bf.system.entry.js → p-09a04f55.system.entry.js} +1 -1
  163. package/dist/ripple/{p-a2f10a77.entry.js → p-09bc0aa7.entry.js} +1 -1
  164. package/dist/ripple/{p-0414179c.entry.js → p-0cfc0d13.entry.js} +1 -1
  165. package/dist/ripple/{p-a9080b82.entry.js → p-0ef638b7.entry.js} +1 -1
  166. package/dist/ripple/p-0efd4691.js +1 -0
  167. package/dist/ripple/{p-f740c48c.system.entry.js → p-12c70659.system.entry.js} +1 -1
  168. package/dist/ripple/{p-7ee31208.js → p-18c2f4fe.js} +1 -1
  169. package/dist/ripple/{p-462e7cf8.system.entry.js → p-236dab05.system.entry.js} +1 -1
  170. package/dist/ripple/{p-9baf62ae.entry.js → p-2cd5477a.entry.js} +1 -1
  171. package/dist/ripple/{p-2cef256c.system.entry.js → p-2cde4ade.system.entry.js} +1 -1
  172. package/dist/ripple/{p-076a8729.entry.js → p-2d46dbea.entry.js} +1 -1
  173. package/dist/ripple/{p-3313df40.system.entry.js → p-2dd5f5c3.system.entry.js} +1 -1
  174. package/dist/ripple/{p-64b64f40.system.entry.js → p-35790e4e.system.entry.js} +1 -1
  175. package/dist/ripple/{p-4e7489a3.system.entry.js → p-38819b27.system.entry.js} +1 -1
  176. package/dist/ripple/{p-926aab51.entry.js → p-3aa8e5f5.entry.js} +1 -1
  177. package/dist/ripple/{p-42739dba.entry.js → p-42f8f3ff.entry.js} +1 -1
  178. package/dist/ripple/{p-c1d814f8.system.entry.js → p-4444add0.system.entry.js} +1 -1
  179. package/dist/ripple/{p-0648aa61.system.entry.js → p-4f5a48dd.system.entry.js} +1 -1
  180. package/dist/ripple/{p-22b74491.entry.js → p-51b38033.entry.js} +1 -1
  181. package/dist/ripple/{p-9706537b.system.js → p-54a2b7d6.system.js} +1 -1
  182. package/dist/ripple/{p-00edfbc8.system.entry.js → p-56ba575c.system.entry.js} +1 -1
  183. package/dist/ripple/{p-b7f204e6.entry.js → p-5708349e.entry.js} +1 -1
  184. package/dist/ripple/{p-7dafc84b.system.entry.js → p-630bd6f5.system.entry.js} +1 -1
  185. package/dist/ripple/p-68808537.system.js +1 -0
  186. package/dist/ripple/{p-95a0cf13.entry.js → p-69c13034.entry.js} +1 -1
  187. package/dist/ripple/{p-b7982fab.system.js → p-6eb2c2d5.system.js} +1 -1
  188. package/dist/ripple/{p-3aaf86e4.entry.js → p-7f15df83.entry.js} +1 -1
  189. package/dist/ripple/{p-4bd9623f.system.entry.js → p-81eb0d71.system.entry.js} +1 -1
  190. package/dist/ripple/{p-5ddb1660.entry.js → p-832910a0.entry.js} +1 -1
  191. package/dist/ripple/{p-66bb46e5.system.entry.js → p-84ce9b67.system.entry.js} +1 -1
  192. package/dist/ripple/{p-e6fde200.system.entry.js → p-8775e10b.system.entry.js} +1 -1
  193. package/dist/ripple/{p-6f96c28d.entry.js → p-8b23f32b.entry.js} +1 -1
  194. package/dist/ripple/{p-17490d32.entry.js → p-8c853762.entry.js} +1 -1
  195. package/dist/ripple/{p-81b26d3a.system.entry.js → p-8ff578ad.system.entry.js} +1 -1
  196. package/dist/ripple/{p-9b9e60aa.system.entry.js → p-95aa793b.system.entry.js} +1 -1
  197. package/dist/ripple/{p-9b28a31f.entry.js → p-95f4e5a1.entry.js} +1 -1
  198. package/dist/ripple/{p-accdf91c.system.entry.js → p-a006968b.system.entry.js} +1 -1
  199. package/dist/ripple/{p-f1c345c2.system.js → p-ad129ba3.system.js} +1 -1
  200. package/dist/ripple/{p-094388f1.entry.js → p-ae1e1db8.entry.js} +1 -1
  201. package/dist/ripple/{p-3b582301.entry.js → p-b3d97de8.entry.js} +1 -1
  202. package/dist/ripple/{p-f8418ac9.entry.js → p-bdecbb63.entry.js} +1 -1
  203. package/dist/ripple/{p-b805612a.system.entry.js → p-c3665c9f.system.entry.js} +1 -1
  204. package/dist/ripple/{p-d7f77b2c.js → p-d96b86c9.js} +1 -1
  205. package/dist/ripple/{p-08e1c91b.system.entry.js → p-d973fe13.system.entry.js} +1 -1
  206. package/dist/ripple/{p-0503e614.system.entry.js → p-ea99fb58.system.entry.js} +1 -1
  207. package/dist/ripple/{p-bd94e7c3.entry.js → p-eeeec290.entry.js} +1 -1
  208. package/dist/ripple/{p-a5662a2c.system.entry.js → p-f2bb38d0.system.entry.js} +1 -1
  209. package/dist/ripple/{p-043b4874.entry.js → p-f6c9c95f.entry.js} +1 -1
  210. package/dist/ripple/{p-731beaab.system.entry.js → p-f6f80b8d.system.entry.js} +1 -1
  211. package/dist/ripple/{p-49f7f1da.entry.js → p-fe76e568.entry.js} +1 -1
  212. package/dist/ripple/{p-60f58a39.system.entry.js → p-fea37751.system.entry.js} +1 -1
  213. package/dist/ripple/{p-918dc303.entry.js → p-ffb83b6f.entry.js} +1 -1
  214. package/dist/ripple/ripple.esm.js +1 -1
  215. package/dist/ripple/ripple.js +1 -1
  216. package/dist/types/components/charts/chartFunctions.d.ts +37 -37
  217. package/dist/types/components/charts/priv-chart-popover/priv-chart-popover.d.ts +27 -27
  218. package/dist/types/components/charts/wm-chart/wm-chart-slice.d.ts +11 -11
  219. package/dist/types/components/charts/wm-chart/wm-chart.d.ts +47 -47
  220. package/dist/types/components/charts/wm-progress-monitor/wm-progress-indicator.d.ts +29 -29
  221. package/dist/types/components/charts/wm-progress-monitor/wm-progress-monitor.d.ts +20 -20
  222. package/dist/types/components/charts/wm-progress-monitor/wm-progress-slice.d.ts +10 -10
  223. package/dist/types/components/wm-action-menu/wm-action-menu.d.ts +49 -49
  224. package/dist/types/components/wm-button/wm-button.d.ts +49 -49
  225. package/dist/types/components/wm-datepicker/priv-datepicker/priv-datepicker.d.ts +80 -80
  226. package/dist/types/components/wm-datepicker/wm-datepicker.d.ts +42 -42
  227. package/dist/types/components/wm-file/wm-file.d.ts +40 -40
  228. package/dist/types/components/wm-file-list/wm-file-list.d.ts +16 -16
  229. package/dist/types/components/wm-input/wm-input.d.ts +57 -57
  230. package/dist/types/components/wm-menuitem/wm-menuitem.d.ts +34 -34
  231. package/dist/types/components/wm-modal/wm-modal-footer.d.ts +14 -14
  232. package/dist/types/components/wm-modal/wm-modal-header.d.ts +10 -10
  233. package/dist/types/components/wm-modal/wm-modal.d.ts +40 -40
  234. package/dist/types/components/wm-navigation/wm-navigation-hamburger.d.ts +21 -21
  235. package/dist/types/components/wm-navigation/wm-navigation-item.d.ts +13 -13
  236. package/dist/types/components/wm-navigation/wm-navigation.d.ts +26 -26
  237. package/dist/types/components/wm-navigator/priv-navigator-button/priv-navigator-button.d.ts +10 -10
  238. package/dist/types/components/wm-navigator/priv-navigator-item/priv-navigator-item.d.ts +13 -13
  239. package/dist/types/components/wm-navigator/wm-navigator.d.ts +61 -61
  240. package/dist/types/components/wm-option/wm-option.d.ts +34 -34
  241. package/dist/types/components/wm-pagination/wm-pagination.d.ts +32 -32
  242. package/dist/types/components/wm-search/wm-search.d.ts +77 -77
  243. package/dist/types/components/wm-select/wm-select.d.ts +101 -101
  244. package/dist/types/components/wm-snackbar/wm-snackbar.d.ts +31 -31
  245. package/dist/types/components/wm-tabs/wm-tab-item/wm-tab-item.d.ts +37 -37
  246. package/dist/types/components/wm-tabs/wm-tab-list/wm-tab-list.d.ts +52 -52
  247. package/dist/types/components/wm-tabs/wm-tab-panel/wm-tab-panel.d.ts +20 -20
  248. package/dist/types/components/wm-tag-input/wm-tag-input-row/wm-tag-input-row.d.ts +11 -11
  249. package/dist/types/components/wm-tag-input/wm-tag-input.d.ts +136 -136
  250. package/dist/types/components/wm-timepicker/wm-timepicker.d.ts +62 -62
  251. package/dist/types/components/wm-toggletip/wm-toggletip.d.ts +28 -28
  252. package/dist/types/components/wm-uploader/wm-network-uploader/wm-network-uploader.d.ts +85 -85
  253. package/dist/types/components/wm-uploader/wm-uploader.d.ts +99 -99
  254. package/dist/types/components/wm-wrapper/wm-wrapper.d.ts +7 -7
  255. package/dist/types/components.d.ts +27 -27
  256. package/dist/types/global/__mocks__/functions.d.ts +6 -6
  257. package/dist/types/global/functions.d.ts +49 -49
  258. package/dist/types/global/global.d.ts +1 -1
  259. package/dist/types/global/interfaces.d.ts +74 -74
  260. package/dist/types/global/intl.d.ts +29 -29
  261. package/dist/types/global/services/__mocks__/http-service.d.ts +6 -6
  262. package/dist/types/global/services/http-service.d.ts +4 -4
  263. package/dist/types/lang/lang.d.ts +5 -5
  264. package/package.json +46 -46
  265. package/dist/esm-es5/global-315bd16c.js +0 -1
  266. package/dist/ripple/p-3306f082.system.js +0 -1
  267. package/dist/ripple/p-a230bbf1.js +0 -1
  268. /package/dist/esm-es5/{functions-b2582352.js → functions-3b813e0c.js} +0 -0
  269. /package/dist/esm-es5/{http-service-5d037e16.js → http-service-3dc3b3e7.js} +0 -0
  270. /package/dist/esm-es5/{interfaces-61c6305b.js → interfaces-2b97fab2.js} +0 -0
  271. /package/dist/ripple/{p-9e94ae94.system.js → p-190afa40.system.js} +0 -0
  272. /package/dist/ripple/{p-888bec42.js → p-43f1298b.js} +0 -0
  273. /package/dist/ripple/{p-5384856b.js → p-4a0e1d2d.js} +0 -0
  274. /package/dist/ripple/{p-313b6073.system.js → p-9d02957d.system.js} +0 -0
  275. /package/dist/ripple/{p-08b7ec08.system.js → p-f5df5903.system.js} +0 -0
  276. /package/dist/ripple/{p-a6d6eae7.js → p-fd8070fb.js} +0 -0
@@ -1,562 +1,562 @@
1
- import { h } from "@stencil/core";
2
- import { checkForActiveElInShadow, debounce, findParentWithScrollbar, getPosition, intl } from "../../global/functions";
3
- const colors = {
4
- salmon: "#ff5f4e",
5
- cyan: "#19a1a9",
6
- forest: "#088000",
7
- sleet: "#7f97ad",
8
- midnight: "#2e1b46",
9
- lavender: "#8b86ca",
10
- periwinkle: "#575195",
11
- gray: "#6b6b6b",
12
- };
13
- export const allChartsDetails = {
14
- // for progress monitor
15
- doughnut: {
16
- size: 155,
17
- colors: [colors.forest, colors.gray],
18
- thickness: 0.73,
19
- padding: 25,
20
- category: "doughnut",
21
- },
22
- // deprecated hybrid chart type, should use Progress Indicator's "doughnut" instead
23
- doughnut0: {
24
- size: 155,
25
- colors: [colors.forest, colors.gray],
26
- thickness: 0.73,
27
- padding: 25,
28
- category: "doughnut",
29
- },
30
- doughnut1: {
31
- size: 130,
32
- colors: [colors.lavender, colors.midnight, colors.gray],
33
- thickness: 0.5,
34
- padding: 90,
35
- category: "doughnut",
36
- },
37
- doughnut2: {
38
- size: 130,
39
- colors: [colors.cyan, colors.salmon, colors.gray],
40
- thickness: 0.5,
41
- padding: 90,
42
- category: "doughnut",
43
- },
44
- // an internal type only for use when doughnut 2 is populated with 4 slices
45
- // in this case, the first slice is colored purple
46
- doughnut2b: {
47
- size: 130,
48
- colors: [colors.periwinkle, colors.cyan, colors.salmon, colors.gray],
49
- thickness: 0.5,
50
- padding: 90,
51
- category: "doughnut",
52
- },
53
- doughnut3: {
54
- size: 130,
55
- colors: [colors.lavender, colors.midnight, "#0089e4", colors.forest, "#ea8500", "#d54f41", "#146ca9"],
56
- thickness: 0.5,
57
- padding: 90,
58
- category: "doughnut",
59
- },
60
- // for progress monitor
61
- bar: {
62
- size: 350,
63
- colors: [colors.forest, colors.gray],
64
- padding: 0,
65
- category: "stackedBar",
66
- },
67
- // deprecated hybrid chart type, should use Progress Indicator's "bar" instead
68
- bar1: {
69
- size: 350,
70
- colors: [colors.forest, colors.gray],
71
- padding: 0,
72
- category: "stackedBar",
73
- },
74
- bar2: {
75
- size: 400,
76
- colors: [colors.gray, colors.periwinkle, colors.cyan, colors.salmon],
77
- padding: 0,
78
- category: "stackedBar",
79
- },
80
- bar2b: {
81
- size: 400,
82
- colors: [colors.gray, colors.periwinkle, colors.midnight, colors.cyan, colors.salmon],
83
- padding: 0,
84
- category: "stackedBar",
85
- },
86
- bar3: {
87
- size: 300,
88
- colors: ["#0d696e", colors.cyan, "#8e4129", colors.salmon],
89
- padding: 0,
90
- category: "stackedBar",
91
- },
92
- bar4: {
93
- size: 400,
94
- colors: [colors.salmon, colors.cyan, colors.periwinkle],
95
- padding: 0,
96
- category: "stackedBar",
97
- },
98
- bar5: {
99
- size: 400,
100
- colors: [
101
- colors.gray,
102
- colors.lavender,
103
- colors.midnight,
104
- "#0089e4",
105
- colors.forest,
106
- "#ea8500",
107
- "#d54f41",
108
- "#146ca9",
109
- ],
110
- padding: 0,
111
- category: "stackedBar",
112
- },
113
- bar6: {
114
- size: 400,
115
- colors: [colors.lavender],
116
- padding: 0,
117
- category: "simpleBar",
118
- },
119
- bar7: {
120
- size: 400,
121
- colors: [colors.periwinkle, colors.cyan, colors.salmon, colors.gray],
122
- padding: 0,
123
- category: "simpleBar",
124
- },
125
- };
126
- function showValue(valueFormat) {
127
- return valueFormat === "percentage" || valueFormat === "amount" ? "show-values" : "";
128
- }
129
- export const textHiddenMessage = intl.formatMessage({
130
- id: "chart.hiddenValues",
131
- defaultMessage: "Values are not shown when too close to each other.",
132
- description: "Text displayed when a chart has some values hidden",
133
- });
134
- export const seeDetailsMessage = intl.formatMessage({
135
- id: "chart.clickToSeeDetails",
136
- defaultMessage: "Click or use arrow keys to see details.",
137
- description: "Text displayed, guiding user to interact to see more details.",
138
- });
139
- function abbrNumber(num) {
140
- return num > 999 ? Math.round(num / 100) / 10 + "K" : num;
141
- }
142
- export function amountToPercent(val, total, asInt) {
143
- return asInt ? Math.round((val * 100) / total) : Math.round((val * 10000) / total) / 100; // with 2 decimals
144
- }
145
- export function amountToDegree(val, total) {
146
- // In a circle of {total}, determine degrees of slice {val}
147
- return (val * 360) / total;
148
- }
149
- export function toFixed(number) {
150
- return parseFloat((Math.floor(number * 100) / 100).toFixed(2));
151
- }
152
- export function polarToCartesian(half, radius, startAngle, endAngle) {
153
- var x = toFixed(half + half * radius * Math.cos((Math.PI * startAngle) / 180));
154
- var y = toFixed(half + half * radius * Math.sin((Math.PI * startAngle) / 180));
155
- if (endAngle !== undefined) {
156
- // if a 2nd angle value was passed, return 2 pairs of coords
157
- var x2 = toFixed(half + half * radius * Math.cos((Math.PI * endAngle) / 180));
158
- var y2 = toFixed(half + half * radius * Math.sin((Math.PI * endAngle) / 180));
159
- return { x1: x, y1: y, x2, y2 };
160
- }
161
- return { x, y };
162
- }
163
- function getArc(radius, largeArcFlag, x, y, chartSize) {
164
- var z = toFixed((chartSize / 2) * radius);
165
- return `A ${z}, ${z} 0 ${largeArcFlag} ${toFixed(x)}, ${toFixed(y)}`;
166
- }
167
- function scale(val, inMin, inMax, outMin, outMax) {
168
- let scaled = ((val - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin;
169
- // clip the values so that whatever is passed in the output is never smaller than outMin or greater than outMax
170
- return scaled < outMin ? outMin : scaled > outMax ? outMax : scaled;
171
- }
172
- function minSpacing(width) {
173
- // minimum spacing between 2 ticks, in px
174
- return scale(width, 300, 900, 70, 150);
175
- }
176
- function getMaxTicks(width) {
177
- return Math.round(width / minSpacing(width));
178
- }
179
- function getInterval(largest, maxticks) {
180
- const minimum = largest / maxticks;
181
- const magnitude = 10 ** Math.floor(Math.log10(minimum));
182
- const residual = minimum / magnitude;
183
- let interval;
184
- if (residual > 5) {
185
- interval = 10 * magnitude;
186
- }
187
- else if (residual > 3) {
188
- interval = 5 * magnitude;
189
- }
190
- else if (residual > 2) {
191
- interval = 3 * magnitude;
192
- }
193
- else if (residual > 1.5) {
194
- interval = 2 * magnitude;
195
- }
196
- else if (residual > 1) {
197
- interval = 1.5 * magnitude;
198
- }
199
- else {
200
- interval = magnitude;
201
- }
202
- return interval;
203
- }
204
- function handleSliceKeyDown(ev) {
205
- if (this.popoverEl && this.popoverEl.open && ev.key === "Enter") {
206
- const popoverBtn = this.popoverEl.querySelector("button");
207
- popoverBtn && popoverBtn.click();
208
- }
209
- }
210
- export function handleSliceClick(ev, s) {
211
- if (this.popoverEl && !this.isTabbing) {
212
- s.coords = { x: ev.clientX, y: ev.clientY };
213
- openPopover.call(this, s);
214
- }
215
- }
216
- function handleSliceFocus(ev, s) {
217
- if (this.popoverEl && this.isTabbing) {
218
- s.coords = getPosition(ev.target);
219
- openPopover.call(this, s);
220
- }
221
- }
222
- export function handleChartKeydown(ev) {
223
- switch (ev.key) {
224
- // arrow up / left
225
- case "ArrowUp":
226
- case "ArrowLeft":
227
- ev.preventDefault();
228
- this.isTabbing = true; // shd already be true. just in case user clicked on chart then pressed an arrow key
229
- focusPrevious.call(this);
230
- break;
231
- // arrow right / down
232
- case "ArrowRight":
233
- case "ArrowDown":
234
- ev.preventDefault();
235
- this.isTabbing = true; // shd already be true. just in case user clicked on chart then pressed an arrow key
236
- focusNext.call(this);
237
- break;
238
- // tab
239
- case "Tab":
240
- exitChart.call(this);
241
- break;
242
- case "Escape":
243
- this.popoverEl.open = false;
244
- this.userIsNavigating = false;
245
- break;
246
- }
247
- }
248
- export function openPopover(s) {
249
- if (!!this.popoverEl && !!s.title && !!s.text) {
250
- this.popoverEl.popoverTitle = s.title;
251
- this.popoverEl.popoverText = s.text;
252
- this.popoverEl.buttonText = s.buttonText;
253
- this.popoverEl.coords = s.coords;
254
- this.popoverEl.sliceRef = s.sliceRef;
255
- window.setTimeout(() => {
256
- if (this.popoverEl) {
257
- this.popoverEl.open = true;
258
- }
259
- }, 30);
260
- const debouncedClosePopover = debounce(async () => {
261
- this.popoverEl.open = false;
262
- }, 10);
263
- // set up event listeners for scrolling
264
- // to close popover on page scroll
265
- document.addEventListener("scroll", () => {
266
- debouncedClosePopover();
267
- });
268
- // ... and on parent scroll
269
- const scrollableParent = findParentWithScrollbar(this.el);
270
- if (!!scrollableParent) {
271
- scrollableParent.addEventListener("scroll", () => {
272
- debouncedClosePopover();
273
- });
274
- }
275
- }
276
- }
277
- function focusNext() {
278
- const activeEl = checkForActiveElInShadow(document.activeElement);
279
- const index =
280
- // if the active el is not in the array the first element gets focused
281
- (this.sliceEls.indexOf(activeEl) + 1) % this.sliceEls.length;
282
- focusSlice.call(this, index);
283
- }
284
- function focusPrevious() {
285
- if (this.sliceEls) {
286
- const activeEl = checkForActiveElInShadow(document.activeElement);
287
- let index = this.sliceEls.indexOf(activeEl);
288
- if (index === -1) {
289
- // not in the array : focus the first slice
290
- index = 0;
291
- }
292
- else if (index === 0) {
293
- // first slice : focus the last slice
294
- index = this.sliceEls.length - 1;
295
- }
296
- else {
297
- // anything else: focus previous
298
- index -= 1;
299
- }
300
- focusSlice.call(this, index);
301
- }
302
- }
303
- function focusSlice(index) {
304
- if (this.sliceEls && this.el) {
305
- this.userIsNavigating = true;
306
- if (this.popoverEl) {
307
- this.popoverEl.open = false;
308
- }
309
- // set tabindex of the wrapper to -1 while slices are being focused, to allow for shft-tabbing out of the component directly
310
- this.componentWrapperEl.tabIndex = -1;
311
- // @ts-ignore
312
- this.el.focusable = false; // for Edge
313
- this.sliceEls.map((p) => {
314
- p.tabIndex = -1;
315
- // @ts-ignore
316
- p.focusable = false; // for Edge
317
- });
318
- this.sliceEls[index].tabIndex = 0;
319
- // @ts-ignore
320
- this.sliceEls[index].focusable = true; // for Edge
321
- this.sliceEls[index].focus();
322
- window.setTimeout(() => {
323
- if (this.popoverEl) {
324
- this.popoverEl.open = true;
325
- }
326
- }, 10);
327
- }
328
- }
329
- export function exitChart() {
330
- this.sliceEls &&
331
- this.sliceEls.map((p) => {
332
- p.tabIndex = -1;
333
- // @ts-ignore
334
- p.focusable = false; // for Edge
335
- });
336
- this.userIsNavigating = false;
337
- // delay so that we can tab out of component before chart becomes focusable again
338
- // and in case user was still pressing an arrow key when they pressed tab
339
- window.setTimeout(() => {
340
- this.componentWrapperEl.tabIndex = 0;
341
- // @ts-ignore
342
- this.el.focusable = true; // for Edge
343
- if (this.popoverEl) {
344
- this.popoverEl.open = false;
345
- }
346
- }, 100);
347
- }
348
- export async function getDetails(chartType) {
349
- this.slicesDetails = [];
350
- let acc = 0;
351
- const children = Array.from(this.el.children);
352
- this.total = children.reduce((total, slice) => (total += parseInt(slice.getAttribute("amount") || "0")), 0);
353
- children.forEach((c, i) => {
354
- const amount = parseInt(c.getAttribute("amount") || "0");
355
- const perc = amountToPercent(amount, this.total, true);
356
- let colorIndex = i;
357
- // for bar5, first color should be skipped unless notStartedColor is set to true
358
- if (chartType === "bar5") {
359
- colorIndex = this.notStartedColor ? i : i + 1;
360
- }
361
- // bars in bar6 are all the same color
362
- if (chartType === "bar6") {
363
- colorIndex = 0;
364
- }
365
- const color = allChartsDetails[chartType].colors[colorIndex];
366
- const sliceDetails = {
367
- amount: amount,
368
- perc: perc,
369
- legend: c.getAttribute("legend"),
370
- color: color || colors.gray,
371
- offset: acc,
372
- id: `${this.uid}-${i + 1}`,
373
- title: c.getAttribute("popover-title"),
374
- text: c.getAttribute("popover-text"),
375
- buttonText: c.getAttribute("popover-button-text"),
376
- sliceRef: c,
377
- inSmallCluster: false,
378
- };
379
- acc += amount;
380
- this.slicesDetails.push(sliceDetails);
381
- });
382
- }
383
- function sortSlicesDetails(slicesDetails, total) {
384
- // sort slices by decreasing amount
385
- let sortedSlicesDetails = [...slicesDetails].sort((a, b) => a.amount === b.amount ? 0 : a.amount > b.amount ? -1 : 1);
386
- let acc = 0;
387
- sortedSlicesDetails.forEach((s, idx) => {
388
- const prev = sortedSlicesDetails[idx === 0 ? sortedSlicesDetails.length - 1 : idx - 1];
389
- const next = sortedSlicesDetails[idx === sortedSlicesDetails.length - 1 ? 0 : idx + 1];
390
- const prevPerc = amountToPercent(prev.amount, total, true);
391
- const nextPerc = amountToPercent(next.amount, total, true);
392
- s.offset = acc;
393
- acc += s.amount;
394
- s.inSmallCluster = isInSmallCluster(prevPerc, s.perc, s.amount, nextPerc);
395
- });
396
- return sortedSlicesDetails;
397
- }
398
- function isInSmallCluster(prevPerc, perc, amount, nextPerc) {
399
- // determine whether the slice is in a cluster of small values
400
- // to avoid percentage text overlap for small values
401
- const isSmall = perc < 4;
402
- const prevIsSmall = prevPerc < 5;
403
- const nextIsSmall = nextPerc < 5;
404
- let inSmallCluster = isSmall && (prevIsSmall || nextIsSmall);
405
- // because <1% slice percentage text has an additional character
406
- // the inSmallCluster threshold needs to be widened for that slice only
407
- const lessThanOnePerc = perc === 0 && amount > 0;
408
- if (lessThanOnePerc && (nextPerc < 8 || prevPerc < 8)) {
409
- inSmallCluster = true;
410
- }
411
- return inSmallCluster;
412
- }
413
- function getPathData(amount, offset, chartType) {
414
- const startAngle = amountToDegree(offset, this.total) - 90; // start at noon, not at 3 o'clock
415
- const activeAngle = (amount / this.total) * 360;
416
- let endAngle = startAngle + activeAngle;
417
- const largeArcFlagOuter = activeAngle > 180 ? "1 1" : "0 1";
418
- const largeArcFlagInner = activeAngle > 180 ? "1 0" : "0 0";
419
- const half = this.chartDetails.size / 2;
420
- const innerRadius = this.chartDetails.thickness;
421
- const outerRadius = 1;
422
- const isHybridDoughnut = chartType === "doughnut0" || chartType === "doughnut";
423
- const outerSeparatorOffset = 1.5;
424
- const innerSeparatorOffset = isHybridDoughnut ? 2.25 : 3;
425
- if (activeAngle === 360) {
426
- // fix to avoid bad svg shape when the path goes all around (100%)
427
- endAngle -= 0.01;
428
- }
429
- const outerCoords = polarToCartesian(half, outerRadius, startAngle + outerSeparatorOffset, // Addition for slice separator
430
- endAngle);
431
- const innerCoords = polarToCartesian(half, innerRadius, startAngle + innerSeparatorOffset, // Addition for slice separator
432
- endAngle);
433
- const moveTo = `M ${outerCoords.x1}, ${outerCoords.y1} `;
434
- const arc1 = getArc(outerRadius, largeArcFlagOuter, outerCoords.x2, outerCoords.y2, this.chartDetails.size);
435
- const line = ` L ${innerCoords.x2}, ${innerCoords.y2} `;
436
- const arc2 = getArc(innerRadius, largeArcFlagInner, innerCoords.x1, innerCoords.y1, this.chartDetails.size);
437
- return moveTo + arc1 + line + arc2 + " z";
438
- }
439
- export function renderInstructionsText() {
440
- const chartInstructions = intl.formatMessage({
441
- id: "chart.instructions",
442
- defaultMessage: "Use arrow keys to browse elements, press Tab to exit.",
443
- description: "For screen readers only, instructions on how to interact with the chart component",
444
- });
445
- return h("div", { id: "chart-instructions" }, chartInstructions);
446
- }
447
- function renderFilter() {
448
- return (h("defs", null, h("filter", { id: "wmHoverDropShadow" }, h("feGaussianBlur", { stdDeviation: "3" }), h("feOffset", { result: "offsetblur" }), h("feFlood", { "flood-color": "#333" }), h("feComposite", { operator: "in", in2: "offsetblur" }), h("feMerge", null, h("feMergeNode", null), h("feMergeNode", { in: "SourceGraphic" })))));
449
- }
450
- export function renderDoughnut(chartType) {
451
- const outerSize = this.chartDetails.size + this.chartDetails.padding;
452
- const isHybridDoughnut = chartType === "doughnut0" || chartType === "doughnut";
453
- // no sorting in progress indicators
454
- let slicesDetails = isHybridDoughnut ? this.slicesDetails : sortSlicesDetails(this.slicesDetails, this.total);
455
- return (h("div", { class: "chart-wrapper doughnut-wrapper" }, h("svg", { width: outerSize + "px", height: outerSize + "px", id: `graphic-${this.uid}`, class: "doughnut-svg" }, renderFilter(), slicesDetails.map((s) => renderPath.call(this, s, chartType)), isHybridDoughnut ? (h("text", { class: "value", x: "50%", y: "50%", "font-size": "1.5rem", "font-weight": "500", "text-anchor": "middle", "dominant-baseline": "middle" }, amountToPercent(slicesDetails[0].amount, this.total, true) + "%")) : (h("g", { transform: `translate(${this.chartDetails.padding / 2}, ${this.chartDetails.padding / 2})`, "text-anchor": "middle", "dominant-baseline": "middle" }, slicesDetails.map((s) => s.amount > 0 && !s.inSmallCluster ? renderDoughnutText.call(this, s) : ""))))));
456
- }
457
- function renderPath(s, chartType) {
458
- return (h("g", { transform: `translate(${this.chartDetails.padding / 2}, ${this.chartDetails.padding / 2})` }, h("path", { id: s.id, class: "segment doughnut-segment", fill: s.amount ? s.color : "transparent", d: getPathData.call(this, s.amount, s.offset, chartType), onClick: (ev) => handleSliceClick.call(this, ev, s), onFocus: (ev) => handleSliceFocus.call(this, ev, s), onKeyDown: (ev) => handleSliceKeyDown.call(this, ev), role: "img", "aria-label": s.legend })));
459
- }
460
- function renderDoughnutText(s) {
461
- const arcMiddle = amountToDegree(s.offset + s.amount / 2, this.total);
462
- let { x, y } = polarToCartesian(this.chartDetails.size / 2, 1.4, arcMiddle - 90);
463
- return (h("text", { class: "value", x: x + "px", y: y + "px" }, `${s.perc > 0 ? s.perc : "<1"}%`));
464
- }
465
- export function renderStackedBar(chartType) {
466
- const isHybridBar = chartType === "bar1" || chartType === "bar";
467
- return (h("div", { class: "chart-wrapper bar-wrapper" }, isHybridBar ? (h("div", { class: "single-perc" }, amountToPercent(this.slicesDetails[0].amount, this.total, true) + "%")) : (""), this.chartType === "bar3" && this.drawAxis(), h("div", { class: `inner-stacked-bar-wrapper ${showValue(this.tempValueFormat)}` }, !isHybridBar ? (h("div", { class: "values" }, this.slicesDetails.map((s, idx) => this.renderBarText(s, idx)))) : (""), h("div", { class: "stacked-bar-segments-wrapper" }, this.slicesDetails.map((s, idx) => renderStackedBarSegment.call(this, s, idx))), isHybridBar ? renderCompletionMessage.call(this) : "")));
468
- }
469
- function renderStackedBarSegment(s, idx) {
470
- const isLastSlice = idx !== this.slicesDetails.length - 1;
471
- const width = `calc(${amountToPercent(s.amount, this.total, false)}%${isLastSlice ? " - 2px" : ""})`;
472
- return (h("div", { class: `segment stacked-bar-segment ${amountToPercent(s.amount, this.total, false) === 0 ? "zero" : ""}`, style: {
473
- backgroundColor: s.color,
474
- width: width,
475
- }, onClick: (ev) => handleSliceClick.call(this, ev, s), onFocus: (ev) => handleSliceFocus.call(this, ev, s), onKeyDown: (ev) => handleSliceKeyDown.call(this, ev) }, h("span", { class: "sr-only" }, s.legend)));
476
- }
477
- export function renderSimpleBar(chartType) {
478
- // find largest number and get interval, numTicks, chartMaxVal for all.
479
- const largest = this.slicesDetails
480
- .map((s) => s.amount)
481
- .reduce((a, b) => {
482
- return a > b ? a : b;
483
- });
484
- const labelWidth = parseInt(getComputedStyle(this.el).getPropertyValue("--labelWidth"), 10);
485
- const chartPadding = 48;
486
- const componentWidth = this.el.getBoundingClientRect().width;
487
- const chartWidth = componentWidth - labelWidth - chartPadding;
488
- let numTicks = getMaxTicks(chartWidth);
489
- let interval = getInterval(largest, numTicks);
490
- // after the algorithm finds an interval, remove extra ticks so that the greater number is always between the last tick and the one before that
491
- const lastTickVal = numTicks * interval;
492
- const extraTicks = Math.floor((lastTickVal - largest) / interval);
493
- numTicks -= extraTicks;
494
- this.el.style.setProperty("--backgroundSize", 100 / numTicks + "%");
495
- this.el.style.setProperty("--labelWidth", this.labelWidth);
496
- if (chartType === "bar7" && !this.showBarLegend) {
497
- this.el.style.setProperty("--labelWidth", "0px");
498
- }
499
- // we have to prep the data here rather than iterate directly in the return statement
500
- // because CSS grid needs a flat structure, and return functions must
501
- // have a single parent element
502
- const rows = [];
503
- this.slicesDetails.forEach((s) => {
504
- s.legend && rows.push(renderSimpleBarLegend(s.legend, this.showBarLegend, chartType));
505
- rows.push(renderSimpleBarItem.call(this, s, interval, numTicks, largest));
506
- });
507
- const ticks = [];
508
- for (let i = 1; i <= numTicks; i++) {
509
- const tickVal = abbrNumber(i * interval);
510
- ticks.push(h("div", { class: "tick" }, h("span", null, tickVal)));
511
- }
512
- const showGrid = chartType === "bar6" && this.showGrid && this.el.getBoundingClientRect().width > 300;
513
- return (h("div", { class: "chart-wrapper simple-bar-wrapper" }, h("div", { class: `chart ${showValue(this.tempValueFormat)}` }, showGrid && h("div", { class: "gridlines" }), h("div", { class: "rows" }, rows)), showGrid && (h("div", { class: "x-axis", "aria-hidden": "true" }, h("div", { class: "zero" }, h("span", null, "0")), ticks))));
514
- }
515
- function renderSimpleBarLegend(legend, show, chartType) {
516
- // not sure how to collapse the left column to 0 width with CSS grid. text should still be available to SR.
517
- const hidden = chartType === "bar7" && !show ? " hidden" : "";
518
- return h("label", { class: `label${hidden}` }, legend);
519
- }
520
- function renderSimpleBarItem(s, interval, ticks, largest) {
521
- const chartMaxVal = this.currentChartType === "bar6" ? interval * ticks : largest;
522
- const width = amountToPercent(s.amount, chartMaxVal, false);
523
- const cssWidth = width ? width + "%" : "1px";
524
- const amt = abbrNumber(s.amount);
525
- let displayValue = this.tempValueFormat === "amount" ? amt : "";
526
- if (this.currentChartType === "bar6" && this.tempValueFormat === "percentage") {
527
- displayValue = s.amount + "%";
528
- }
529
- else if (this.currentChartType === "bar7" && this.tempValueFormat === "percentage") {
530
- displayValue = amountToPercent(s.amount, this.total, true) + "%";
531
- }
532
- return (h("div", { class: "bar segment", style: {
533
- backgroundColor: s.color,
534
- width: cssWidth,
535
- }, onClick: (ev) => handleSliceClick.call(this, ev, s), onFocus: (ev) => handleSliceFocus.call(this, ev, s), onKeyDown: (ev) => handleSliceKeyDown.call(this, ev) }, h("div", { class: "value" }, displayValue)));
536
- }
537
- export function renderLegend(chartType) {
538
- // legend is hidden for bar1 and bar6 types regardless of showLegend value
539
- if (this.showLegend) {
540
- const hasCluster = !this.chartDetails.isBar &&
541
- this.slicesDetails.reduce((hasCluster, cur) => (hasCluster = cur.inSmallCluster ? true : hasCluster), false);
542
- return (h("div", { class: "legend-wrapper" }, h("div", { class: `legend ${chartType} ${this.mode === "bar" ? "--top" : "--bottom"}`, "aria-hidden": "true" }, this.total > 0
543
- ? this.slicesDetails.map((s) => {
544
- // when both legend and amount are omitted, the legend is not shown for that particular option (it's been deactivated by the user)
545
- if (!!s.amount || !!s.legend) {
546
- return renderLegendItem({ key: s.legend, color: s.color });
547
- }
548
- })
549
- : ""), hasCluster && renderHiddenValuesMessage()));
550
- }
551
- }
552
- export function renderLegendItem(legendItem) {
553
- return (h("div", { class: "legend-item" }, h("div", { class: "legend-color", style: { backgroundColor: legendItem.color } }), h("div", { class: "legend-text" }, legendItem.key)));
554
- }
555
- export function renderCompletionMessage() {
556
- if (this.completionMessage) {
557
- return h("div", { class: "completion-message" }, this.completionMessage);
558
- }
559
- }
560
- export function renderHiddenValuesMessage() {
561
- return (h("div", { class: "hidden-values-warning" }, textHiddenMessage, h("br", null), seeDetailsMessage));
562
- }
1
+ import { h } from "@stencil/core";
2
+ import { checkForActiveElInShadow, debounce, findParentWithScrollbar, getPosition, intl } from "../../global/functions";
3
+ const colors = {
4
+ salmon: "#ff5f4e",
5
+ cyan: "#19a1a9",
6
+ forest: "#088000",
7
+ sleet: "#7f97ad",
8
+ midnight: "#2e1b46",
9
+ lavender: "#8b86ca",
10
+ periwinkle: "#575195",
11
+ gray: "#6b6b6b",
12
+ };
13
+ export const allChartsDetails = {
14
+ // for progress monitor
15
+ doughnut: {
16
+ size: 155,
17
+ colors: [colors.forest, colors.gray],
18
+ thickness: 0.73,
19
+ padding: 25,
20
+ category: "doughnut",
21
+ },
22
+ // deprecated hybrid chart type, should use Progress Indicator's "doughnut" instead
23
+ doughnut0: {
24
+ size: 155,
25
+ colors: [colors.forest, colors.gray],
26
+ thickness: 0.73,
27
+ padding: 25,
28
+ category: "doughnut",
29
+ },
30
+ doughnut1: {
31
+ size: 130,
32
+ colors: [colors.lavender, colors.midnight, colors.gray],
33
+ thickness: 0.5,
34
+ padding: 90,
35
+ category: "doughnut",
36
+ },
37
+ doughnut2: {
38
+ size: 130,
39
+ colors: [colors.cyan, colors.salmon, colors.gray],
40
+ thickness: 0.5,
41
+ padding: 90,
42
+ category: "doughnut",
43
+ },
44
+ // an internal type only for use when doughnut 2 is populated with 4 slices
45
+ // in this case, the first slice is colored purple
46
+ doughnut2b: {
47
+ size: 130,
48
+ colors: [colors.periwinkle, colors.cyan, colors.salmon, colors.gray],
49
+ thickness: 0.5,
50
+ padding: 90,
51
+ category: "doughnut",
52
+ },
53
+ doughnut3: {
54
+ size: 130,
55
+ colors: [colors.lavender, colors.midnight, "#0089e4", colors.forest, "#ea8500", "#d54f41", "#146ca9"],
56
+ thickness: 0.5,
57
+ padding: 90,
58
+ category: "doughnut",
59
+ },
60
+ // for progress monitor
61
+ bar: {
62
+ size: 350,
63
+ colors: [colors.forest, colors.gray],
64
+ padding: 0,
65
+ category: "stackedBar",
66
+ },
67
+ // deprecated hybrid chart type, should use Progress Indicator's "bar" instead
68
+ bar1: {
69
+ size: 350,
70
+ colors: [colors.forest, colors.gray],
71
+ padding: 0,
72
+ category: "stackedBar",
73
+ },
74
+ bar2: {
75
+ size: 400,
76
+ colors: [colors.gray, colors.periwinkle, colors.cyan, colors.salmon],
77
+ padding: 0,
78
+ category: "stackedBar",
79
+ },
80
+ bar2b: {
81
+ size: 400,
82
+ colors: [colors.gray, colors.periwinkle, colors.midnight, colors.cyan, colors.salmon],
83
+ padding: 0,
84
+ category: "stackedBar",
85
+ },
86
+ bar3: {
87
+ size: 300,
88
+ colors: ["#0d696e", colors.cyan, "#8e4129", colors.salmon],
89
+ padding: 0,
90
+ category: "stackedBar",
91
+ },
92
+ bar4: {
93
+ size: 400,
94
+ colors: [colors.salmon, colors.cyan, colors.periwinkle],
95
+ padding: 0,
96
+ category: "stackedBar",
97
+ },
98
+ bar5: {
99
+ size: 400,
100
+ colors: [
101
+ colors.gray,
102
+ colors.lavender,
103
+ colors.midnight,
104
+ "#0089e4",
105
+ colors.forest,
106
+ "#ea8500",
107
+ "#d54f41",
108
+ "#146ca9",
109
+ ],
110
+ padding: 0,
111
+ category: "stackedBar",
112
+ },
113
+ bar6: {
114
+ size: 400,
115
+ colors: [colors.lavender],
116
+ padding: 0,
117
+ category: "simpleBar",
118
+ },
119
+ bar7: {
120
+ size: 400,
121
+ colors: [colors.periwinkle, colors.cyan, colors.salmon, colors.gray],
122
+ padding: 0,
123
+ category: "simpleBar",
124
+ },
125
+ };
126
+ function showValue(valueFormat) {
127
+ return valueFormat === "percentage" || valueFormat === "amount" ? "show-values" : "";
128
+ }
129
+ export const textHiddenMessage = intl.formatMessage({
130
+ id: "chart.hiddenValues",
131
+ defaultMessage: "Values are not shown when too close to each other.",
132
+ description: "Text displayed when a chart has some values hidden",
133
+ });
134
+ export const seeDetailsMessage = intl.formatMessage({
135
+ id: "chart.clickToSeeDetails",
136
+ defaultMessage: "Click or use arrow keys to see details.",
137
+ description: "Text displayed, guiding user to interact to see more details.",
138
+ });
139
+ function abbrNumber(num) {
140
+ return num > 999 ? Math.round(num / 100) / 10 + "K" : num;
141
+ }
142
+ export function amountToPercent(val, total, asInt) {
143
+ return asInt ? Math.round((val * 100) / total) : Math.round((val * 10000) / total) / 100; // with 2 decimals
144
+ }
145
+ export function amountToDegree(val, total) {
146
+ // In a circle of {total}, determine degrees of slice {val}
147
+ return (val * 360) / total;
148
+ }
149
+ export function toFixed(number) {
150
+ return parseFloat((Math.floor(number * 100) / 100).toFixed(2));
151
+ }
152
+ export function polarToCartesian(half, radius, startAngle, endAngle) {
153
+ var x = toFixed(half + half * radius * Math.cos((Math.PI * startAngle) / 180));
154
+ var y = toFixed(half + half * radius * Math.sin((Math.PI * startAngle) / 180));
155
+ if (endAngle !== undefined) {
156
+ // if a 2nd angle value was passed, return 2 pairs of coords
157
+ var x2 = toFixed(half + half * radius * Math.cos((Math.PI * endAngle) / 180));
158
+ var y2 = toFixed(half + half * radius * Math.sin((Math.PI * endAngle) / 180));
159
+ return { x1: x, y1: y, x2, y2 };
160
+ }
161
+ return { x, y };
162
+ }
163
+ function getArc(radius, largeArcFlag, x, y, chartSize) {
164
+ var z = toFixed((chartSize / 2) * radius);
165
+ return `A ${z}, ${z} 0 ${largeArcFlag} ${toFixed(x)}, ${toFixed(y)}`;
166
+ }
167
+ function scale(val, inMin, inMax, outMin, outMax) {
168
+ let scaled = ((val - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin;
169
+ // clip the values so that whatever is passed in the output is never smaller than outMin or greater than outMax
170
+ return scaled < outMin ? outMin : scaled > outMax ? outMax : scaled;
171
+ }
172
+ function minSpacing(width) {
173
+ // minimum spacing between 2 ticks, in px
174
+ return scale(width, 300, 900, 70, 150);
175
+ }
176
+ function getMaxTicks(width) {
177
+ return Math.round(width / minSpacing(width));
178
+ }
179
+ function getInterval(largest, maxticks) {
180
+ const minimum = largest / maxticks;
181
+ const magnitude = 10 ** Math.floor(Math.log10(minimum));
182
+ const residual = minimum / magnitude;
183
+ let interval;
184
+ if (residual > 5) {
185
+ interval = 10 * magnitude;
186
+ }
187
+ else if (residual > 3) {
188
+ interval = 5 * magnitude;
189
+ }
190
+ else if (residual > 2) {
191
+ interval = 3 * magnitude;
192
+ }
193
+ else if (residual > 1.5) {
194
+ interval = 2 * magnitude;
195
+ }
196
+ else if (residual > 1) {
197
+ interval = 1.5 * magnitude;
198
+ }
199
+ else {
200
+ interval = magnitude;
201
+ }
202
+ return interval;
203
+ }
204
+ function handleSliceKeyDown(ev) {
205
+ if (this.popoverEl && this.popoverEl.open && ev.key === "Enter") {
206
+ const popoverBtn = this.popoverEl.querySelector("button");
207
+ popoverBtn && popoverBtn.click();
208
+ }
209
+ }
210
+ export function handleSliceClick(ev, s) {
211
+ if (this.popoverEl && !this.isTabbing) {
212
+ s.coords = { x: ev.clientX, y: ev.clientY };
213
+ openPopover.call(this, s);
214
+ }
215
+ }
216
+ function handleSliceFocus(ev, s) {
217
+ if (this.popoverEl && this.isTabbing) {
218
+ s.coords = getPosition(ev.target);
219
+ openPopover.call(this, s);
220
+ }
221
+ }
222
+ export function handleChartKeydown(ev) {
223
+ switch (ev.key) {
224
+ // arrow up / left
225
+ case "ArrowUp":
226
+ case "ArrowLeft":
227
+ ev.preventDefault();
228
+ this.isTabbing = true; // shd already be true. just in case user clicked on chart then pressed an arrow key
229
+ focusPrevious.call(this);
230
+ break;
231
+ // arrow right / down
232
+ case "ArrowRight":
233
+ case "ArrowDown":
234
+ ev.preventDefault();
235
+ this.isTabbing = true; // shd already be true. just in case user clicked on chart then pressed an arrow key
236
+ focusNext.call(this);
237
+ break;
238
+ // tab
239
+ case "Tab":
240
+ exitChart.call(this);
241
+ break;
242
+ case "Escape":
243
+ this.popoverEl.open = false;
244
+ this.userIsNavigating = false;
245
+ break;
246
+ }
247
+ }
248
+ export function openPopover(s) {
249
+ if (!!this.popoverEl && !!s.title && !!s.text) {
250
+ this.popoverEl.popoverTitle = s.title;
251
+ this.popoverEl.popoverText = s.text;
252
+ this.popoverEl.buttonText = s.buttonText;
253
+ this.popoverEl.coords = s.coords;
254
+ this.popoverEl.sliceRef = s.sliceRef;
255
+ window.setTimeout(() => {
256
+ if (this.popoverEl) {
257
+ this.popoverEl.open = true;
258
+ }
259
+ }, 30);
260
+ const debouncedClosePopover = debounce(async () => {
261
+ this.popoverEl.open = false;
262
+ }, 10);
263
+ // set up event listeners for scrolling
264
+ // to close popover on page scroll
265
+ document.addEventListener("scroll", () => {
266
+ debouncedClosePopover();
267
+ });
268
+ // ... and on parent scroll
269
+ const scrollableParent = findParentWithScrollbar(this.el);
270
+ if (!!scrollableParent) {
271
+ scrollableParent.addEventListener("scroll", () => {
272
+ debouncedClosePopover();
273
+ });
274
+ }
275
+ }
276
+ }
277
+ function focusNext() {
278
+ const activeEl = checkForActiveElInShadow(document.activeElement);
279
+ const index =
280
+ // if the active el is not in the array the first element gets focused
281
+ (this.sliceEls.indexOf(activeEl) + 1) % this.sliceEls.length;
282
+ focusSlice.call(this, index);
283
+ }
284
+ function focusPrevious() {
285
+ if (this.sliceEls) {
286
+ const activeEl = checkForActiveElInShadow(document.activeElement);
287
+ let index = this.sliceEls.indexOf(activeEl);
288
+ if (index === -1) {
289
+ // not in the array : focus the first slice
290
+ index = 0;
291
+ }
292
+ else if (index === 0) {
293
+ // first slice : focus the last slice
294
+ index = this.sliceEls.length - 1;
295
+ }
296
+ else {
297
+ // anything else: focus previous
298
+ index -= 1;
299
+ }
300
+ focusSlice.call(this, index);
301
+ }
302
+ }
303
+ function focusSlice(index) {
304
+ if (this.sliceEls && this.el) {
305
+ this.userIsNavigating = true;
306
+ if (this.popoverEl) {
307
+ this.popoverEl.open = false;
308
+ }
309
+ // set tabindex of the wrapper to -1 while slices are being focused, to allow for shft-tabbing out of the component directly
310
+ this.componentWrapperEl.tabIndex = -1;
311
+ // @ts-ignore
312
+ this.el.focusable = false; // for Edge
313
+ this.sliceEls.map((p) => {
314
+ p.tabIndex = -1;
315
+ // @ts-ignore
316
+ p.focusable = false; // for Edge
317
+ });
318
+ this.sliceEls[index].tabIndex = 0;
319
+ // @ts-ignore
320
+ this.sliceEls[index].focusable = true; // for Edge
321
+ this.sliceEls[index].focus();
322
+ window.setTimeout(() => {
323
+ if (this.popoverEl) {
324
+ this.popoverEl.open = true;
325
+ }
326
+ }, 10);
327
+ }
328
+ }
329
+ export function exitChart() {
330
+ this.sliceEls &&
331
+ this.sliceEls.map((p) => {
332
+ p.tabIndex = -1;
333
+ // @ts-ignore
334
+ p.focusable = false; // for Edge
335
+ });
336
+ this.userIsNavigating = false;
337
+ // delay so that we can tab out of component before chart becomes focusable again
338
+ // and in case user was still pressing an arrow key when they pressed tab
339
+ window.setTimeout(() => {
340
+ this.componentWrapperEl.tabIndex = 0;
341
+ // @ts-ignore
342
+ this.el.focusable = true; // for Edge
343
+ if (this.popoverEl) {
344
+ this.popoverEl.open = false;
345
+ }
346
+ }, 100);
347
+ }
348
+ export async function getDetails(chartType) {
349
+ this.slicesDetails = [];
350
+ let acc = 0;
351
+ const children = Array.from(this.el.children);
352
+ this.total = children.reduce((total, slice) => (total += parseInt(slice.getAttribute("amount") || "0")), 0);
353
+ children.forEach((c, i) => {
354
+ const amount = parseInt(c.getAttribute("amount") || "0");
355
+ const perc = amountToPercent(amount, this.total, true);
356
+ let colorIndex = i;
357
+ // for bar5, first color should be skipped unless notStartedColor is set to true
358
+ if (chartType === "bar5") {
359
+ colorIndex = this.notStartedColor ? i : i + 1;
360
+ }
361
+ // bars in bar6 are all the same color
362
+ if (chartType === "bar6") {
363
+ colorIndex = 0;
364
+ }
365
+ const color = allChartsDetails[chartType].colors[colorIndex];
366
+ const sliceDetails = {
367
+ amount: amount,
368
+ perc: perc,
369
+ legend: c.getAttribute("legend"),
370
+ color: color || colors.gray,
371
+ offset: acc,
372
+ id: `${this.uid}-${i + 1}`,
373
+ title: c.getAttribute("popover-title"),
374
+ text: c.getAttribute("popover-text"),
375
+ buttonText: c.getAttribute("popover-button-text"),
376
+ sliceRef: c,
377
+ inSmallCluster: false,
378
+ };
379
+ acc += amount;
380
+ this.slicesDetails.push(sliceDetails);
381
+ });
382
+ }
383
+ function sortSlicesDetails(slicesDetails, total) {
384
+ // sort slices by decreasing amount
385
+ let sortedSlicesDetails = [...slicesDetails].sort((a, b) => a.amount === b.amount ? 0 : a.amount > b.amount ? -1 : 1);
386
+ let acc = 0;
387
+ sortedSlicesDetails.forEach((s, idx) => {
388
+ const prev = sortedSlicesDetails[idx === 0 ? sortedSlicesDetails.length - 1 : idx - 1];
389
+ const next = sortedSlicesDetails[idx === sortedSlicesDetails.length - 1 ? 0 : idx + 1];
390
+ const prevPerc = amountToPercent(prev.amount, total, true);
391
+ const nextPerc = amountToPercent(next.amount, total, true);
392
+ s.offset = acc;
393
+ acc += s.amount;
394
+ s.inSmallCluster = isInSmallCluster(prevPerc, s.perc, s.amount, nextPerc);
395
+ });
396
+ return sortedSlicesDetails;
397
+ }
398
+ function isInSmallCluster(prevPerc, perc, amount, nextPerc) {
399
+ // determine whether the slice is in a cluster of small values
400
+ // to avoid percentage text overlap for small values
401
+ const isSmall = perc < 4;
402
+ const prevIsSmall = prevPerc < 5;
403
+ const nextIsSmall = nextPerc < 5;
404
+ let inSmallCluster = isSmall && (prevIsSmall || nextIsSmall);
405
+ // because <1% slice percentage text has an additional character
406
+ // the inSmallCluster threshold needs to be widened for that slice only
407
+ const lessThanOnePerc = perc === 0 && amount > 0;
408
+ if (lessThanOnePerc && (nextPerc < 8 || prevPerc < 8)) {
409
+ inSmallCluster = true;
410
+ }
411
+ return inSmallCluster;
412
+ }
413
+ function getPathData(amount, offset, chartType) {
414
+ const startAngle = amountToDegree(offset, this.total) - 90; // start at noon, not at 3 o'clock
415
+ const activeAngle = (amount / this.total) * 360;
416
+ let endAngle = startAngle + activeAngle;
417
+ const largeArcFlagOuter = activeAngle > 180 ? "1 1" : "0 1";
418
+ const largeArcFlagInner = activeAngle > 180 ? "1 0" : "0 0";
419
+ const half = this.chartDetails.size / 2;
420
+ const innerRadius = this.chartDetails.thickness;
421
+ const outerRadius = 1;
422
+ const isHybridDoughnut = chartType === "doughnut0" || chartType === "doughnut";
423
+ const outerSeparatorOffset = 1.5;
424
+ const innerSeparatorOffset = isHybridDoughnut ? 2.25 : 3;
425
+ if (activeAngle === 360) {
426
+ // fix to avoid bad svg shape when the path goes all around (100%)
427
+ endAngle -= 0.01;
428
+ }
429
+ const outerCoords = polarToCartesian(half, outerRadius, startAngle + outerSeparatorOffset, // Addition for slice separator
430
+ endAngle);
431
+ const innerCoords = polarToCartesian(half, innerRadius, startAngle + innerSeparatorOffset, // Addition for slice separator
432
+ endAngle);
433
+ const moveTo = `M ${outerCoords.x1}, ${outerCoords.y1} `;
434
+ const arc1 = getArc(outerRadius, largeArcFlagOuter, outerCoords.x2, outerCoords.y2, this.chartDetails.size);
435
+ const line = ` L ${innerCoords.x2}, ${innerCoords.y2} `;
436
+ const arc2 = getArc(innerRadius, largeArcFlagInner, innerCoords.x1, innerCoords.y1, this.chartDetails.size);
437
+ return moveTo + arc1 + line + arc2 + " z";
438
+ }
439
+ export function renderInstructionsText() {
440
+ const chartInstructions = intl.formatMessage({
441
+ id: "chart.instructions",
442
+ defaultMessage: "Use arrow keys to browse elements, press Tab to exit.",
443
+ description: "For screen readers only, instructions on how to interact with the chart component",
444
+ });
445
+ return h("div", { id: "chart-instructions" }, chartInstructions);
446
+ }
447
+ function renderFilter() {
448
+ return (h("defs", null, h("filter", { id: "wmHoverDropShadow" }, h("feGaussianBlur", { stdDeviation: "3" }), h("feOffset", { result: "offsetblur" }), h("feFlood", { "flood-color": "#333" }), h("feComposite", { operator: "in", in2: "offsetblur" }), h("feMerge", null, h("feMergeNode", null), h("feMergeNode", { in: "SourceGraphic" })))));
449
+ }
450
+ export function renderDoughnut(chartType) {
451
+ const outerSize = this.chartDetails.size + this.chartDetails.padding;
452
+ const isHybridDoughnut = chartType === "doughnut0" || chartType === "doughnut";
453
+ // no sorting in progress indicators
454
+ let slicesDetails = isHybridDoughnut ? this.slicesDetails : sortSlicesDetails(this.slicesDetails, this.total);
455
+ return (h("div", { class: "chart-wrapper doughnut-wrapper" }, h("svg", { width: outerSize + "px", height: outerSize + "px", id: `graphic-${this.uid}`, class: "doughnut-svg" }, renderFilter(), slicesDetails.map((s) => renderPath.call(this, s, chartType)), isHybridDoughnut ? (h("text", { class: "value", x: "50%", y: "50%", "font-size": "1.5rem", "font-weight": "500", "text-anchor": "middle", "dominant-baseline": "middle" }, amountToPercent(slicesDetails[0].amount, this.total, true) + "%")) : (h("g", { transform: `translate(${this.chartDetails.padding / 2}, ${this.chartDetails.padding / 2})`, "text-anchor": "middle", "dominant-baseline": "middle" }, slicesDetails.map((s) => s.amount > 0 && !s.inSmallCluster ? renderDoughnutText.call(this, s) : ""))))));
456
+ }
457
+ function renderPath(s, chartType) {
458
+ return (h("g", { transform: `translate(${this.chartDetails.padding / 2}, ${this.chartDetails.padding / 2})` }, h("path", { id: s.id, class: "segment doughnut-segment", fill: s.amount ? s.color : "transparent", d: getPathData.call(this, s.amount, s.offset, chartType), onClick: (ev) => handleSliceClick.call(this, ev, s), onFocus: (ev) => handleSliceFocus.call(this, ev, s), onKeyDown: (ev) => handleSliceKeyDown.call(this, ev), role: "img", "aria-label": s.legend })));
459
+ }
460
+ function renderDoughnutText(s) {
461
+ const arcMiddle = amountToDegree(s.offset + s.amount / 2, this.total);
462
+ let { x, y } = polarToCartesian(this.chartDetails.size / 2, 1.4, arcMiddle - 90);
463
+ return (h("text", { class: "value", x: x + "px", y: y + "px" }, `${s.perc > 0 ? s.perc : "<1"}%`));
464
+ }
465
+ export function renderStackedBar(chartType) {
466
+ const isHybridBar = chartType === "bar1" || chartType === "bar";
467
+ return (h("div", { class: "chart-wrapper bar-wrapper" }, isHybridBar ? (h("div", { class: "single-perc" }, amountToPercent(this.slicesDetails[0].amount, this.total, true) + "%")) : (""), this.chartType === "bar3" && this.drawAxis(), h("div", { class: `inner-stacked-bar-wrapper ${showValue(this.tempValueFormat)}` }, !isHybridBar ? (h("div", { class: "values" }, this.slicesDetails.map((s, idx) => this.renderBarText(s, idx)))) : (""), h("div", { class: "stacked-bar-segments-wrapper" }, this.slicesDetails.map((s, idx) => renderStackedBarSegment.call(this, s, idx))), isHybridBar ? renderCompletionMessage.call(this) : "")));
468
+ }
469
+ function renderStackedBarSegment(s, idx) {
470
+ const isLastSlice = idx !== this.slicesDetails.length - 1;
471
+ const width = `calc(${amountToPercent(s.amount, this.total, false)}%${isLastSlice ? " - 2px" : ""})`;
472
+ return (h("div", { class: `segment stacked-bar-segment ${amountToPercent(s.amount, this.total, false) === 0 ? "zero" : ""}`, style: {
473
+ backgroundColor: s.color,
474
+ width: width,
475
+ }, onClick: (ev) => handleSliceClick.call(this, ev, s), onFocus: (ev) => handleSliceFocus.call(this, ev, s), onKeyDown: (ev) => handleSliceKeyDown.call(this, ev) }, h("span", { class: "sr-only" }, s.legend)));
476
+ }
477
+ export function renderSimpleBar(chartType) {
478
+ // find largest number and get interval, numTicks, chartMaxVal for all.
479
+ const largest = this.slicesDetails
480
+ .map((s) => s.amount)
481
+ .reduce((a, b) => {
482
+ return a > b ? a : b;
483
+ });
484
+ const labelWidth = parseInt(getComputedStyle(this.el).getPropertyValue("--labelWidth"), 10);
485
+ const chartPadding = 48;
486
+ const componentWidth = this.el.getBoundingClientRect().width;
487
+ const chartWidth = componentWidth - labelWidth - chartPadding;
488
+ let numTicks = getMaxTicks(chartWidth);
489
+ let interval = getInterval(largest, numTicks);
490
+ // after the algorithm finds an interval, remove extra ticks so that the greater number is always between the last tick and the one before that
491
+ const lastTickVal = numTicks * interval;
492
+ const extraTicks = Math.floor((lastTickVal - largest) / interval);
493
+ numTicks -= extraTicks;
494
+ this.el.style.setProperty("--backgroundSize", 100 / numTicks + "%");
495
+ this.el.style.setProperty("--labelWidth", this.labelWidth);
496
+ if (chartType === "bar7" && !this.showBarLegend) {
497
+ this.el.style.setProperty("--labelWidth", "0px");
498
+ }
499
+ // we have to prep the data here rather than iterate directly in the return statement
500
+ // because CSS grid needs a flat structure, and return functions must
501
+ // have a single parent element
502
+ const rows = [];
503
+ this.slicesDetails.forEach((s) => {
504
+ s.legend && rows.push(renderSimpleBarLegend(s.legend, this.showBarLegend, chartType));
505
+ rows.push(renderSimpleBarItem.call(this, s, interval, numTicks, largest));
506
+ });
507
+ const ticks = [];
508
+ for (let i = 1; i <= numTicks; i++) {
509
+ const tickVal = abbrNumber(i * interval);
510
+ ticks.push(h("div", { class: "tick" }, h("span", null, tickVal)));
511
+ }
512
+ const showGrid = chartType === "bar6" && this.showGrid && this.el.getBoundingClientRect().width > 300;
513
+ return (h("div", { class: "chart-wrapper simple-bar-wrapper" }, h("div", { class: `chart ${showValue(this.tempValueFormat)}` }, showGrid && h("div", { class: "gridlines" }), h("div", { class: "rows" }, rows)), showGrid && (h("div", { class: "x-axis", "aria-hidden": "true" }, h("div", { class: "zero" }, h("span", null, "0")), ticks))));
514
+ }
515
+ function renderSimpleBarLegend(legend, show, chartType) {
516
+ // not sure how to collapse the left column to 0 width with CSS grid. text should still be available to SR.
517
+ const hidden = chartType === "bar7" && !show ? " hidden" : "";
518
+ return h("label", { class: `label${hidden}` }, legend);
519
+ }
520
+ function renderSimpleBarItem(s, interval, ticks, largest) {
521
+ const chartMaxVal = this.currentChartType === "bar6" ? interval * ticks : largest;
522
+ const width = amountToPercent(s.amount, chartMaxVal, false);
523
+ const cssWidth = width ? width + "%" : "1px";
524
+ const amt = abbrNumber(s.amount);
525
+ let displayValue = this.tempValueFormat === "amount" ? amt : "";
526
+ if (this.currentChartType === "bar6" && this.tempValueFormat === "percentage") {
527
+ displayValue = s.amount + "%";
528
+ }
529
+ else if (this.currentChartType === "bar7" && this.tempValueFormat === "percentage") {
530
+ displayValue = amountToPercent(s.amount, this.total, true) + "%";
531
+ }
532
+ return (h("div", { class: "bar segment", style: {
533
+ backgroundColor: s.color,
534
+ width: cssWidth,
535
+ }, onClick: (ev) => handleSliceClick.call(this, ev, s), onFocus: (ev) => handleSliceFocus.call(this, ev, s), onKeyDown: (ev) => handleSliceKeyDown.call(this, ev) }, h("div", { class: "value" }, displayValue)));
536
+ }
537
+ export function renderLegend(chartType) {
538
+ // legend is hidden for bar1 and bar6 types regardless of showLegend value
539
+ if (this.showLegend) {
540
+ const hasCluster = !this.chartDetails.isBar &&
541
+ this.slicesDetails.reduce((hasCluster, cur) => (hasCluster = cur.inSmallCluster ? true : hasCluster), false);
542
+ return (h("div", { class: "legend-wrapper" }, h("div", { class: `legend ${chartType} ${this.mode === "bar" ? "--top" : "--bottom"}`, "aria-hidden": "true" }, this.total > 0
543
+ ? this.slicesDetails.map((s) => {
544
+ // when both legend and amount are omitted, the legend is not shown for that particular option (it's been deactivated by the user)
545
+ if (!!s.amount || !!s.legend) {
546
+ return renderLegendItem({ key: s.legend, color: s.color });
547
+ }
548
+ })
549
+ : ""), hasCluster && renderHiddenValuesMessage()));
550
+ }
551
+ }
552
+ export function renderLegendItem(legendItem) {
553
+ return (h("div", { class: "legend-item" }, h("div", { class: "legend-color", style: { backgroundColor: legendItem.color } }), h("div", { class: "legend-text" }, legendItem.key)));
554
+ }
555
+ export function renderCompletionMessage() {
556
+ if (this.completionMessage) {
557
+ return h("div", { class: "completion-message" }, this.completionMessage);
558
+ }
559
+ }
560
+ export function renderHiddenValuesMessage() {
561
+ return (h("div", { class: "hidden-values-warning" }, textHiddenMessage, h("br", null), seeDetailsMessage));
562
+ }