@watermarkinsights/ripple 3.4.0 → 3.5.0-3

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 (203) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/functions-653e695c.js +6164 -0
  3. package/dist/cjs/{global-caec45e5.js → global-ee710089.js} +65 -65
  4. package/dist/cjs/{http-service-9e8c4dd5.js → http-service-494d81de.js} +49 -49
  5. package/dist/cjs/{index-921ef454.js → index-cd179539.js} +157 -103
  6. package/dist/cjs/{interfaces-30a74c1f.js → interfaces-a3338581.js} +29 -29
  7. package/dist/cjs/loader.cjs.js +3 -3
  8. package/dist/cjs/priv-chart-popover.cjs.entry.js +79 -79
  9. package/dist/cjs/priv-datepicker.cjs.entry.js +668 -668
  10. package/dist/cjs/priv-navigator-button.cjs.entry.js +19 -19
  11. package/dist/cjs/priv-navigator-item.cjs.entry.js +24 -24
  12. package/dist/cjs/ripple.cjs.js +5 -5
  13. package/dist/cjs/wm-action-menu_2.cjs.entry.js +342 -342
  14. package/dist/cjs/wm-button.cjs.entry.js +219 -219
  15. package/dist/cjs/wm-chart-slice.cjs.entry.js +14 -14
  16. package/dist/cjs/wm-chart.cjs.entry.js +475 -517
  17. package/dist/cjs/wm-datepicker.cjs.entry.js +257 -257
  18. package/dist/cjs/wm-input.cjs.entry.js +134 -134
  19. package/dist/cjs/wm-modal-footer.cjs.entry.js +32 -32
  20. package/dist/cjs/wm-modal-header.cjs.entry.js +35 -35
  21. package/dist/cjs/wm-modal.cjs.entry.js +162 -162
  22. package/dist/cjs/wm-navigator.cjs.entry.js +269 -269
  23. package/dist/cjs/wm-network-uploader.cjs.entry.js +421 -421
  24. package/dist/cjs/wm-option_2.cjs.entry.js +492 -492
  25. package/dist/cjs/wm-pagination.cjs.entry.js +168 -168
  26. package/dist/cjs/wm-search.cjs.entry.js +232 -232
  27. package/dist/cjs/wm-snackbar.cjs.entry.js +171 -171
  28. package/dist/cjs/wm-tab-item_3.cjs.entry.js +301 -301
  29. package/dist/cjs/wm-tag-input.cjs.entry.js +557 -557
  30. package/dist/cjs/wm-timepicker.cjs.entry.js +384 -384
  31. package/dist/cjs/wm-toggletip.cjs.entry.js +125 -125
  32. package/dist/cjs/wm-uploader.cjs.entry.js +347 -347
  33. package/dist/cjs/wm-wrapper.cjs.entry.js +13 -13
  34. package/dist/collection/collection-manifest.json +2 -2
  35. package/dist/collection/components/wm-action-menu/wm-action-menu.js +460 -460
  36. package/dist/collection/components/wm-button/wm-button.js +485 -485
  37. package/dist/collection/components/wm-chart/priv-chart-popover/priv-chart-popover.js +232 -232
  38. package/dist/collection/components/wm-chart/wm-chart-slice.js +64 -64
  39. package/dist/collection/components/wm-chart/wm-chart.css +71 -84
  40. package/dist/collection/components/wm-chart/wm-chart.js +718 -765
  41. package/dist/collection/components/wm-datepicker/priv-datepicker/priv-datepicker.js +1015 -1015
  42. package/dist/collection/components/wm-datepicker/wm-datepicker.js +462 -462
  43. package/dist/collection/components/wm-input/wm-input.js +423 -423
  44. package/dist/collection/components/wm-menuitem/wm-menuitem.js +444 -444
  45. package/dist/collection/components/wm-modal/wm-modal-footer.js +141 -141
  46. package/dist/collection/components/wm-modal/wm-modal-header.js +92 -92
  47. package/dist/collection/components/wm-modal/wm-modal.js +459 -459
  48. package/dist/collection/components/wm-navigator/priv-navigator-button/priv-navigator-button.js +97 -97
  49. package/dist/collection/components/wm-navigator/priv-navigator-item/priv-navigator-item.js +114 -114
  50. package/dist/collection/components/wm-navigator/wm-navigator.js +468 -468
  51. package/dist/collection/components/wm-option/wm-option.js +422 -422
  52. package/dist/collection/components/wm-pagination/wm-pagination.js +368 -368
  53. package/dist/collection/components/wm-search/wm-search.js +479 -479
  54. package/dist/collection/components/wm-select/wm-select.js +717 -717
  55. package/dist/collection/components/wm-snackbar/wm-snackbar.js +297 -297
  56. package/dist/collection/components/wm-tabs/wm-tab-item/wm-tab-item.js +219 -219
  57. package/dist/collection/components/wm-tabs/wm-tab-list/wm-tab-list.js +331 -331
  58. package/dist/collection/components/wm-tabs/wm-tab-panel/wm-tab-panel.js +104 -104
  59. package/dist/collection/components/wm-tag-input/wm-tag-input.js +787 -787
  60. package/dist/collection/components/wm-timepicker/wm-timepicker.js +589 -589
  61. package/dist/collection/components/wm-toggletip/wm-toggletip.js +241 -241
  62. package/dist/collection/components/wm-uploader/wm-network-uploader/wm-network-uploader.js +753 -753
  63. package/dist/collection/components/wm-uploader/wm-uploader.js +748 -748
  64. package/dist/collection/components/wm-wrapper/wm-wrapper.js +27 -27
  65. package/dist/collection/dev/scripts.js +20 -20
  66. package/dist/collection/global/__mocks__/functions.js +6 -6
  67. package/dist/collection/global/functions.js +445 -445
  68. package/dist/collection/global/global.js +72 -72
  69. package/dist/collection/global/interfaces.js +49 -49
  70. package/dist/collection/global/services/__mocks__/http-service.js +130 -130
  71. package/dist/collection/global/services/http-service.js +50 -50
  72. package/dist/collection/lang/lang.js +5 -5
  73. package/dist/collection/lang/piglatin.js +93 -93
  74. package/dist/esm/functions-e528c934.js +6144 -0
  75. package/dist/esm/{global-08ca269c.js → global-b94f59e6.js} +65 -65
  76. package/dist/esm/{http-service-5d037e16.js → http-service-3dc3b3e7.js} +49 -49
  77. package/dist/esm/{index-f8b130b6.js → index-66f8130e.js} +157 -103
  78. package/dist/esm/{interfaces-61c6305b.js → interfaces-2b97fab2.js} +29 -29
  79. package/dist/esm/loader.js +3 -3
  80. package/dist/esm/polyfills/core-js.js +0 -0
  81. package/dist/esm/polyfills/dom.js +0 -0
  82. package/dist/esm/polyfills/es5-html-element.js +0 -0
  83. package/dist/esm/polyfills/index.js +2 -2
  84. package/dist/esm/polyfills/system.js +0 -0
  85. package/dist/esm/priv-chart-popover.entry.js +79 -79
  86. package/dist/esm/priv-datepicker.entry.js +668 -668
  87. package/dist/esm/priv-navigator-button.entry.js +19 -19
  88. package/dist/esm/priv-navigator-item.entry.js +24 -24
  89. package/dist/esm/ripple.js +5 -5
  90. package/dist/esm/wm-action-menu_2.entry.js +342 -342
  91. package/dist/esm/wm-button.entry.js +219 -219
  92. package/dist/esm/wm-chart-slice.entry.js +14 -14
  93. package/dist/esm/wm-chart.entry.js +475 -517
  94. package/dist/esm/wm-datepicker.entry.js +257 -257
  95. package/dist/esm/wm-input.entry.js +134 -134
  96. package/dist/esm/wm-modal-footer.entry.js +32 -32
  97. package/dist/esm/wm-modal-header.entry.js +35 -35
  98. package/dist/esm/wm-modal.entry.js +162 -162
  99. package/dist/esm/wm-navigator.entry.js +269 -269
  100. package/dist/esm/wm-network-uploader.entry.js +421 -421
  101. package/dist/esm/wm-option_2.entry.js +492 -492
  102. package/dist/esm/wm-pagination.entry.js +168 -168
  103. package/dist/esm/wm-search.entry.js +232 -232
  104. package/dist/esm/wm-snackbar.entry.js +171 -171
  105. package/dist/esm/wm-tab-item_3.entry.js +301 -301
  106. package/dist/esm/wm-tag-input.entry.js +557 -557
  107. package/dist/esm/wm-timepicker.entry.js +384 -384
  108. package/dist/esm/wm-toggletip.entry.js +125 -125
  109. package/dist/esm/wm-uploader.entry.js +347 -347
  110. package/dist/esm/wm-wrapper.entry.js +13 -13
  111. package/dist/ripple/p-092b01f3.entry.js +1 -0
  112. package/dist/ripple/{p-c995acbc.entry.js → p-0c58f50d.entry.js} +1 -1
  113. package/dist/ripple/p-11c09317.entry.js +1 -0
  114. package/dist/ripple/p-1e0c41a9.entry.js +1 -0
  115. package/dist/ripple/p-3003d26d.entry.js +1 -0
  116. package/dist/ripple/p-33524565.entry.js +1 -0
  117. package/dist/ripple/{p-888bec42.js → p-43f1298b.js} +0 -0
  118. package/dist/ripple/{p-5e49aba7.entry.js → p-4cc71463.entry.js} +1 -1
  119. package/dist/ripple/p-588b4475.js +16 -0
  120. package/dist/ripple/p-65e3a656.entry.js +1 -0
  121. package/dist/ripple/p-7a96bb97.js +1 -0
  122. package/dist/ripple/p-83b8aaaf.entry.js +1 -0
  123. package/dist/ripple/p-8923b7d0.entry.js +1 -0
  124. package/dist/ripple/{p-d52033d5.entry.js → p-8b0eb05e.entry.js} +1 -1
  125. package/dist/ripple/p-8cd1396e.entry.js +1 -0
  126. package/dist/ripple/{p-22a1a636.entry.js → p-99db8501.entry.js} +1 -1
  127. package/dist/ripple/p-9baa3039.js +1 -0
  128. package/dist/ripple/p-aa973691.entry.js +1 -0
  129. package/dist/ripple/{p-a61977b2.entry.js → p-b3d5ea85.entry.js} +1 -1
  130. package/dist/ripple/{p-7d009793.entry.js → p-b5189f72.entry.js} +1 -1
  131. package/dist/ripple/p-bc27b604.entry.js +1 -0
  132. package/dist/ripple/p-bc9ca97b.entry.js +1 -0
  133. package/dist/ripple/{p-bba99fcd.entry.js → p-cd58a15c.entry.js} +1 -1
  134. package/dist/ripple/p-dc9c9fda.entry.js +1 -0
  135. package/dist/ripple/p-e7616311.entry.js +1 -0
  136. package/dist/ripple/p-e9e8334e.entry.js +1 -0
  137. package/dist/ripple/p-ec9697db.entry.js +1 -0
  138. package/dist/ripple/p-efdaf3b6.entry.js +1 -0
  139. package/dist/ripple/p-fcdc6395.entry.js +1 -0
  140. package/dist/ripple/{p-a6d6eae7.js → p-fd8070fb.js} +0 -0
  141. package/dist/ripple/ripple.esm.js +1 -1
  142. package/dist/types/components/wm-action-menu/wm-action-menu.d.ts +48 -48
  143. package/dist/types/components/wm-button/wm-button.d.ts +44 -44
  144. package/dist/types/components/wm-chart/priv-chart-popover/priv-chart-popover.d.ts +23 -23
  145. package/dist/types/components/wm-chart/wm-chart-slice.d.ts +8 -8
  146. package/dist/types/components/wm-chart/wm-chart.d.ts +81 -80
  147. package/dist/types/components/wm-datepicker/priv-datepicker/priv-datepicker.d.ts +76 -76
  148. package/dist/types/components/wm-datepicker/wm-datepicker.d.ts +41 -41
  149. package/dist/types/components/wm-input/wm-input.d.ts +46 -46
  150. package/dist/types/components/wm-menuitem/wm-menuitem.d.ts +34 -34
  151. package/dist/types/components/wm-modal/wm-modal-footer.d.ts +15 -15
  152. package/dist/types/components/wm-modal/wm-modal-header.d.ts +12 -12
  153. package/dist/types/components/wm-modal/wm-modal.d.ts +41 -41
  154. package/dist/types/components/wm-navigator/priv-navigator-button/priv-navigator-button.d.ts +10 -10
  155. package/dist/types/components/wm-navigator/priv-navigator-item/priv-navigator-item.d.ts +13 -13
  156. package/dist/types/components/wm-navigator/wm-navigator.d.ts +61 -61
  157. package/dist/types/components/wm-option/wm-option.d.ts +32 -32
  158. package/dist/types/components/wm-pagination/wm-pagination.d.ts +32 -32
  159. package/dist/types/components/wm-search/wm-search.d.ts +86 -86
  160. package/dist/types/components/wm-select/wm-select.d.ts +66 -66
  161. package/dist/types/components/wm-snackbar/wm-snackbar.d.ts +35 -35
  162. package/dist/types/components/wm-tabs/wm-tab-item/wm-tab-item.d.ts +38 -38
  163. package/dist/types/components/wm-tabs/wm-tab-list/wm-tab-list.d.ts +53 -53
  164. package/dist/types/components/wm-tabs/wm-tab-panel/wm-tab-panel.d.ts +20 -20
  165. package/dist/types/components/wm-tag-input/wm-tag-input.d.ts +91 -91
  166. package/dist/types/components/wm-timepicker/wm-timepicker.d.ts +62 -62
  167. package/dist/types/components/wm-toggletip/wm-toggletip.d.ts +27 -27
  168. package/dist/types/components/wm-uploader/wm-network-uploader/wm-network-uploader.d.ts +85 -85
  169. package/dist/types/components/wm-uploader/wm-uploader.d.ts +80 -80
  170. package/dist/types/components/wm-wrapper/wm-wrapper.d.ts +7 -7
  171. package/dist/types/components.d.ts +24 -24
  172. package/dist/types/global/__mocks__/functions.d.ts +6 -6
  173. package/dist/types/global/functions.d.ts +40 -0
  174. package/dist/types/global/global.d.ts +1 -1
  175. package/dist/types/global/interfaces.d.ts +34 -34
  176. package/dist/types/global/services/__mocks__/http-service.d.ts +6 -6
  177. package/dist/types/global/services/http-service.d.ts +4 -4
  178. package/dist/types/lang/lang.d.ts +5 -5
  179. package/dist/types/stencil-public-runtime.d.ts +194 -186
  180. package/package.json +46 -46
  181. package/dist/cjs/functions-a6491ba8.js +0 -7943
  182. package/dist/esm/functions-5aebd578.js +0 -7923
  183. package/dist/ripple/p-0865e7cf.js +0 -16
  184. package/dist/ripple/p-0f663e59.entry.js +0 -1
  185. package/dist/ripple/p-1b790a7d.entry.js +0 -1
  186. package/dist/ripple/p-3b4c01b8.entry.js +0 -1
  187. package/dist/ripple/p-54c1f704.entry.js +0 -1
  188. package/dist/ripple/p-76c615e9.entry.js +0 -1
  189. package/dist/ripple/p-7d993d52.js +0 -1
  190. package/dist/ripple/p-8198cc9c.entry.js +0 -1
  191. package/dist/ripple/p-839d35bd.entry.js +0 -1
  192. package/dist/ripple/p-8708b8cb.entry.js +0 -1
  193. package/dist/ripple/p-8bd66955.entry.js +0 -1
  194. package/dist/ripple/p-957e3a05.entry.js +0 -1
  195. package/dist/ripple/p-af6eb4d5.entry.js +0 -1
  196. package/dist/ripple/p-b3f9f575.entry.js +0 -1
  197. package/dist/ripple/p-cd30198d.entry.js +0 -1
  198. package/dist/ripple/p-d9d6bf11.js +0 -1
  199. package/dist/ripple/p-e097c562.entry.js +0 -1
  200. package/dist/ripple/p-e9db6122.entry.js +0 -1
  201. package/dist/ripple/p-eabbd1e9.entry.js +0 -1
  202. package/dist/ripple/p-ec496b8b.entry.js +0 -1
  203. package/dist/ripple/p-fc8ec142.entry.js +0 -1
@@ -1,765 +1,718 @@
1
- import { Component, Element, h, Host, Prop, State, Listen } from "@stencil/core";
2
- import { forceUpdate } from "@stencil/core";
3
- import { debounce, generateId, checkForActiveElInShadow, getPosition, intl, findParentWithScrollbar, } from "../../global/functions";
4
- export class Chart {
5
- constructor() {
6
- this.chartType = "doughnut1";
7
- this.showLegend = true;
8
- this.notStartedColor = false;
9
- // left labels are a temporary solution for the lack of a stacked bar chart and is undocumented
10
- // it only works with bar4 and should be used without a legend
11
- this.labelPosition = "top";
12
- this.isTabbing = false;
13
- this.uid = generateId();
14
- this.slicesData = [];
15
- this.colors = {
16
- salmon: "#ff5f4e",
17
- cyan: "#19a1a9",
18
- sleet: "#7f97ad",
19
- midnight: "#2e1b46",
20
- lavender: "#8b86ca",
21
- };
22
- this.types = {
23
- doughnut0: {
24
- size: 155,
25
- colors: [this.colors.cyan, "#bfbfbf"],
26
- thickness: 0.73,
27
- padding: 25,
28
- isBar: false,
29
- },
30
- doughnut1: {
31
- size: 130,
32
- colors: [this.colors.lavender, this.colors.midnight, "#d4d4d4"],
33
- thickness: 0.5,
34
- padding: 90,
35
- isBar: false,
36
- },
37
- doughnut2: {
38
- size: 130,
39
- colors: [this.colors.cyan, this.colors.salmon, "#d4d4d4"],
40
- thickness: 0.5,
41
- padding: 90,
42
- isBar: false,
43
- },
44
- doughnut3: {
45
- size: 130,
46
- colors: [this.colors.lavender, this.colors.midnight, "#919834", "#c177cf", "#c16e00", "#029af2", "#2a6993"],
47
- thickness: 0.5,
48
- padding: 90,
49
- isBar: false,
50
- },
51
- bar1: {
52
- size: 350,
53
- colors: [this.colors.cyan, "#bfbfbf"],
54
- padding: 0,
55
- isBar: true,
56
- },
57
- bar2: {
58
- size: 400,
59
- colors: ["#d4d4d4", this.colors.sleet, this.colors.cyan, this.colors.salmon],
60
- padding: 0,
61
- isBar: true,
62
- },
63
- bar3: {
64
- size: 300,
65
- colors: ["#0d696e", this.colors.cyan, "#8e4129", this.colors.salmon],
66
- padding: 0,
67
- isBar: true,
68
- },
69
- bar4: {
70
- size: 400,
71
- colors: ["#d4d4d4", this.colors.sleet, "#33a919"],
72
- padding: 0,
73
- isBar: true,
74
- },
75
- bar5: {
76
- size: 400,
77
- colors: [
78
- "#d4d4d4",
79
- this.colors.lavender,
80
- this.colors.midnight,
81
- "#919834",
82
- "#c177cf",
83
- "#c16e00",
84
- "#029af2",
85
- "#2a6993",
86
- ],
87
- padding: 0,
88
- isBar: true,
89
- },
90
- };
91
- /* LIFECYCLE METHODS + EVENTS FROM THE CHILDREN */
92
- this.debouncedResize = debounce(async () => {
93
- if (this.chartType === "hybrid") {
94
- this.setHybridType();
95
- await this.getData();
96
- }
97
- forceUpdate(this.el);
98
- }, 10);
99
- this.debouncedSliceUpdate = debounce(async () => {
100
- await this.getData();
101
- forceUpdate(this.el);
102
- }, 100);
103
- }
104
- get tempValueFormat() {
105
- // use of this getter should be replaced with dateFormat when showValues is fully phased out
106
- return this.valueFormat || this.showValues || "none";
107
- }
108
- toggleTabbingOn() {
109
- this.isTabbing = true;
110
- }
111
- toggleTabbingOff() {
112
- this.isTabbing = false;
113
- }
114
- handleKeydown(ev) {
115
- switch (ev.keyCode) {
116
- // arrow up / left
117
- case 37:
118
- case 38:
119
- ev.preventDefault();
120
- this.isTabbing = true; // shd already be true. just in case user clicked on chart then pressed an arrow key
121
- this.focusPrevious();
122
- break;
123
- // arrow right / down
124
- case 39:
125
- case 40:
126
- ev.preventDefault();
127
- this.isTabbing = true; // shd already be true. just in case user clicked on chart then pressed an arrow key
128
- this.focusNext();
129
- break;
130
- // tab
131
- case 9:
132
- this.exitChart();
133
- break;
134
- case 27:
135
- this.popoverEl.open = false;
136
- break;
137
- }
138
- }
139
- focusNext() {
140
- const activeEl = checkForActiveElInShadow(document.activeElement);
141
- const index =
142
- // if the active el is not in the array the first element gets focused
143
- (this.sliceEls.indexOf(activeEl) + 1) % this.sliceEls.length;
144
- this.focusSlice(index);
145
- }
146
- focusPrevious() {
147
- if (this.sliceEls) {
148
- const activeEl = checkForActiveElInShadow(document.activeElement);
149
- let index = this.sliceEls.indexOf(activeEl);
150
- if (index === -1) {
151
- // not in the array : focus the first slice
152
- index = 0;
153
- }
154
- else if (index === 0) {
155
- // first slice : focus the last slice
156
- index = this.sliceEls.length - 1;
157
- }
158
- else {
159
- // anything else: focus previous
160
- index -= 1;
161
- }
162
- this.focusSlice(index);
163
- }
164
- }
165
- focusSlice(index) {
166
- if (this.sliceEls && this.el) {
167
- if (this.popoverEl) {
168
- this.popoverEl.open = false;
169
- }
170
- this.el.tabIndex = -1;
171
- // @ts-ignore
172
- this.el.focusable = false; // for Edge
173
- this.sliceEls.map((p) => {
174
- p.tabIndex = -1;
175
- // @ts-ignore
176
- p.focusable = false; // for Edge
177
- });
178
- this.sliceEls[index].tabIndex = 0;
179
- // @ts-ignore
180
- this.sliceEls[index].focusable = true; // for Edge
181
- this.sliceEls[index].focus();
182
- window.setTimeout(() => {
183
- if (this.popoverEl) {
184
- this.popoverEl.open = true;
185
- }
186
- }, 10);
187
- }
188
- }
189
- exitChart() {
190
- this.sliceEls &&
191
- this.sliceEls.map((p) => {
192
- p.tabIndex = -1;
193
- // @ts-ignore
194
- p.focusable = false; // for Edge
195
- });
196
- // delay so that we can tab out of component before chart becomes focusable again
197
- // and in case user was still pressing an arrow key when they pressed tab
198
- window.setTimeout(() => {
199
- if (this.el) {
200
- this.el.tabIndex = 0;
201
- // @ts-ignore
202
- this.el.focusable = true; // for Edge
203
- if (this.popoverEl) {
204
- this.popoverEl.open = false;
205
- }
206
- }
207
- }, 100);
208
- }
209
- openPopover(s) {
210
- if (!!this.popoverEl && !!s.title && !!s.text) {
211
- this.popoverEl.popoverTitle = s.title;
212
- this.popoverEl.popoverText = s.text;
213
- this.popoverEl.buttonText = s.buttonText;
214
- this.popoverEl.coords = s.coords;
215
- this.popoverEl.sliceRef = s.sliceRef;
216
- window.setTimeout(() => {
217
- if (this.popoverEl) {
218
- this.popoverEl.open = true;
219
- }
220
- }, 30);
221
- const debouncedClosePopover = debounce(async () => {
222
- this.popoverEl.open = false;
223
- }, 10);
224
- // set up event listeners for scrolling
225
- // to close popover on page scroll
226
- document.addEventListener("scroll", () => {
227
- debouncedClosePopover();
228
- });
229
- // ... and on parent scroll
230
- const scrollableParent = findParentWithScrollbar(this.el);
231
- if (!!scrollableParent) {
232
- scrollableParent.addEventListener("scroll", () => {
233
- debouncedClosePopover();
234
- });
235
- }
236
- }
237
- }
238
- /* UTILS */
239
- amountToPercent(val, asInt) {
240
- return asInt ? Math.round((val * 100) / this.total) : Math.round((val * 10000) / this.total) / 100; // with 2 decimals
241
- }
242
- amountToDegree(val) {
243
- return (val * 360) / this.total;
244
- }
245
- toFixed(number) {
246
- var val = parseFloat((Math.floor(number * 100) / 100).toFixed(2));
247
- return val;
248
- }
249
- polarToCartesian(half, radius, startAngle, endAngle) {
250
- var x = this.toFixed(half + half * radius * Math.cos((Math.PI * startAngle) / 180));
251
- var y = this.toFixed(half + half * radius * Math.sin((Math.PI * startAngle) / 180));
252
- if (endAngle !== undefined) {
253
- // if a 2nd angle value was passed, return 2 pairs of coords
254
- var x2 = this.toFixed(half + half * radius * Math.cos((Math.PI * endAngle) / 180));
255
- var y2 = this.toFixed(half + half * radius * Math.sin((Math.PI * endAngle) / 180));
256
- return { x1: x, y1: y, x2, y2 };
257
- }
258
- return { x, y };
259
- }
260
- /* CRUNCH THE NUMBERS */
261
- getPathData(amount, offset) {
262
- var startAngle = this.amountToDegree(offset) - 90; // start at noon, not at 3 o'clock
263
- var activeAngle = (amount / this.total) * 360;
264
- var endAngle = startAngle + activeAngle;
265
- var largeArcFlagOuter = activeAngle > 180 ? "1 1" : "0 1";
266
- var largeArcFlagInner = activeAngle > 180 ? "1 0" : "0 0";
267
- var half = this.chartData.size / 2;
268
- var innerRadius = this.chartData.thickness;
269
- var outerRadius = 1;
270
- if (activeAngle === 360) {
271
- // fix to avoid bad svg shape when the path goes all around (100%)
272
- endAngle -= 0.01;
273
- }
274
- var outerCoords = this.polarToCartesian(half, outerRadius, startAngle + 1.5, // 1.5 for slice separator
275
- endAngle);
276
- var innerCoords = this.polarToCartesian(half, innerRadius, startAngle + 3, // 3 for slice separator
277
- endAngle);
278
- const moveTo = `M ${outerCoords.x1}, ${outerCoords.y1} `;
279
- const arc1 = this.getArc(outerRadius, largeArcFlagOuter, outerCoords.x2, outerCoords.y2);
280
- const line = ` L ${innerCoords.x2}, ${innerCoords.y2} `;
281
- const arc2 = this.getArc(innerRadius, largeArcFlagInner, innerCoords.x1, innerCoords.y1);
282
- return moveTo + arc1 + line + arc2 + " z";
283
- }
284
- getArc(radius, largeArcFlag, x, y) {
285
- var z = this.toFixed((this.chartData.size / 2) * radius);
286
- return `A ${z}, ${z} 0 ${largeArcFlag} ${this.toFixed(x)}, ${this.toFixed(y)}`;
287
- }
288
- setHybridType() {
289
- this.hybridType = window.innerWidth > 1340 ? "doughnut0" : "bar1";
290
- }
291
- getType() {
292
- return this.chartType === "hybrid" ? this.hybridType : this.chartType;
293
- }
294
- /* GET THE DATA */
295
- async getData() {
296
- this.slicesData = [];
297
- let acc = 0;
298
- const children = this.el.querySelectorAll("wm-chart-slice");
299
- this.total = Array.from(children).reduce((total, slice) => (total += parseInt(slice.getAttribute("amount") || "0")), 0);
300
- children.forEach((c, i) => {
301
- const amount = parseInt(c.getAttribute("amount") || "0");
302
- const perc = this.amountToPercent(amount, true);
303
- // determine whether the slice is in a cluster of small values
304
- // to avoid percentage text overlap for small values
305
- const prev = children[i === 0 ? children.length - 1 : i - 1];
306
- const prevPerc = this.amountToPercent(parseInt(prev.getAttribute("amount") || "0"), true);
307
- const next = children[i === children.length - 1 ? 0 : i + 1];
308
- const nextPerc = this.amountToPercent(parseInt(next.getAttribute("amount") || "0"), true);
309
- const isSmall = perc < 4;
310
- const prevIsSmall = prevPerc < 5;
311
- const nextIsSmall = nextPerc < 5;
312
- let inSmallCluster = isSmall && (prevIsSmall || nextIsSmall);
313
- // because <1% slice percentage text has an additional character
314
- // the inSmallCluster threshold needs to be widened for that slice only
315
- const lessThanOnePerc = perc === 0 && amount > 0;
316
- if (lessThanOnePerc && (nextPerc < 8 || prevPerc < 8)) {
317
- inSmallCluster = true;
318
- }
319
- // for bar5, first color should be skipped unless notStartedColor is set to true
320
- const ind = this.getType() === "bar5" ? (this.notStartedColor ? i : i + 1) : i;
321
- const color = this.types[this.getType()].colors[ind];
322
- const sliceData = {
323
- amount: amount,
324
- perc: perc,
325
- legend: c.getAttribute("legend"),
326
- color: color || "#d4d4d4",
327
- offset: acc,
328
- id: `${this.uid}-${i + 1}`,
329
- title: c.getAttribute("popover-title"),
330
- text: c.getAttribute("popover-text"),
331
- buttonText: c.getAttribute("popover-button-text"),
332
- sliceRef: c,
333
- inSmallCluster: inSmallCluster,
334
- };
335
- acc += amount;
336
- this.slicesData.push(sliceData);
337
- });
338
- this.chartData = this.types[this.getType()];
339
- }
340
- getSliceEls() {
341
- if (this.svgEl) {
342
- this.sliceEls = Array.from(this.svgEl.querySelectorAll(this.chartData.isBar ? "rect" : "path"));
343
- }
344
- }
345
- handleResize() {
346
- // handling resizing only needs to occur for bar charts (hybrid included)
347
- if (this.chartType.includes("bar") || this.chartType === "hybrid") {
348
- this.debouncedResize();
349
- }
350
- }
351
- async componentWillLoad() {
352
- if (!this.label) {
353
- throw new Error("For accessibility purposes, you must provide a label for the chart. See https://components.watermarkinsights.com/chart for more information.");
354
- }
355
- if (this.showValues) {
356
- console.warn("wm-chart: show-values has been deprecated as of v3.1.0. Please use value-format instead.");
357
- }
358
- if (this.chartType === "hybrid") {
359
- this.setHybridType();
360
- }
361
- await this.getData();
362
- }
363
- componentDidLoad() {
364
- this.getSliceEls();
365
- }
366
- componentDidUpdate() {
367
- this.getSliceEls();
368
- }
369
- handleSliceUpdate() {
370
- this.debouncedSliceUpdate();
371
- }
372
- /* RENDERING */
373
- renderFilter() {
374
- return (h("defs", null,
375
- h("filter", { id: "wmHoverDropShadow" },
376
- h("feGaussianBlur", { stdDeviation: "3" }),
377
- h("feOffset", { result: "offsetblur" }),
378
- h("feFlood", { "flood-color": "#333" }),
379
- h("feComposite", { operator: "in", in2: "offsetblur" }),
380
- h("feMerge", null,
381
- h("feMergeNode", null),
382
- h("feMergeNode", { in: "SourceGraphic" })))));
383
- }
384
- // DOUGHNUT
385
- renderDoughnut() {
386
- const outerSize = this.chartData.size + this.chartData.padding;
387
- return (h("div", { class: "svg-wrapper doughnut-wrapper" },
388
- h("svg", { width: outerSize + "px", height: outerSize + "px", ref: (el) => (this.svgEl = el), id: `graphic-${this.uid}`, class: `chart-svg doughnut-svg ${this.isTabbing ? "user-is-tabbing" : ""}` },
389
- this.renderFilter(),
390
- this.slicesData.map((s) => this.renderPath(s)),
391
- this.getType() === "doughnut0" ? (h("text", { class: "value", x: "50%", y: "50%", "font-size": "1.5rem", "font-weight": "500", "text-anchor": "middle", "dominant-baseline": "middle" }, this.amountToPercent(this.slicesData[0].amount, true) + "%")) : (h("g", { transform: `translate(${this.chartData.padding / 2}, ${this.chartData.padding / 2})`, "text-anchor": "middle", "dominant-baseline": "middle" }, this.slicesData.map((s) => (s.amount > 0 ? this.renderDoughnutText(s) : "")))))));
392
- }
393
- renderPath(s) {
394
- return (h("g", { transform: `translate(${this.chartData.padding / 2}, ${this.chartData.padding / 2})` },
395
- h("path", { id: s.id, fill: s.amount ? s.color : "transparent", d: this.getPathData(s.amount, s.offset), onClick: (ev) => {
396
- if (this.popoverEl) {
397
- if (!this.isTabbing) {
398
- s.coords = { x: ev.clientX, y: ev.clientY };
399
- this.openPopover(s);
400
- }
401
- }
402
- }, onFocus: (ev) => {
403
- if (this.popoverEl) {
404
- if (this.isTabbing) {
405
- s.coords = getPosition(ev.target);
406
- this.openPopover(s);
407
- }
408
- }
409
- }, onKeyDown: (ev) => {
410
- if (this.popoverEl && this.popoverEl.open && ev.keyCode === 13) {
411
- const popoverBtn = this.popoverEl.querySelector("button");
412
- popoverBtn && popoverBtn.click();
413
- }
414
- } }),
415
- h("text", { class: "sr-only" }, s.legend)));
416
- }
417
- renderDoughnutText(s) {
418
- if (!s.inSmallCluster) {
419
- const arcMiddle = this.amountToDegree(s.offset + s.amount / 2);
420
- let { x, y } = this.polarToCartesian(this.chartData.size / 2, 1.4, arcMiddle - 90);
421
- return (h("text", { class: "value", x: x + "px", y: y + "px" }, `${s.perc > 0 ? s.perc : "<1"}%`));
422
- }
423
- }
424
- // BAR
425
- renderBar() {
426
- return (h("div", { class: "svg-wrapper bar-wrapper" },
427
- this.getType() === "bar1" ? (h("div", { class: "single-perc" }, this.amountToPercent(this.slicesData[0].amount, true) + "%")) : (""),
428
- this.drawAxis(),
429
- h("div", { class: "completion-message-wrapper" },
430
- h("svg", { ref: (el) => (this.svgEl = el), id: `graphic-${this.uid}`, class: {
431
- "chart-svg bar-svg": true,
432
- "user-is-tabbing": this.isTabbing,
433
- "show-values": this.tempValueFormat === "percentage" || this.tempValueFormat === "amount",
434
- } },
435
- this.renderFilter(),
436
- h("foreignObject", { class: this.getType() === "bar2" || this.getType() === "bar4" || this.getType() === "bar5"
437
- ? "focus-offset"
438
- : "" },
439
- h("div", {
440
- // @ts-ignore
441
- xmlns: "http://www.w3.org/1999/xhtml", class: "tabbing-focus" })),
442
- this.slicesData.map((s, idx) => this.renderRect(s, idx)),
443
- this.getType() !== "bar1" ? (h("g", { class: "percs" }, this.slicesData.map((s) => (s.perc > 0 ? this.renderBarText(s) : "")))) : ("")),
444
- this.renderCompletionMessage())));
445
- }
446
- renderRect(s, idx) {
447
- let y;
448
- switch (this.getType()) {
449
- case "bar2":
450
- case "bar4":
451
- case "bar5":
452
- y = this.tempValueFormat === "percentage" || this.tempValueFormat === "amount" ? "30px" : "0";
453
- break;
454
- default:
455
- y = "0";
456
- }
457
- // adjusting the width of the rect slightly ensures repainting on rerenders
458
- // important for updating width accurate when resizing the page
459
- const randomTinyNumber = Math.random() / 1000;
460
- return (h("g", { class: "barcontainer" },
461
- h("style", null, ` #${s.id} {
462
- fill:${s.color};
463
- x: ${`${this.amountToPercent(s.offset, false)}%`};
464
- y: ${y};
465
- height: 30px;
466
- width: calc(${this.amountToPercent(s.amount, false) + randomTinyNumber}%${idx !== this.slicesData.length - 1 ? " - 2px" : ""});
467
- }`),
468
- h("rect", { id: s.id, onClick: (ev) => {
469
- if (this.popoverEl) {
470
- if (!this.isTabbing) {
471
- s.coords = { x: ev.clientX, y: ev.clientY };
472
- this.openPopover(s);
473
- }
474
- }
475
- }, onFocus: (ev) => {
476
- if (this.popoverEl) {
477
- if (this.isTabbing) {
478
- s.coords = getPosition(ev.target);
479
- this.openPopover(s);
480
- }
481
- }
482
- }, onKeyDown: (ev) => {
483
- if (this.popoverEl && this.popoverEl.open && ev.keyCode === 13) {
484
- const popoverBtn = this.popoverEl.querySelector("button");
485
- popoverBtn && popoverBtn.click();
486
- }
487
- } }),
488
- h("text", { class: "sr-only" }, s.legend)));
489
- }
490
- renderBarText(s) {
491
- let val;
492
- if (this.tempValueFormat === "percentage") {
493
- val = s.perc + "%";
494
- }
495
- else if (this.tempValueFormat === "amount") {
496
- val = s.amount;
497
- }
498
- else {
499
- return;
500
- }
501
- return (h("text", { class: "value", x: `${this.amountToPercent(s.offset, false) + this.amountToPercent(s.amount, false) / 2}%` }, val));
502
- }
503
- drawAxis() {
504
- if (this.getType() === "bar3") {
505
- return (h("svg", { class: "axis" },
506
- h("line", { x1: "0", x2: "100%", y1: "0", y2: "0" }),
507
- h("line", { x1: "0", x2: "0", y1: "0", y2: "-85px" }),
508
- h("line", { class: "tick", x1: "0.5", x2: "0.5", y1: "0", y2: "6" }),
509
- h("text", { x: "0.5", y: "-6" }, "0%"),
510
- h("line", { class: "tick", x1: "100%", x2: "100%", y1: "0", y2: "6" }),
511
- h("text", { x: "100%", y: "-6" }, "100%")));
512
- }
513
- }
514
- renderCompletionMessage() {
515
- if (this.chartType === "hybrid" && this.completionMessage) {
516
- return h("span", { class: "completion-message" }, this.completionMessage);
517
- }
518
- }
519
- renderLegend() {
520
- // legend is hidden for bar1 type regardless of showLegend value
521
- if (this.showLegend) {
522
- const hasCluster = this.slicesData.reduce((hasCluster, cur) => (hasCluster = cur.inSmallCluster ? true : hasCluster), false);
523
- return (h("div", { class: "legend-wrapper" },
524
- h("div", { class: `legend ${this.chartData.isBar ? "--top" : "--bottom"}`, "aria-hidden": "true" }, this.total > 0
525
- ? this.slicesData.map((s) => {
526
- // when both legend and amount are omitted, the legend is not shown for that particular option (it's been deactivated by the user)
527
- if (!!s.amount || !!s.legend) {
528
- return (h("div", { class: "legend-item" },
529
- h("div", { class: "legend-color", style: { "background-color": s.color } }),
530
- h("div", { class: "legend-text" }, s.legend)));
531
- }
532
- })
533
- : ""),
534
- !this.chartData.isBar && hasCluster ? (h("div", { class: "cluster-warning" },
535
- intl.formatMessage({
536
- id: "chart.hiddenPercentages",
537
- defaultMessage: "Percentages smaller than 5% are not shown when too close to each other.",
538
- }),
539
- h("br", null),
540
- intl.formatMessage({
541
- id: "chart.clickToSeeDetails",
542
- defaultMessage: "Click or use arrow keys to see details.",
543
- }))) : ("")));
544
- }
545
- }
546
- render() {
547
- return (h(Host, { role: "application", "aria-label": this.label +
548
- ", " +
549
- intl.formatMessage({
550
- id: "chart.interactiveChart",
551
- defaultMessage: "Interactive chart. Use arrow keys to browse elements, press Tab to exit.",
552
- }), tabindex: "0" },
553
- h("div", { class: `component-wrapper ${this.getType()} ${this.labelPosition === "left" && this.chartType === "bar4" ? "left-label" : ""}` },
554
- h("label", { class: "label", id: `label-${this.uid}`, htmlFor: `graphic-${this.uid}` },
555
- h("span", { class: "label-text" }, this.label),
556
- this.subinfo ? h("span", { class: "subinfo" }, this.subinfo) : ""),
557
- this.chartData.isBar ? this.renderLegend() : "",
558
- this.total > 0 && this.chartData.isBar ? this.renderBar() : this.renderDoughnut(),
559
- !this.chartData.isBar ? this.renderLegend() : "",
560
- h("priv-chart-popover", { class: this.isTabbing ? "user-is-tabbing" : "", ref: (el) => (this.popoverEl = el) }),
561
- this.hybridType === "doughnut0" ? this.renderCompletionMessage() : "")));
562
- }
563
- static get is() { return "wm-chart"; }
564
- static get encapsulation() { return "shadow"; }
565
- static get originalStyleUrls() { return {
566
- "$": ["wm-chart.scss"]
567
- }; }
568
- static get styleUrls() { return {
569
- "$": ["wm-chart.css"]
570
- }; }
571
- static get properties() { return {
572
- "chartType": {
573
- "type": "string",
574
- "mutable": false,
575
- "complexType": {
576
- "original": "\"doughnut1\" | \"doughnut2\" | \"doughnut3\" | \"hybrid\" | \"bar1\" | \"bar2\" | \"bar3\" | \"bar4\" | \"bar5\"",
577
- "resolved": "\"bar1\" | \"bar2\" | \"bar3\" | \"bar4\" | \"bar5\" | \"doughnut1\" | \"doughnut2\" | \"doughnut3\" | \"hybrid\"",
578
- "references": {}
579
- },
580
- "required": false,
581
- "optional": false,
582
- "docs": {
583
- "tags": [],
584
- "text": ""
585
- },
586
- "attribute": "chart-type",
587
- "reflect": false,
588
- "defaultValue": "\"doughnut1\""
589
- },
590
- "label": {
591
- "type": "string",
592
- "mutable": false,
593
- "complexType": {
594
- "original": "string",
595
- "resolved": "string | undefined",
596
- "references": {}
597
- },
598
- "required": false,
599
- "optional": true,
600
- "docs": {
601
- "tags": [],
602
- "text": ""
603
- },
604
- "attribute": "label",
605
- "reflect": false
606
- },
607
- "subinfo": {
608
- "type": "string",
609
- "mutable": false,
610
- "complexType": {
611
- "original": "string",
612
- "resolved": "string | undefined",
613
- "references": {}
614
- },
615
- "required": false,
616
- "optional": true,
617
- "docs": {
618
- "tags": [],
619
- "text": ""
620
- },
621
- "attribute": "subinfo",
622
- "reflect": false
623
- },
624
- "completionMessage": {
625
- "type": "string",
626
- "mutable": false,
627
- "complexType": {
628
- "original": "string",
629
- "resolved": "string | undefined",
630
- "references": {}
631
- },
632
- "required": false,
633
- "optional": true,
634
- "docs": {
635
- "tags": [],
636
- "text": ""
637
- },
638
- "attribute": "completion-message",
639
- "reflect": false
640
- },
641
- "valueFormat": {
642
- "type": "string",
643
- "mutable": false,
644
- "complexType": {
645
- "original": "\"percentage\" | \"amount\"",
646
- "resolved": "\"amount\" | \"percentage\" | undefined",
647
- "references": {}
648
- },
649
- "required": false,
650
- "optional": true,
651
- "docs": {
652
- "tags": [],
653
- "text": ""
654
- },
655
- "attribute": "value-format",
656
- "reflect": false
657
- },
658
- "showValues": {
659
- "type": "string",
660
- "mutable": false,
661
- "complexType": {
662
- "original": "\"percentage\" | \"amount\"",
663
- "resolved": "\"amount\" | \"percentage\" | undefined",
664
- "references": {}
665
- },
666
- "required": false,
667
- "optional": true,
668
- "docs": {
669
- "tags": [],
670
- "text": ""
671
- },
672
- "attribute": "show-values",
673
- "reflect": false
674
- },
675
- "showLegend": {
676
- "type": "boolean",
677
- "mutable": false,
678
- "complexType": {
679
- "original": "boolean",
680
- "resolved": "boolean",
681
- "references": {}
682
- },
683
- "required": false,
684
- "optional": false,
685
- "docs": {
686
- "tags": [],
687
- "text": ""
688
- },
689
- "attribute": "show-legend",
690
- "reflect": false,
691
- "defaultValue": "true"
692
- },
693
- "notStartedColor": {
694
- "type": "boolean",
695
- "mutable": false,
696
- "complexType": {
697
- "original": "boolean",
698
- "resolved": "boolean",
699
- "references": {}
700
- },
701
- "required": false,
702
- "optional": false,
703
- "docs": {
704
- "tags": [],
705
- "text": ""
706
- },
707
- "attribute": "not-started-color",
708
- "reflect": false,
709
- "defaultValue": "false"
710
- },
711
- "labelPosition": {
712
- "type": "string",
713
- "mutable": false,
714
- "complexType": {
715
- "original": "\"left\" | \"top\"",
716
- "resolved": "\"left\" | \"top\"",
717
- "references": {}
718
- },
719
- "required": false,
720
- "optional": false,
721
- "docs": {
722
- "tags": [],
723
- "text": ""
724
- },
725
- "attribute": "label-position",
726
- "reflect": false,
727
- "defaultValue": "\"top\""
728
- }
729
- }; }
730
- static get states() { return {
731
- "isTabbing": {}
732
- }; }
733
- static get elementRef() { return "el"; }
734
- static get listeners() { return [{
735
- "name": "wmUserIsTabbing",
736
- "method": "toggleTabbingOn",
737
- "target": "window",
738
- "capture": false,
739
- "passive": false
740
- }, {
741
- "name": "wmUserIsNotTabbing",
742
- "method": "toggleTabbingOff",
743
- "target": "window",
744
- "capture": false,
745
- "passive": false
746
- }, {
747
- "name": "keydown",
748
- "method": "handleKeydown",
749
- "target": undefined,
750
- "capture": false,
751
- "passive": false
752
- }, {
753
- "name": "resize",
754
- "method": "handleResize",
755
- "target": "window",
756
- "capture": false,
757
- "passive": true
758
- }, {
759
- "name": "wmChartSliceUpdated",
760
- "method": "handleSliceUpdate",
761
- "target": undefined,
762
- "capture": false,
763
- "passive": false
764
- }]; }
765
- }
1
+ import { Component, Element, h, Host, Prop, State, Listen } from "@stencil/core";
2
+ import { forceUpdate } from "@stencil/core";
3
+ import { debounce, generateId, checkForActiveElInShadow, getPosition, intl, findParentWithScrollbar, } from "../../global/functions";
4
+ export class Chart {
5
+ constructor() {
6
+ this.chartType = "doughnut1";
7
+ this.showLegend = true;
8
+ this.notStartedColor = false;
9
+ // left labels are a temporary solution for the lack of a stacked bar chart and is undocumented
10
+ // it only works with bar4 and should be used without a legend
11
+ this.labelPosition = "top";
12
+ this.isTabbing = false;
13
+ this.uid = generateId();
14
+ this.slicesData = [];
15
+ this.colors = {
16
+ salmon: "#ff5f4e",
17
+ cyan: "#19a1a9",
18
+ sleet: "#7f97ad",
19
+ midnight: "#2e1b46",
20
+ lavender: "#8b86ca",
21
+ };
22
+ this.types = {
23
+ doughnut0: {
24
+ size: 155,
25
+ colors: [this.colors.cyan, "#bfbfbf"],
26
+ thickness: 0.73,
27
+ padding: 25,
28
+ isBar: false,
29
+ },
30
+ doughnut1: {
31
+ size: 130,
32
+ colors: [this.colors.lavender, this.colors.midnight, "#d4d4d4"],
33
+ thickness: 0.5,
34
+ padding: 90,
35
+ isBar: false,
36
+ },
37
+ doughnut2: {
38
+ size: 130,
39
+ colors: [this.colors.cyan, this.colors.salmon, "#d4d4d4"],
40
+ thickness: 0.5,
41
+ padding: 90,
42
+ isBar: false,
43
+ },
44
+ doughnut3: {
45
+ size: 130,
46
+ colors: [this.colors.lavender, this.colors.midnight, "#919834", "#c177cf", "#c16e00", "#029af2", "#2a6993"],
47
+ thickness: 0.5,
48
+ padding: 90,
49
+ isBar: false,
50
+ },
51
+ bar1: {
52
+ size: 350,
53
+ colors: [this.colors.cyan, "#bfbfbf"],
54
+ padding: 0,
55
+ isBar: true,
56
+ },
57
+ bar2: {
58
+ size: 400,
59
+ colors: ["#d4d4d4", this.colors.sleet, this.colors.cyan, this.colors.salmon],
60
+ padding: 0,
61
+ isBar: true,
62
+ },
63
+ bar3: {
64
+ size: 300,
65
+ colors: ["#0d696e", this.colors.cyan, "#8e4129", this.colors.salmon],
66
+ padding: 0,
67
+ isBar: true,
68
+ },
69
+ bar4: {
70
+ size: 400,
71
+ colors: ["#d4d4d4", this.colors.sleet, "#33a919"],
72
+ padding: 0,
73
+ isBar: true,
74
+ },
75
+ bar5: {
76
+ size: 400,
77
+ colors: [
78
+ "#d4d4d4",
79
+ this.colors.lavender,
80
+ this.colors.midnight,
81
+ "#919834",
82
+ "#c177cf",
83
+ "#c16e00",
84
+ "#029af2",
85
+ "#2a6993",
86
+ ],
87
+ padding: 0,
88
+ isBar: true,
89
+ },
90
+ };
91
+ /* LIFECYCLE METHODS + EVENTS FROM THE CHILDREN */
92
+ this.debouncedResize = debounce(async () => {
93
+ this.setHybridType();
94
+ await this.getData();
95
+ forceUpdate(this.el);
96
+ }, 10);
97
+ this.debouncedSliceUpdate = debounce(async () => {
98
+ await this.getData();
99
+ forceUpdate(this.el);
100
+ }, 100);
101
+ }
102
+ get tempValueFormat() {
103
+ // use of this getter should be replaced with dateFormat when showValues is fully phased out
104
+ return this.valueFormat || this.showValues || "none";
105
+ }
106
+ get sliceEls() {
107
+ const isBarType = this.currentChartType.includes("bar");
108
+ const isDoughnutType = this.currentChartType.includes("doughnut");
109
+ return isBarType
110
+ ? Array.from(this.barEl.querySelectorAll(".bar-segment"))
111
+ : isDoughnutType
112
+ ? Array.from(this.doughnutEl.querySelectorAll(".doughnut-segment"))
113
+ : undefined;
114
+ }
115
+ get currentChartType() {
116
+ return this.chartType === "hybrid" ? this.hybridType : this.chartType;
117
+ }
118
+ toggleTabbingOn() {
119
+ this.isTabbing = true;
120
+ }
121
+ toggleTabbingOff() {
122
+ this.isTabbing = false;
123
+ }
124
+ handleKeydown(ev) {
125
+ switch (ev.keyCode) {
126
+ // arrow up / left
127
+ case 37:
128
+ case 38:
129
+ ev.preventDefault();
130
+ this.isTabbing = true; // shd already be true. just in case user clicked on chart then pressed an arrow key
131
+ this.focusPrevious();
132
+ break;
133
+ // arrow right / down
134
+ case 39:
135
+ case 40:
136
+ ev.preventDefault();
137
+ this.isTabbing = true; // shd already be true. just in case user clicked on chart then pressed an arrow key
138
+ this.focusNext();
139
+ break;
140
+ // tab
141
+ case 9:
142
+ this.exitChart();
143
+ break;
144
+ case 27:
145
+ this.popoverEl.open = false;
146
+ break;
147
+ }
148
+ }
149
+ handleSliceClick(ev, s) {
150
+ if (this.popoverEl && !this.isTabbing) {
151
+ s.coords = { x: ev.clientX, y: ev.clientY };
152
+ this.openPopover(s);
153
+ }
154
+ }
155
+ handleSliceFocus(ev, s) {
156
+ if (this.popoverEl && this.isTabbing) {
157
+ s.coords = getPosition(ev.target);
158
+ this.openPopover(s);
159
+ }
160
+ }
161
+ handleSliceKeyDown(ev) {
162
+ if (this.popoverEl && this.popoverEl.open && ev.key === "Enter") {
163
+ const popoverBtn = this.popoverEl.querySelector("button");
164
+ popoverBtn && popoverBtn.click();
165
+ }
166
+ }
167
+ focusNext() {
168
+ const activeEl = checkForActiveElInShadow(document.activeElement);
169
+ const index =
170
+ // if the active el is not in the array the first element gets focused
171
+ (this.sliceEls.indexOf(activeEl) + 1) % this.sliceEls.length;
172
+ this.focusSlice(index);
173
+ }
174
+ focusPrevious() {
175
+ if (this.sliceEls) {
176
+ const activeEl = checkForActiveElInShadow(document.activeElement);
177
+ let index = this.sliceEls.indexOf(activeEl);
178
+ if (index === -1) {
179
+ // not in the array : focus the first slice
180
+ index = 0;
181
+ }
182
+ else if (index === 0) {
183
+ // first slice : focus the last slice
184
+ index = this.sliceEls.length - 1;
185
+ }
186
+ else {
187
+ // anything else: focus previous
188
+ index -= 1;
189
+ }
190
+ this.focusSlice(index);
191
+ }
192
+ }
193
+ focusSlice(index) {
194
+ if (this.sliceEls && this.el) {
195
+ if (this.popoverEl) {
196
+ this.popoverEl.open = false;
197
+ }
198
+ this.el.tabIndex = -1;
199
+ // @ts-ignore
200
+ this.el.focusable = false; // for Edge
201
+ this.sliceEls.map((p) => {
202
+ p.tabIndex = -1;
203
+ // @ts-ignore
204
+ p.focusable = false; // for Edge
205
+ });
206
+ this.sliceEls[index].tabIndex = 0;
207
+ // @ts-ignore
208
+ this.sliceEls[index].focusable = true; // for Edge
209
+ this.sliceEls[index].focus();
210
+ window.setTimeout(() => {
211
+ if (this.popoverEl) {
212
+ this.popoverEl.open = true;
213
+ }
214
+ }, 10);
215
+ }
216
+ }
217
+ exitChart() {
218
+ this.sliceEls &&
219
+ this.sliceEls.map((p) => {
220
+ p.tabIndex = -1;
221
+ // @ts-ignore
222
+ p.focusable = false; // for Edge
223
+ });
224
+ // delay so that we can tab out of component before chart becomes focusable again
225
+ // and in case user was still pressing an arrow key when they pressed tab
226
+ window.setTimeout(() => {
227
+ if (this.el) {
228
+ this.el.tabIndex = 0;
229
+ // @ts-ignore
230
+ this.el.focusable = true; // for Edge
231
+ if (this.popoverEl) {
232
+ this.popoverEl.open = false;
233
+ }
234
+ }
235
+ }, 100);
236
+ }
237
+ openPopover(s) {
238
+ if (!!this.popoverEl && !!s.title && !!s.text) {
239
+ this.popoverEl.popoverTitle = s.title;
240
+ this.popoverEl.popoverText = s.text;
241
+ this.popoverEl.buttonText = s.buttonText;
242
+ this.popoverEl.coords = s.coords;
243
+ this.popoverEl.sliceRef = s.sliceRef;
244
+ window.setTimeout(() => {
245
+ if (this.popoverEl) {
246
+ this.popoverEl.open = true;
247
+ }
248
+ }, 30);
249
+ const debouncedClosePopover = debounce(async () => {
250
+ this.popoverEl.open = false;
251
+ }, 10);
252
+ // set up event listeners for scrolling
253
+ // to close popover on page scroll
254
+ document.addEventListener("scroll", () => {
255
+ debouncedClosePopover();
256
+ });
257
+ // ... and on parent scroll
258
+ const scrollableParent = findParentWithScrollbar(this.el);
259
+ if (!!scrollableParent) {
260
+ scrollableParent.addEventListener("scroll", () => {
261
+ debouncedClosePopover();
262
+ });
263
+ }
264
+ }
265
+ }
266
+ /* UTILS */
267
+ amountToPercent(val, asInt) {
268
+ return asInt ? Math.round((val * 100) / this.total) : Math.round((val * 10000) / this.total) / 100; // with 2 decimals
269
+ }
270
+ amountToDegree(val) {
271
+ return (val * 360) / this.total;
272
+ }
273
+ toFixed(number) {
274
+ var val = parseFloat((Math.floor(number * 100) / 100).toFixed(2));
275
+ return val;
276
+ }
277
+ polarToCartesian(half, radius, startAngle, endAngle) {
278
+ var x = this.toFixed(half + half * radius * Math.cos((Math.PI * startAngle) / 180));
279
+ var y = this.toFixed(half + half * radius * Math.sin((Math.PI * startAngle) / 180));
280
+ if (endAngle !== undefined) {
281
+ // if a 2nd angle value was passed, return 2 pairs of coords
282
+ var x2 = this.toFixed(half + half * radius * Math.cos((Math.PI * endAngle) / 180));
283
+ var y2 = this.toFixed(half + half * radius * Math.sin((Math.PI * endAngle) / 180));
284
+ return { x1: x, y1: y, x2, y2 };
285
+ }
286
+ return { x, y };
287
+ }
288
+ /* CRUNCH THE NUMBERS */
289
+ getPathData(amount, offset) {
290
+ var startAngle = this.amountToDegree(offset) - 90; // start at noon, not at 3 o'clock
291
+ var activeAngle = (amount / this.total) * 360;
292
+ var endAngle = startAngle + activeAngle;
293
+ var largeArcFlagOuter = activeAngle > 180 ? "1 1" : "0 1";
294
+ var largeArcFlagInner = activeAngle > 180 ? "1 0" : "0 0";
295
+ var half = this.chartData.size / 2;
296
+ var innerRadius = this.chartData.thickness;
297
+ var outerRadius = 1;
298
+ if (activeAngle === 360) {
299
+ // fix to avoid bad svg shape when the path goes all around (100%)
300
+ endAngle -= 0.01;
301
+ }
302
+ var outerCoords = this.polarToCartesian(half, outerRadius, startAngle + 1.5, // 1.5 for slice separator
303
+ endAngle);
304
+ var innerCoords = this.polarToCartesian(half, innerRadius, startAngle + 3, // 3 for slice separator
305
+ endAngle);
306
+ const moveTo = `M ${outerCoords.x1}, ${outerCoords.y1} `;
307
+ const arc1 = this.getArc(outerRadius, largeArcFlagOuter, outerCoords.x2, outerCoords.y2);
308
+ const line = ` L ${innerCoords.x2}, ${innerCoords.y2} `;
309
+ const arc2 = this.getArc(innerRadius, largeArcFlagInner, innerCoords.x1, innerCoords.y1);
310
+ return moveTo + arc1 + line + arc2 + " z";
311
+ }
312
+ getArc(radius, largeArcFlag, x, y) {
313
+ var z = this.toFixed((this.chartData.size / 2) * radius);
314
+ return `A ${z}, ${z} 0 ${largeArcFlag} ${this.toFixed(x)}, ${this.toFixed(y)}`;
315
+ }
316
+ setHybridType() {
317
+ this.hybridType = window.innerWidth > 1340 ? "doughnut0" : "bar1";
318
+ }
319
+ /* GET THE DATA */
320
+ async getData() {
321
+ this.slicesData = [];
322
+ let acc = 0;
323
+ const children = this.el.querySelectorAll("wm-chart-slice");
324
+ this.total = Array.from(children).reduce((total, slice) => (total += parseInt(slice.getAttribute("amount") || "0")), 0);
325
+ children.forEach((c, i) => {
326
+ const amount = parseInt(c.getAttribute("amount") || "0");
327
+ const perc = this.amountToPercent(amount, true);
328
+ // determine whether the slice is in a cluster of small values
329
+ // to avoid percentage text overlap for small values
330
+ const prev = children[i === 0 ? children.length - 1 : i - 1];
331
+ const prevPerc = this.amountToPercent(parseInt(prev.getAttribute("amount") || "0"), true);
332
+ const next = children[i === children.length - 1 ? 0 : i + 1];
333
+ const nextPerc = this.amountToPercent(parseInt(next.getAttribute("amount") || "0"), true);
334
+ const isSmall = perc < 4;
335
+ const prevIsSmall = prevPerc < 5;
336
+ const nextIsSmall = nextPerc < 5;
337
+ let inSmallCluster = isSmall && (prevIsSmall || nextIsSmall);
338
+ // because <1% slice percentage text has an additional character
339
+ // the inSmallCluster threshold needs to be widened for that slice only
340
+ const lessThanOnePerc = perc === 0 && amount > 0;
341
+ if (lessThanOnePerc && (nextPerc < 8 || prevPerc < 8)) {
342
+ inSmallCluster = true;
343
+ }
344
+ // for bar5, first color should be skipped unless notStartedColor is set to true
345
+ const ind = this.currentChartType === "bar5" ? (this.notStartedColor ? i : i + 1) : i;
346
+ const color = this.types[this.currentChartType].colors[ind];
347
+ const sliceData = {
348
+ amount: amount,
349
+ perc: perc,
350
+ legend: c.getAttribute("legend"),
351
+ color: color || "#d4d4d4",
352
+ offset: acc,
353
+ id: `${this.uid}-${i + 1}`,
354
+ title: c.getAttribute("popover-title"),
355
+ text: c.getAttribute("popover-text"),
356
+ buttonText: c.getAttribute("popover-button-text"),
357
+ sliceRef: c,
358
+ inSmallCluster: inSmallCluster,
359
+ };
360
+ acc += amount;
361
+ this.slicesData.push(sliceData);
362
+ });
363
+ this.chartData = this.types[this.currentChartType];
364
+ }
365
+ handleResize() {
366
+ if (this.chartType === "hybrid") {
367
+ this.debouncedResize();
368
+ }
369
+ }
370
+ async componentWillLoad() {
371
+ if (!this.label) {
372
+ throw new Error("For accessibility purposes, you must provide a label for the chart. See https://components.watermarkinsights.com/chart for more information.");
373
+ }
374
+ if (this.showValues) {
375
+ console.warn("wm-chart: show-values has been deprecated as of v3.1.0. Please use value-format instead.");
376
+ }
377
+ if (this.chartType === "hybrid") {
378
+ this.setHybridType();
379
+ }
380
+ await this.getData();
381
+ }
382
+ handleSliceUpdate() {
383
+ this.debouncedSliceUpdate();
384
+ }
385
+ /* RENDERING */
386
+ renderFilter() {
387
+ return (h("defs", null,
388
+ h("filter", { id: "wmHoverDropShadow" },
389
+ h("feGaussianBlur", { stdDeviation: "3" }),
390
+ h("feOffset", { result: "offsetblur" }),
391
+ h("feFlood", { "flood-color": "#333" }),
392
+ h("feComposite", { operator: "in", in2: "offsetblur" }),
393
+ h("feMerge", null,
394
+ h("feMergeNode", null),
395
+ h("feMergeNode", { in: "SourceGraphic" })))));
396
+ }
397
+ // DOUGHNUT
398
+ renderDoughnut() {
399
+ const outerSize = this.chartData.size + this.chartData.padding;
400
+ return (h("div", { class: "chart-wrapper doughnut-wrapper" },
401
+ h("svg", { width: outerSize + "px", height: outerSize + "px", ref: (el) => (this.doughnutEl = el), id: `graphic-${this.uid}`, class: "doughnut-svg" },
402
+ this.renderFilter(),
403
+ this.slicesData.map((s) => this.renderPath(s)),
404
+ this.currentChartType === "doughnut0" ? (h("text", { class: "value", x: "50%", y: "50%", "font-size": "1.5rem", "font-weight": "500", "text-anchor": "middle", "dominant-baseline": "middle" }, this.amountToPercent(this.slicesData[0].amount, true) + "%")) : (h("g", { transform: `translate(${this.chartData.padding / 2}, ${this.chartData.padding / 2})`, "text-anchor": "middle", "dominant-baseline": "middle" }, this.slicesData.map((s) => (s.amount > 0 ? this.renderDoughnutText(s) : "")))))));
405
+ }
406
+ renderPath(s) {
407
+ return (h("g", { transform: `translate(${this.chartData.padding / 2}, ${this.chartData.padding / 2})` },
408
+ h("path", { id: s.id, class: "doughnut-segment", fill: s.amount ? s.color : "transparent", d: this.getPathData(s.amount, s.offset), onClick: (ev) => this.handleSliceClick(ev, s), onFocus: (ev) => this.handleSliceFocus(ev, s), onKeyDown: (ev) => this.handleSliceKeyDown(ev) }),
409
+ h("text", { class: "sr-only" }, s.legend)));
410
+ }
411
+ renderDoughnutText(s) {
412
+ if (!s.inSmallCluster) {
413
+ const arcMiddle = this.amountToDegree(s.offset + s.amount / 2);
414
+ let { x, y } = this.polarToCartesian(this.chartData.size / 2, 1.4, arcMiddle - 90);
415
+ return (h("text", { class: "value", x: x + "px", y: y + "px" }, `${s.perc > 0 ? s.perc : "<1"}%`));
416
+ }
417
+ }
418
+ // BAR
419
+ renderBar() {
420
+ return (h("div", { class: "chart-wrapper bar-wrapper" },
421
+ this.currentChartType === "bar1" ? (h("div", { class: "single-perc" }, this.amountToPercent(this.slicesData[0].amount, true) + "%")) : (""),
422
+ this.drawAxis(),
423
+ h("div", { class: {
424
+ "inner-bar-wrapper": true,
425
+ "show-values": this.tempValueFormat === "percentage" || this.tempValueFormat === "amount",
426
+ } },
427
+ this.currentChartType !== "bar1" ? (h("div", null, this.slicesData.map((s, idx) => (s.perc > 0 ? this.renderBarText(s, idx) : "")))) : (""),
428
+ h("div", { class: "bar-segments-wrapper", ref: (el) => (this.barEl = el) }, this.slicesData.map((s, idx) => this.renderBarSegment(s, idx))),
429
+ this.renderCompletionMessage())));
430
+ }
431
+ renderBarSegment(s, idx) {
432
+ const isLastSlice = idx !== this.slicesData.length - 1;
433
+ const width = `calc(${this.amountToPercent(s.amount, false)}%${isLastSlice ? " - 2px" : ""})`;
434
+ return (h("div", { class: `bar-segment ${this.amountToPercent(s.amount, false) === 0 ? "zero" : ""}`, style: {
435
+ backgroundColor: s.color,
436
+ width: width,
437
+ }, onClick: (ev) => this.handleSliceClick(ev, s), onFocus: (ev) => this.handleSliceFocus(ev, s), onKeyDown: (ev) => this.handleSliceKeyDown(ev) },
438
+ h("text", { class: "sr-only" }, s.legend)));
439
+ }
440
+ renderBarText(s, idx) {
441
+ let val;
442
+ if (this.tempValueFormat === "percentage") {
443
+ val = s.perc + "%";
444
+ }
445
+ else if (this.tempValueFormat === "amount") {
446
+ val = s.amount;
447
+ }
448
+ else {
449
+ return;
450
+ }
451
+ return (h("span", { class: "value", style: {
452
+ width: `calc(${this.amountToPercent(s.amount, false)}%
453
+ ${idx !== this.slicesData.length - 1 ? " - 2px" : ""}`,
454
+ } }, val));
455
+ }
456
+ drawAxis() {
457
+ if (this.currentChartType === "bar3") {
458
+ return (h("svg", { class: "axis" },
459
+ h("line", { x1: "0", x2: "100%", y1: "0", y2: "0" }),
460
+ h("line", { x1: "0", x2: "0", y1: "0", y2: "-85px" }),
461
+ h("line", { class: "tick", x1: "0.5", x2: "0.5", y1: "0", y2: "6" }),
462
+ h("text", { x: "0.5", y: "-6" }, "0%"),
463
+ h("line", { class: "tick", x1: "100%", x2: "100%", y1: "0", y2: "6" }),
464
+ h("text", { x: "100%", y: "-6" }, "100%")));
465
+ }
466
+ }
467
+ renderCompletionMessage() {
468
+ if (this.chartType === "hybrid" && this.completionMessage) {
469
+ return h("div", { class: "completion-message" }, this.completionMessage);
470
+ }
471
+ }
472
+ renderLegend() {
473
+ // legend is hidden for bar1 type regardless of showLegend value
474
+ if (this.showLegend) {
475
+ const hasCluster = this.slicesData.reduce((hasCluster, cur) => (hasCluster = cur.inSmallCluster ? true : hasCluster), false);
476
+ return (h("div", { class: "legend-wrapper" },
477
+ h("div", { class: `legend ${this.chartData.isBar ? "--top" : "--bottom"}`, "aria-hidden": "true" }, this.total > 0
478
+ ? this.slicesData.map((s) => {
479
+ // when both legend and amount are omitted, the legend is not shown for that particular option (it's been deactivated by the user)
480
+ if (!!s.amount || !!s.legend) {
481
+ return (h("div", { class: "legend-item" },
482
+ h("div", { class: "legend-color", style: { "background-color": s.color } }),
483
+ h("div", { class: "legend-text" }, s.legend)));
484
+ }
485
+ })
486
+ : ""),
487
+ !this.chartData.isBar && hasCluster ? (h("div", { class: "cluster-warning" },
488
+ intl.formatMessage({
489
+ id: "chart.hiddenPercentages",
490
+ defaultMessage: "Percentages smaller than 5% are not shown when too close to each other.",
491
+ }),
492
+ h("br", null),
493
+ intl.formatMessage({
494
+ id: "chart.clickToSeeDetails",
495
+ defaultMessage: "Click or use arrow keys to see details.",
496
+ }))) : ("")));
497
+ }
498
+ }
499
+ render() {
500
+ return (h(Host, { role: "application", "aria-label": this.label +
501
+ ", " +
502
+ intl.formatMessage({
503
+ id: "chart.interactiveChart",
504
+ defaultMessage: "Interactive chart. Use arrow keys to browse elements, press Tab to exit.",
505
+ }), tabindex: "0" },
506
+ h("div", { class: `component-wrapper ${this.currentChartType} ${this.isTabbing ? "user-is-tabbing" : ""} ${this.labelPosition === "left" && this.chartType === "bar4" ? "left-label" : ""}` },
507
+ h("label", { class: "label", id: `label-${this.uid}`, htmlFor: `graphic-${this.uid}` },
508
+ h("span", { class: "label-text" }, this.label),
509
+ this.subinfo ? h("span", { class: "subinfo" }, this.subinfo) : ""),
510
+ this.chartData.isBar ? this.renderLegend() : "",
511
+ this.total > 0 && this.chartData.isBar ? this.renderBar() : this.renderDoughnut(),
512
+ !this.chartData.isBar ? this.renderLegend() : "",
513
+ h("priv-chart-popover", { class: this.isTabbing ? "user-is-tabbing" : "", ref: (el) => (this.popoverEl = el) }),
514
+ this.hybridType === "doughnut0" ? this.renderCompletionMessage() : "")));
515
+ }
516
+ static get is() { return "wm-chart"; }
517
+ static get encapsulation() { return "shadow"; }
518
+ static get originalStyleUrls() { return {
519
+ "$": ["wm-chart.scss"]
520
+ }; }
521
+ static get styleUrls() { return {
522
+ "$": ["wm-chart.css"]
523
+ }; }
524
+ static get properties() { return {
525
+ "chartType": {
526
+ "type": "string",
527
+ "mutable": false,
528
+ "complexType": {
529
+ "original": "\"doughnut1\" | \"doughnut2\" | \"doughnut3\" | \"hybrid\" | \"bar1\" | \"bar2\" | \"bar3\" | \"bar4\" | \"bar5\"",
530
+ "resolved": "\"bar1\" | \"bar2\" | \"bar3\" | \"bar4\" | \"bar5\" | \"doughnut1\" | \"doughnut2\" | \"doughnut3\" | \"hybrid\"",
531
+ "references": {}
532
+ },
533
+ "required": false,
534
+ "optional": false,
535
+ "docs": {
536
+ "tags": [],
537
+ "text": ""
538
+ },
539
+ "attribute": "chart-type",
540
+ "reflect": false,
541
+ "defaultValue": "\"doughnut1\""
542
+ },
543
+ "label": {
544
+ "type": "string",
545
+ "mutable": false,
546
+ "complexType": {
547
+ "original": "string",
548
+ "resolved": "string | undefined",
549
+ "references": {}
550
+ },
551
+ "required": false,
552
+ "optional": true,
553
+ "docs": {
554
+ "tags": [],
555
+ "text": ""
556
+ },
557
+ "attribute": "label",
558
+ "reflect": false
559
+ },
560
+ "subinfo": {
561
+ "type": "string",
562
+ "mutable": false,
563
+ "complexType": {
564
+ "original": "string",
565
+ "resolved": "string | undefined",
566
+ "references": {}
567
+ },
568
+ "required": false,
569
+ "optional": true,
570
+ "docs": {
571
+ "tags": [],
572
+ "text": ""
573
+ },
574
+ "attribute": "subinfo",
575
+ "reflect": false
576
+ },
577
+ "completionMessage": {
578
+ "type": "string",
579
+ "mutable": false,
580
+ "complexType": {
581
+ "original": "string",
582
+ "resolved": "string | undefined",
583
+ "references": {}
584
+ },
585
+ "required": false,
586
+ "optional": true,
587
+ "docs": {
588
+ "tags": [],
589
+ "text": ""
590
+ },
591
+ "attribute": "completion-message",
592
+ "reflect": false
593
+ },
594
+ "valueFormat": {
595
+ "type": "string",
596
+ "mutable": false,
597
+ "complexType": {
598
+ "original": "\"percentage\" | \"amount\"",
599
+ "resolved": "\"amount\" | \"percentage\" | undefined",
600
+ "references": {}
601
+ },
602
+ "required": false,
603
+ "optional": true,
604
+ "docs": {
605
+ "tags": [],
606
+ "text": ""
607
+ },
608
+ "attribute": "value-format",
609
+ "reflect": false
610
+ },
611
+ "showValues": {
612
+ "type": "string",
613
+ "mutable": false,
614
+ "complexType": {
615
+ "original": "\"percentage\" | \"amount\"",
616
+ "resolved": "\"amount\" | \"percentage\" | undefined",
617
+ "references": {}
618
+ },
619
+ "required": false,
620
+ "optional": true,
621
+ "docs": {
622
+ "tags": [],
623
+ "text": ""
624
+ },
625
+ "attribute": "show-values",
626
+ "reflect": false
627
+ },
628
+ "showLegend": {
629
+ "type": "boolean",
630
+ "mutable": false,
631
+ "complexType": {
632
+ "original": "boolean",
633
+ "resolved": "boolean",
634
+ "references": {}
635
+ },
636
+ "required": false,
637
+ "optional": false,
638
+ "docs": {
639
+ "tags": [],
640
+ "text": ""
641
+ },
642
+ "attribute": "show-legend",
643
+ "reflect": false,
644
+ "defaultValue": "true"
645
+ },
646
+ "notStartedColor": {
647
+ "type": "boolean",
648
+ "mutable": false,
649
+ "complexType": {
650
+ "original": "boolean",
651
+ "resolved": "boolean",
652
+ "references": {}
653
+ },
654
+ "required": false,
655
+ "optional": false,
656
+ "docs": {
657
+ "tags": [],
658
+ "text": ""
659
+ },
660
+ "attribute": "not-started-color",
661
+ "reflect": false,
662
+ "defaultValue": "false"
663
+ },
664
+ "labelPosition": {
665
+ "type": "string",
666
+ "mutable": false,
667
+ "complexType": {
668
+ "original": "\"left\" | \"top\"",
669
+ "resolved": "\"left\" | \"top\"",
670
+ "references": {}
671
+ },
672
+ "required": false,
673
+ "optional": false,
674
+ "docs": {
675
+ "tags": [],
676
+ "text": ""
677
+ },
678
+ "attribute": "label-position",
679
+ "reflect": false,
680
+ "defaultValue": "\"top\""
681
+ }
682
+ }; }
683
+ static get states() { return {
684
+ "isTabbing": {}
685
+ }; }
686
+ static get elementRef() { return "el"; }
687
+ static get listeners() { return [{
688
+ "name": "wmUserIsTabbing",
689
+ "method": "toggleTabbingOn",
690
+ "target": "window",
691
+ "capture": false,
692
+ "passive": false
693
+ }, {
694
+ "name": "wmUserIsNotTabbing",
695
+ "method": "toggleTabbingOff",
696
+ "target": "window",
697
+ "capture": false,
698
+ "passive": false
699
+ }, {
700
+ "name": "keydown",
701
+ "method": "handleKeydown",
702
+ "target": undefined,
703
+ "capture": false,
704
+ "passive": false
705
+ }, {
706
+ "name": "resize",
707
+ "method": "handleResize",
708
+ "target": "window",
709
+ "capture": false,
710
+ "passive": true
711
+ }, {
712
+ "name": "wmChartSliceUpdated",
713
+ "method": "handleSliceUpdate",
714
+ "target": undefined,
715
+ "capture": false,
716
+ "passive": false
717
+ }]; }
718
+ }