@designsystem-se/af 32.3.1-beta.1 → 33.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (400) hide show
  1. package/components/digi-bar-chart.js +1 -1
  2. package/components/digi-calendar-datepicker.js +3 -4
  3. package/components/digi-calendar-week-view.js +1 -1
  4. package/components/digi-calendar.js +1 -1
  5. package/components/digi-card.js +1 -1
  6. package/components/digi-chart-line.js +1 -1
  7. package/components/digi-code-block.js +1 -1
  8. package/components/digi-code-example.js +9 -7
  9. package/components/digi-context-menu.js +151 -52
  10. package/components/digi-dialog.js +3 -4
  11. package/components/digi-expandable-accordion.js +2 -3
  12. package/components/digi-expandable-faq-item.js +1 -1
  13. package/components/digi-footer.js +2 -3
  14. package/components/digi-form-error-list.js +3 -4
  15. package/components/digi-form-file-upload.js +1 -1
  16. package/components/digi-form-receipt.js +1 -2
  17. package/components/digi-form-select-filter.js +2 -3
  18. package/components/digi-header-avatar.js +2 -2
  19. package/components/digi-header-navigation.js +3 -4
  20. package/components/digi-header.js +3 -4
  21. package/components/digi-info-card-multi.js +4 -4
  22. package/components/digi-info-card.js +1 -1
  23. package/components/digi-list.js +1 -1
  24. package/components/digi-loader-spinner.js +1 -1
  25. package/components/digi-media-image.js +1 -1
  26. package/components/digi-navigation-context-menu.js +1 -1
  27. package/components/digi-navigation-pagination.js +9 -10
  28. package/components/digi-navigation-sidebar-button.js +1 -1
  29. package/components/digi-navigation-sidebar.js +4 -4
  30. package/components/digi-navigation-vertical-menu-item.js +6 -6
  31. package/components/digi-navigation-vertical-menu.js +1 -1
  32. package/components/digi-notification-alert.js +1 -1
  33. package/components/digi-notification-error-page.js +7 -15
  34. package/components/digi-progress-circle.js +12 -8
  35. package/components/digi-progress-indicator.js +7 -3
  36. package/components/digi-progress-list-item.js +5 -5
  37. package/components/digi-progress-list.js +2 -2
  38. package/components/digi-progressbar.js +2 -2
  39. package/components/digi-quote.js +3 -3
  40. package/components/digi-table.js +1 -1
  41. package/components/digi-tablist-panel.js +2 -2
  42. package/components/digi-tablist.js +5 -5
  43. package/components/digi-tag-media.js +1 -1
  44. package/components/digi-tag.js +5 -3
  45. package/components/digi-tools-feedback-banner.js +1 -1
  46. package/components/digi-tools-feedback-rating.js +3 -3
  47. package/components/digi-tools-feedback.js +2 -3
  48. package/components/digi-tools-languagepicker.js +5 -5
  49. package/components/digi-typography-heading-jumbo.js +6 -2
  50. package/components/digi-typography-meta.js +37 -1
  51. package/components/digi-typography-preamble.js +1 -1
  52. package/components/digi-typography-time.js +1 -1
  53. package/components/digi-typography.js +1 -1
  54. package/components/digi-util-breakpoint-observer.js +1 -1
  55. package/components/digi-util-detect-click-outside.js +1 -1
  56. package/components/digi-util-detect-focus-outside.js +1 -1
  57. package/components/digi-util-intersection-observer.js +1 -1
  58. package/components/digi-util-keydown-handler.js +1 -1
  59. package/components/digi-util-keyup-handler.js +1 -1
  60. package/components/digi-util-resize-observer.js +1 -1
  61. package/components/index.d.ts +0 -6
  62. package/components/index.js +1 -5
  63. package/components/{p-d7211fec.js → p-2b4c472b.js} +1 -11
  64. package/components/{p-1ee02c0b.js → p-38b0d0c7.js} +1 -2
  65. package/components/{p-e87d124f.js → p-4b8bc232.js} +1 -1
  66. package/components/{p-ed121585.js → p-50634baa.js} +1 -1
  67. package/components/{p-83e38978.js → p-5e487ed4.js} +1 -1
  68. package/components/{p-dfa85da0.js → p-8a1aaa8e.js} +6 -6
  69. package/components/{p-809fd710.js → p-918e9955.js} +2 -2
  70. package/components/{p-23d4119d.js → p-950b05b1.js} +1 -1
  71. package/components/{p-f034b64e.js → p-aa59e5c0.js} +1 -1
  72. package/components/{p-af7ab137.js → p-d08de295.js} +1 -1
  73. package/components/{p-648cd0b2.js → p-ef49c2f8.js} +4 -5
  74. package/components/{p-2bfb4163.js → p-f0bdf339.js} +1 -1
  75. package/components/{p-71554a36.js → p-f3c5a743.js} +1 -1
  76. package/custom-elements.json +11 -120
  77. package/dist/cjs/digi-arbetsformedlingen.cjs.js +1 -1
  78. package/dist/cjs/digi-button_6.cjs.entry.js +246 -2301
  79. package/dist/cjs/digi-calendar-datepicker.cjs.entry.js +3 -4
  80. package/dist/cjs/digi-chart-line.cjs.entry.js +2314 -0
  81. package/dist/cjs/digi-code-block_3.cjs.entry.js +3 -4
  82. package/dist/cjs/digi-code-example.cjs.entry.js +7 -5
  83. package/dist/cjs/digi-dialog.cjs.entry.js +3 -4
  84. package/dist/cjs/digi-expandable-accordion.cjs.entry.js +3 -4
  85. package/dist/cjs/digi-footer.cjs.entry.js +3 -4
  86. package/dist/cjs/digi-form-error-list.cjs.entry.js +3 -4
  87. package/dist/cjs/digi-form-receipt.cjs.entry.js +3 -4
  88. package/dist/cjs/digi-form-select-filter.cjs.entry.js +3 -4
  89. package/dist/cjs/digi-header-navigation.cjs.entry.js +3 -4
  90. package/dist/cjs/digi-header.cjs.entry.js +4 -5
  91. package/dist/cjs/digi-icon-chart_2.cjs.entry.js +53 -0
  92. package/dist/cjs/digi-icon-language-outline_4.cjs.entry.js +5 -5
  93. package/dist/cjs/digi-icon-x.cjs.entry.js +30 -0
  94. package/dist/cjs/digi-layout-block.cjs.entry.js +47 -0
  95. package/dist/cjs/digi-loader-spinner.cjs.entry.js +1 -1
  96. package/dist/cjs/digi-logo_2.cjs.entry.js +1 -1
  97. package/dist/cjs/digi-media-image_2.cjs.entry.js +1 -1
  98. package/dist/cjs/digi-navigation-pagination.cjs.entry.js +9 -10
  99. package/dist/cjs/digi-navigation-sidebar.cjs.entry.js +2 -2
  100. package/dist/cjs/digi-navigation-vertical-menu-item.cjs.entry.js +6 -6
  101. package/dist/cjs/digi-navigation-vertical-menu.cjs.entry.js +1 -1
  102. package/dist/cjs/digi-notification-alert.cjs.entry.js +5 -6
  103. package/dist/cjs/digi-notification-error-page.cjs.entry.js +7 -15
  104. package/dist/cjs/digi-progress-circle.cjs.entry.js +12 -8
  105. package/dist/cjs/digi-progress-indicator.cjs.entry.js +7 -3
  106. package/dist/cjs/digi-progress-list-item.cjs.entry.js +5 -5
  107. package/dist/cjs/digi-progress-list.cjs.entry.js +1 -1
  108. package/dist/cjs/digi-progressbar.cjs.entry.js +2 -2
  109. package/dist/cjs/digi-quote.cjs.entry.js +1 -1
  110. package/dist/cjs/digi-table.cjs.entry.js +1 -1
  111. package/dist/cjs/digi-tablist-panel.cjs.entry.js +2 -2
  112. package/dist/cjs/digi-tablist.cjs.entry.js +5 -5
  113. package/dist/cjs/digi-tag-media.cjs.entry.js +2 -2
  114. package/dist/cjs/digi-tag.cjs.entry.js +3 -2
  115. package/dist/cjs/digi-tools-feedback-banner.cjs.entry.js +1 -1
  116. package/dist/cjs/digi-tools-feedback-rating.cjs.entry.js +2 -2
  117. package/dist/cjs/digi-tools-feedback.cjs.entry.js +4 -5
  118. package/dist/cjs/digi-tools-languagepicker.cjs.entry.js +3 -3
  119. package/dist/cjs/digi-typography-heading-jumbo.cjs.entry.js +6 -2
  120. package/dist/cjs/digi-typography-meta.cjs.entry.js +1 -1
  121. package/dist/cjs/digi-typography-preamble.cjs.entry.js +1 -1
  122. package/dist/cjs/digi-typography-time.cjs.entry.js +1 -1
  123. package/dist/cjs/digi-util-breakpoint-observer.cjs.entry.js +1 -1
  124. package/dist/cjs/digi-util-detect-click-outside.cjs.entry.js +1 -1
  125. package/dist/cjs/digi-util-detect-focus-outside.cjs.entry.js +1 -1
  126. package/dist/cjs/digi-util-keydown-handler.cjs.entry.js +1 -1
  127. package/dist/cjs/digi-util-keyup-handler.cjs.entry.js +1 -1
  128. package/dist/cjs/digi-util-resize-observer.cjs.entry.js +1 -1
  129. package/dist/cjs/index-cfa8e9be.js +18 -30
  130. package/dist/cjs/index.cjs.js +22 -35
  131. package/dist/cjs/layout-block-container.enum-52ae6994.js +8 -0
  132. package/dist/cjs/loader.cjs.js +1 -1
  133. package/dist/cjs/{tools-feedback-variation.enum-4547e1e3.js → tools-feedback-variation.enum-2ac9956e.js} +0 -10
  134. package/dist/cjs/{layout-container-max-width.enum-7e637f44.js → typography-variation.enum-d7083728.js} +6 -7
  135. package/dist/collection/collection-manifest.json +0 -3
  136. package/dist/collection/components/_code/code-example/code-example.js +7 -5
  137. package/dist/collection/components/_loader/loader-spinner/loader-spinner.css +1 -0
  138. package/dist/collection/components/_navigation/navigation-context-menu/navigation-context-menu.css +85 -172
  139. package/dist/collection/components/_navigation/navigation-context-menu/navigation-context-menu.js +190 -62
  140. package/dist/collection/components/_navigation/navigation-context-menu-legacy/navigation-context-menu.js +5 -5
  141. package/dist/collection/components/_navigation/navigation-pagination/navigation-pagination.js +6 -6
  142. package/dist/collection/components/_navigation/navigation-sidebar/navigation-sidebar.js +2 -2
  143. package/dist/collection/components/_navigation/navigation-sidebar-button/navigation-sidebar-button.js +1 -1
  144. package/dist/collection/components/_navigation/navigation-tablist/navigation-tablist.js +5 -5
  145. package/dist/collection/components/_navigation/navigation-tablist-panel/tablist-panel.js +2 -2
  146. package/dist/collection/components/_navigation/navigation-vertical-menu/navigation-vertical-menu.js +1 -1
  147. package/dist/collection/components/_navigation/navigation-vertical-menu-item/navigation-vertical-menu-item.js +6 -6
  148. package/dist/collection/components/_notification/notification-alert/notification-alert.js +2 -2
  149. package/dist/collection/components/_notification/notification-error-page/illustrations/illustrations.js +7 -7
  150. package/dist/collection/components/_notification/notification-error-page/notification-error-page.js +3 -3
  151. package/dist/collection/components/_progress/progress-circle/progress-circle.js +12 -8
  152. package/dist/collection/components/_progress/progress-indicator/progress-indicator.js +7 -3
  153. package/dist/collection/components/_progress/progress-list/progress-list.js +1 -1
  154. package/dist/collection/components/_progress/progress-list-item/progress-list-item.js +5 -5
  155. package/dist/collection/components/_progress/progressbar/progressbar.js +2 -2
  156. package/dist/collection/components/_quote/quote/quote.js +1 -2
  157. package/dist/collection/components/_table/table/table.js +1 -1
  158. package/dist/collection/components/_tag/tag/tag.css +10 -0
  159. package/dist/collection/components/_tag/tag/tag.js +25 -1
  160. package/dist/collection/components/_tag/tag-media/tag-media.js +2 -2
  161. package/dist/collection/components/_tools/tools-feedback/tools-feedback.js +1 -1
  162. package/dist/collection/components/_tools/tools-feedback-banner/tools-feedback-banner.js +1 -1
  163. package/dist/collection/components/_tools/tools-feedback-rating/tools-feedback-rating.js +2 -2
  164. package/dist/collection/components/_tools/tools-languagepicker/tools-languagepicker.js +4 -4
  165. package/dist/collection/components/_typography/typography/typography.js +1 -1
  166. package/dist/collection/components/_typography/typography-heading-jumbo/typography-heading-jumbo.js +6 -2
  167. package/dist/collection/components/_typography/typography-meta/typography-meta.js +1 -1
  168. package/dist/collection/components/_typography/typography-preamble/typography-preamble.js +1 -1
  169. package/dist/collection/components/_typography/typography-time/typography-time.js +1 -1
  170. package/dist/collection/components/_util/util-breakpoint-observer/util-breakpoint-observer.js +1 -1
  171. package/dist/collection/components/_util/util-detect-click-outside/util-detect-click-outside.js +1 -1
  172. package/dist/collection/components/_util/util-detect-focus-outside/util-detect-focus-outside.js +1 -1
  173. package/dist/collection/components/_util/util-intersection-observer/util-intersection-observer.js +1 -1
  174. package/dist/collection/components/_util/util-keydown-handler/util-keydown-handler.js +1 -1
  175. package/dist/collection/components/_util/util-keyup-handler/util-keyup-handler.js +1 -1
  176. package/dist/collection/components/_util/util-resize-observer/util-resize-observer.js +1 -1
  177. package/dist/collection/design-tokens/components/_navigation-context-menu.variables.scss +3 -47
  178. package/dist/collection/design-tokens/css/variables.css +3 -0
  179. package/dist/collection/design-tokens/scss/variables.scss +3 -0
  180. package/dist/collection/design-tokens/styleguide/web.json +57 -0
  181. package/dist/collection/design-tokens/styleguide/web.scss +3 -0
  182. package/dist/collection/enums.js +0 -2
  183. package/dist/collection/interfaces.js +0 -1
  184. package/dist/digi-arbetsformedlingen/design-tokens/components/_navigation-context-menu.variables.scss +41 -45
  185. package/dist/digi-arbetsformedlingen/design-tokens/css/variables.css +3 -0
  186. package/dist/digi-arbetsformedlingen/design-tokens/scss/variables.scss +3 -0
  187. package/dist/digi-arbetsformedlingen/design-tokens/styleguide/web.json +57 -0
  188. package/dist/digi-arbetsformedlingen/design-tokens/styleguide/web.scss +3 -0
  189. package/dist/digi-arbetsformedlingen/digi-arbetsformedlingen.css +1 -1
  190. package/dist/digi-arbetsformedlingen/digi-arbetsformedlingen.esm.js +1 -1
  191. package/dist/digi-arbetsformedlingen/index.esm.js +1 -1
  192. package/dist/digi-arbetsformedlingen/p-005c72ca.entry.js +1 -0
  193. package/dist/digi-arbetsformedlingen/p-028dd0d4.js +1 -0
  194. package/dist/digi-arbetsformedlingen/{p-5a7a3e3d.entry.js → p-04ca1ba6.entry.js} +1 -1
  195. package/dist/digi-arbetsformedlingen/p-0551a242.entry.js +1 -0
  196. package/dist/digi-arbetsformedlingen/{p-a64f6920.entry.js → p-0f485fa7.entry.js} +1 -1
  197. package/dist/digi-arbetsformedlingen/p-14368210.entry.js +1 -0
  198. package/dist/digi-arbetsformedlingen/p-16aa5a85.entry.js +1 -0
  199. package/dist/digi-arbetsformedlingen/{p-b1759898.entry.js → p-1d3f7336.entry.js} +1 -1
  200. package/dist/digi-arbetsformedlingen/{p-a4727186.entry.js → p-20a65f1c.entry.js} +1 -1
  201. package/dist/digi-arbetsformedlingen/p-2af9b440.js +1 -0
  202. package/dist/digi-arbetsformedlingen/{p-d3ad14b2.entry.js → p-2f79bfcc.entry.js} +1 -1
  203. package/dist/digi-arbetsformedlingen/{p-11a56b7a.entry.js → p-346297b2.entry.js} +1 -1
  204. package/dist/digi-arbetsformedlingen/{p-ca626e5c.entry.js → p-349f73d9.entry.js} +1 -1
  205. package/dist/digi-arbetsformedlingen/{p-6b57023d.entry.js → p-3ee7d913.entry.js} +1 -1
  206. package/dist/digi-arbetsformedlingen/{p-816ed242.entry.js → p-3fde4aec.entry.js} +1 -1
  207. package/dist/digi-arbetsformedlingen/p-40a81c4a.entry.js +1 -0
  208. package/dist/digi-arbetsformedlingen/{p-edda9cea.entry.js → p-419d99f0.entry.js} +1 -1
  209. package/dist/digi-arbetsformedlingen/p-4638e6b1.entry.js +1 -0
  210. package/dist/digi-arbetsformedlingen/{p-c2bec230.entry.js → p-48664690.entry.js} +1 -1
  211. package/dist/digi-arbetsformedlingen/p-4fa41b6b.entry.js +1 -0
  212. package/dist/digi-arbetsformedlingen/{p-bbad90a7.entry.js → p-57665401.entry.js} +1 -1
  213. package/dist/digi-arbetsformedlingen/p-59d1de44.entry.js +1 -0
  214. package/dist/digi-arbetsformedlingen/p-64609e83.entry.js +1 -0
  215. package/dist/digi-arbetsformedlingen/{p-61e92fa9.entry.js → p-66b0d3c6.entry.js} +1 -1
  216. package/dist/digi-arbetsformedlingen/{p-0a6f6df3.entry.js → p-68886e60.entry.js} +1 -1
  217. package/dist/digi-arbetsformedlingen/{p-699e385a.entry.js → p-7bbee718.entry.js} +1 -1
  218. package/dist/digi-arbetsformedlingen/p-7f4f58d5.entry.js +1 -0
  219. package/dist/digi-arbetsformedlingen/p-81cac8dd.entry.js +1 -0
  220. package/dist/digi-arbetsformedlingen/p-860e37c2.entry.js +1 -0
  221. package/dist/digi-arbetsformedlingen/p-8f42a48e.entry.js +1 -0
  222. package/dist/digi-arbetsformedlingen/{p-9a53b638.entry.js → p-9657af86.entry.js} +1 -1
  223. package/dist/digi-arbetsformedlingen/{p-9d5f4dd0.entry.js → p-966ea804.entry.js} +1 -1
  224. package/dist/digi-arbetsformedlingen/p-9a06e85b.entry.js +1 -0
  225. package/dist/digi-arbetsformedlingen/{p-cccdb2c8.entry.js → p-9d8d64fa.entry.js} +1 -1
  226. package/dist/digi-arbetsformedlingen/{p-caf79640.entry.js → p-a6fcc0f7.entry.js} +1 -1
  227. package/dist/digi-arbetsformedlingen/p-a7970fe3.entry.js +1 -0
  228. package/dist/digi-arbetsformedlingen/{p-eb7ca274.entry.js → p-affe6eac.entry.js} +1 -1
  229. package/dist/digi-arbetsformedlingen/p-b77ea3a1.entry.js +1 -0
  230. package/dist/digi-arbetsformedlingen/{p-70d542da.entry.js → p-ba740002.entry.js} +1 -1
  231. package/dist/digi-arbetsformedlingen/p-bad82d8a.entry.js +1 -0
  232. package/dist/digi-arbetsformedlingen/p-bd56d622.entry.js +1 -0
  233. package/dist/digi-arbetsformedlingen/p-c16371b2.entry.js +1 -0
  234. package/dist/digi-arbetsformedlingen/{p-7b7c092f.entry.js → p-c16e6afe.entry.js} +1 -1
  235. package/dist/digi-arbetsformedlingen/p-c2a5da97.js +1 -0
  236. package/dist/digi-arbetsformedlingen/{p-8fc1143f.js → p-c2ee26cb.js} +1 -1
  237. package/dist/digi-arbetsformedlingen/{p-c750cc28.entry.js → p-d630f2e9.entry.js} +1 -1
  238. package/dist/digi-arbetsformedlingen/{p-9c72fecd.entry.js → p-e07fed59.entry.js} +1 -1
  239. package/dist/digi-arbetsformedlingen/p-e361c7bb.entry.js +1 -0
  240. package/dist/digi-arbetsformedlingen/p-edd43c5d.entry.js +1 -0
  241. package/dist/digi-arbetsformedlingen/p-ee5f2630.entry.js +1 -0
  242. package/dist/digi-arbetsformedlingen/p-eedd8fdb.entry.js +1 -0
  243. package/dist/digi-arbetsformedlingen/{p-305a1547.entry.js → p-f0cdaac5.entry.js} +1 -1
  244. package/dist/digi-arbetsformedlingen/{p-0873a381.entry.js → p-f427db52.entry.js} +1 -1
  245. package/dist/digi-arbetsformedlingen/{p-22beda0f.entry.js → p-f84d9dea.entry.js} +1 -1
  246. package/dist/digi-arbetsformedlingen/p-fa7824e9.entry.js +1 -0
  247. package/dist/digi-arbetsformedlingen/p-fa890d2b.entry.js +1 -0
  248. package/dist/esm/digi-arbetsformedlingen.js +1 -1
  249. package/dist/esm/digi-bar-chart.entry.js +1 -1
  250. package/dist/esm/digi-button_6.entry.js +243 -2298
  251. package/dist/esm/digi-calendar-datepicker.entry.js +3 -4
  252. package/dist/esm/digi-chart-line.entry.js +2310 -0
  253. package/dist/esm/digi-code-block_3.entry.js +3 -4
  254. package/dist/esm/digi-code-example.entry.js +7 -5
  255. package/dist/esm/digi-dialog.entry.js +3 -4
  256. package/dist/esm/digi-expandable-accordion.entry.js +3 -4
  257. package/dist/esm/digi-footer.entry.js +3 -4
  258. package/dist/esm/digi-form-error-list.entry.js +3 -4
  259. package/dist/esm/digi-form-receipt.entry.js +3 -4
  260. package/dist/esm/digi-form-select-filter.entry.js +3 -4
  261. package/dist/esm/digi-header-navigation.entry.js +3 -4
  262. package/dist/esm/digi-header.entry.js +3 -4
  263. package/dist/esm/digi-icon-chart_2.entry.js +48 -0
  264. package/dist/esm/digi-icon-language-outline_4.entry.js +5 -5
  265. package/dist/esm/digi-icon-x.entry.js +26 -0
  266. package/dist/esm/digi-layout-block.entry.js +43 -0
  267. package/dist/esm/digi-loader-spinner.entry.js +1 -1
  268. package/dist/esm/digi-logo_2.entry.js +1 -1
  269. package/dist/esm/digi-media-image_2.entry.js +1 -1
  270. package/dist/esm/digi-navigation-pagination.entry.js +9 -10
  271. package/dist/esm/digi-navigation-sidebar.entry.js +2 -2
  272. package/dist/esm/digi-navigation-vertical-menu-item.entry.js +6 -6
  273. package/dist/esm/digi-navigation-vertical-menu.entry.js +1 -1
  274. package/dist/esm/digi-notification-alert.entry.js +5 -6
  275. package/dist/esm/digi-notification-error-page.entry.js +7 -15
  276. package/dist/esm/digi-progress-circle.entry.js +12 -8
  277. package/dist/esm/digi-progress-indicator.entry.js +7 -3
  278. package/dist/esm/digi-progress-list-item.entry.js +5 -5
  279. package/dist/esm/digi-progress-list.entry.js +1 -1
  280. package/dist/esm/digi-progressbar.entry.js +2 -2
  281. package/dist/esm/digi-quote.entry.js +1 -1
  282. package/dist/esm/digi-table.entry.js +1 -1
  283. package/dist/esm/digi-tablist-panel.entry.js +2 -2
  284. package/dist/esm/digi-tablist.entry.js +5 -5
  285. package/dist/esm/digi-tag-media.entry.js +2 -2
  286. package/dist/esm/digi-tag.entry.js +3 -2
  287. package/dist/esm/digi-tools-feedback-banner.entry.js +1 -1
  288. package/dist/esm/digi-tools-feedback-rating.entry.js +2 -2
  289. package/dist/esm/digi-tools-feedback.entry.js +4 -5
  290. package/dist/esm/digi-tools-languagepicker.entry.js +3 -3
  291. package/dist/esm/digi-typography-heading-jumbo.entry.js +6 -2
  292. package/dist/esm/digi-typography-meta.entry.js +1 -1
  293. package/dist/esm/digi-typography-preamble.entry.js +1 -1
  294. package/dist/esm/digi-typography-time.entry.js +1 -1
  295. package/dist/esm/digi-util-breakpoint-observer.entry.js +1 -1
  296. package/dist/esm/digi-util-detect-click-outside.entry.js +1 -1
  297. package/dist/esm/digi-util-detect-focus-outside.entry.js +1 -1
  298. package/dist/esm/digi-util-keydown-handler.entry.js +1 -1
  299. package/dist/esm/digi-util-keyup-handler.entry.js +1 -1
  300. package/dist/esm/digi-util-resize-observer.entry.js +1 -1
  301. package/dist/esm/index-8e318bb2.js +18 -30
  302. package/dist/esm/index.js +3 -4
  303. package/dist/esm/layout-block-container.enum-29d52ee9.js +8 -0
  304. package/dist/esm/{linear-f59f8318.js → linear-ef018ffb.js} +1 -1
  305. package/dist/esm/loader.js +1 -1
  306. package/dist/esm/{tools-feedback-variation.enum-92d10df2.js → tools-feedback-variation.enum-45abb679.js} +1 -11
  307. package/dist/esm/{layout-container-max-width.enum-c40018ac.js → typography-variation.enum-d9fdbf06.js} +7 -8
  308. package/dist/types/components/_code/code-example/code-example.d.ts +1 -0
  309. package/dist/types/components/_navigation/navigation-context-menu/navigation-context-menu.d.ts +52 -14
  310. package/dist/types/components/_navigation/navigation-context-menu/navigation-context-menu.types.d.ts +7 -3
  311. package/dist/types/components/_progress/progress-circle/progress-circle.d.ts +4 -0
  312. package/dist/types/components/_progress/progress-indicator/progress-indicator.d.ts +4 -0
  313. package/dist/types/components/_quote/quote/quote.d.ts +0 -1
  314. package/dist/types/components/_tag/tag/tag.d.ts +4 -0
  315. package/dist/types/components/_tools/tools-languagepicker/tools-languagepicker.d.ts +1 -1
  316. package/dist/types/components/_typography/typography-heading-jumbo/typography-heading-jumbo.d.ts +4 -0
  317. package/dist/types/components.d.ts +77 -220
  318. package/dist/types/enums.d.ts +0 -2
  319. package/dist/types/interfaces.d.ts +0 -1
  320. package/hydrate/index.js +250 -451
  321. package/hydrate/index.mjs +250 -451
  322. package/package.json +1 -1
  323. package/components/digi-navigation-dropdown.d.ts +0 -11
  324. package/components/digi-navigation-dropdown.js +0 -6
  325. package/components/digi-quote-multi-container.d.ts +0 -11
  326. package/components/digi-quote-multi-container.js +0 -39
  327. package/components/digi-quote-single.d.ts +0 -11
  328. package/components/digi-quote-single.js +0 -63
  329. package/components/p-3f827c1d.js +0 -39
  330. package/components/p-8fa816d6.js +0 -8
  331. package/components/p-e308ef6b.js +0 -221
  332. package/dist/cjs/digi-context-menu.cjs.entry.js +0 -132
  333. package/dist/cjs/digi-icon-check.cjs.entry.js +0 -30
  334. package/dist/cjs/digi-icon-chevron-down.cjs.entry.js +0 -30
  335. package/dist/cjs/digi-layout-block_2.cjs.entry.js +0 -92
  336. package/dist/cjs/digi-navigation-dropdown.cjs.entry.js +0 -188
  337. package/dist/cjs/digi-quote-multi-container.cjs.entry.js +0 -23
  338. package/dist/cjs/digi-quote-single.cjs.entry.js +0 -33
  339. package/dist/cjs/quote-single-variation.enum-53f94dbc.js +0 -8
  340. package/dist/cjs/typography-variation.enum-5b035b3b.js +0 -7
  341. package/dist/collection/components/_navigation/navigation-dropdown/navigation-dropdown.css +0 -319
  342. package/dist/collection/components/_navigation/navigation-dropdown/navigation-dropdown.js +0 -539
  343. package/dist/collection/components/_navigation/navigation-dropdown/navigation-dropdown.types.js +0 -1
  344. package/dist/collection/components/_quote/quote-multi-container/quote-multi-container-heading-level.enum.js +0 -9
  345. package/dist/collection/components/_quote/quote-multi-container/quote-multi-container.css +0 -26
  346. package/dist/collection/components/_quote/quote-multi-container/quote-multi-container.js +0 -86
  347. package/dist/collection/components/_quote/quote-single/quote-single-variation.enum.js +0 -6
  348. package/dist/collection/components/_quote/quote-single/quote.css +0 -324
  349. package/dist/collection/components/_quote/quote-single/quote.js +0 -141
  350. package/dist/collection/design-tokens/components/_quote-quote-multi-container.variables.scss +0 -5
  351. package/dist/collection/design-tokens/components/_quote-single.variables.scss +0 -14
  352. package/dist/digi-arbetsformedlingen/design-tokens/components/_quote-quote-multi-container.variables.scss +0 -5
  353. package/dist/digi-arbetsformedlingen/design-tokens/components/_quote-single.variables.scss +0 -14
  354. package/dist/digi-arbetsformedlingen/p-02646d18.entry.js +0 -1
  355. package/dist/digi-arbetsformedlingen/p-0eac1bee.js +0 -1
  356. package/dist/digi-arbetsformedlingen/p-125dd887.entry.js +0 -1
  357. package/dist/digi-arbetsformedlingen/p-167234fc.entry.js +0 -1
  358. package/dist/digi-arbetsformedlingen/p-195cf497.entry.js +0 -1
  359. package/dist/digi-arbetsformedlingen/p-25faef21.entry.js +0 -1
  360. package/dist/digi-arbetsformedlingen/p-300aa9ef.js +0 -1
  361. package/dist/digi-arbetsformedlingen/p-331e95be.entry.js +0 -1
  362. package/dist/digi-arbetsformedlingen/p-4028ad65.entry.js +0 -1
  363. package/dist/digi-arbetsformedlingen/p-45fe2828.entry.js +0 -1
  364. package/dist/digi-arbetsformedlingen/p-4c6f74fb.entry.js +0 -1
  365. package/dist/digi-arbetsformedlingen/p-4e9b1820.entry.js +0 -1
  366. package/dist/digi-arbetsformedlingen/p-51706444.entry.js +0 -1
  367. package/dist/digi-arbetsformedlingen/p-7cb35359.entry.js +0 -1
  368. package/dist/digi-arbetsformedlingen/p-81e86ac1.entry.js +0 -1
  369. package/dist/digi-arbetsformedlingen/p-848aa358.entry.js +0 -1
  370. package/dist/digi-arbetsformedlingen/p-87c1f5c7.entry.js +0 -1
  371. package/dist/digi-arbetsformedlingen/p-8fa816d6.js +0 -1
  372. package/dist/digi-arbetsformedlingen/p-903b00e6.js +0 -1
  373. package/dist/digi-arbetsformedlingen/p-994395cb.entry.js +0 -1
  374. package/dist/digi-arbetsformedlingen/p-a06dd644.entry.js +0 -1
  375. package/dist/digi-arbetsformedlingen/p-a272c883.entry.js +0 -1
  376. package/dist/digi-arbetsformedlingen/p-a6d806e5.entry.js +0 -1
  377. package/dist/digi-arbetsformedlingen/p-d7fe697e.entry.js +0 -1
  378. package/dist/digi-arbetsformedlingen/p-de4c4238.entry.js +0 -1
  379. package/dist/digi-arbetsformedlingen/p-e092908a.entry.js +0 -1
  380. package/dist/digi-arbetsformedlingen/p-e661462a.entry.js +0 -1
  381. package/dist/digi-arbetsformedlingen/p-e8ae7a8d.entry.js +0 -1
  382. package/dist/digi-arbetsformedlingen/p-f2339f8e.entry.js +0 -1
  383. package/dist/digi-arbetsformedlingen/p-f4c3f47e.entry.js +0 -1
  384. package/dist/digi-arbetsformedlingen/p-fb8ac3de.entry.js +0 -1
  385. package/dist/digi-arbetsformedlingen/p-fc4dc147.entry.js +0 -1
  386. package/dist/esm/digi-context-menu.entry.js +0 -128
  387. package/dist/esm/digi-icon-check.entry.js +0 -26
  388. package/dist/esm/digi-icon-chevron-down.entry.js +0 -26
  389. package/dist/esm/digi-layout-block_2.entry.js +0 -87
  390. package/dist/esm/digi-navigation-dropdown.entry.js +0 -184
  391. package/dist/esm/digi-quote-multi-container.entry.js +0 -19
  392. package/dist/esm/digi-quote-single.entry.js +0 -29
  393. package/dist/esm/quote-single-variation.enum-be92a9f7.js +0 -8
  394. package/dist/esm/typography-variation.enum-38d1ef90.js +0 -7
  395. package/dist/types/components/_navigation/navigation-dropdown/navigation-dropdown.d.ts +0 -44
  396. package/dist/types/components/_navigation/navigation-dropdown/navigation-dropdown.types.d.ts +0 -18
  397. package/dist/types/components/_quote/quote-multi-container/quote-multi-container-heading-level.enum.d.ts +0 -8
  398. package/dist/types/components/_quote/quote-multi-container/quote-multi-container.d.ts +0 -25
  399. package/dist/types/components/_quote/quote-single/quote-single-variation.enum.d.ts +0 -5
  400. package/dist/types/components/_quote/quote-single/quote.d.ts +0 -40
@@ -0,0 +1,2310 @@
1
+ import { r as registerInstance, h, g as getElement } from './index-8e318bb2.js';
2
+ import { _ as _t } from './text-ee5498fa.js';
3
+ import { s as select, f as dispatch, r as range, a as axisLeft, g as formatLocale, p as polyInOut, b as axisBottom, l as linear, m as max, d as min, o as ordinal, c as interpolate, e as linear$1 } from './linear-ef018ffb.js';
4
+ import { r as randomIdGenerator } from './randomIdGenerator.util-56406f2e.js';
5
+
6
+ function sourceEvent(event) {
7
+ let sourceEvent;
8
+ while (sourceEvent = event.sourceEvent) event = sourceEvent;
9
+ return event;
10
+ }
11
+
12
+ function pointer(event, node) {
13
+ event = sourceEvent(event);
14
+ if (node === undefined) node = event.currentTarget;
15
+ if (node) {
16
+ var svg = node.ownerSVGElement || node;
17
+ if (svg.createSVGPoint) {
18
+ var point = svg.createSVGPoint();
19
+ point.x = event.clientX, point.y = event.clientY;
20
+ point = point.matrixTransform(node.getScreenCTM().inverse());
21
+ return [point.x, point.y];
22
+ }
23
+ if (node.getBoundingClientRect) {
24
+ var rect = node.getBoundingClientRect();
25
+ return [event.clientX - rect.left - node.clientLeft, event.clientY - rect.top - node.clientTop];
26
+ }
27
+ }
28
+ return [event.pageX, event.pageY];
29
+ }
30
+
31
+ // These are typically used in conjunction with noevent to ensure that we can
32
+ // preventDefault on the event.
33
+ const nonpassive = {passive: false};
34
+ const nonpassivecapture = {capture: true, passive: false};
35
+
36
+ function nopropagation(event) {
37
+ event.stopImmediatePropagation();
38
+ }
39
+
40
+ function noevent(event) {
41
+ event.preventDefault();
42
+ event.stopImmediatePropagation();
43
+ }
44
+
45
+ function dragDisable(view) {
46
+ var root = view.document.documentElement,
47
+ selection = select(view).on("dragstart.drag", noevent, nonpassivecapture);
48
+ if ("onselectstart" in root) {
49
+ selection.on("selectstart.drag", noevent, nonpassivecapture);
50
+ } else {
51
+ root.__noselect = root.style.MozUserSelect;
52
+ root.style.MozUserSelect = "none";
53
+ }
54
+ }
55
+
56
+ function yesdrag(view, noclick) {
57
+ var root = view.document.documentElement,
58
+ selection = select(view).on("dragstart.drag", null);
59
+ if (noclick) {
60
+ selection.on("click.drag", noevent, nonpassivecapture);
61
+ setTimeout(function() { selection.on("click.drag", null); }, 0);
62
+ }
63
+ if ("onselectstart" in root) {
64
+ selection.on("selectstart.drag", null);
65
+ } else {
66
+ root.style.MozUserSelect = root.__noselect;
67
+ delete root.__noselect;
68
+ }
69
+ }
70
+
71
+ const constant$1 = x => () => x;
72
+
73
+ function DragEvent(type, {
74
+ sourceEvent,
75
+ subject,
76
+ target,
77
+ identifier,
78
+ active,
79
+ x, y, dx, dy,
80
+ dispatch
81
+ }) {
82
+ Object.defineProperties(this, {
83
+ type: {value: type, enumerable: true, configurable: true},
84
+ sourceEvent: {value: sourceEvent, enumerable: true, configurable: true},
85
+ subject: {value: subject, enumerable: true, configurable: true},
86
+ target: {value: target, enumerable: true, configurable: true},
87
+ identifier: {value: identifier, enumerable: true, configurable: true},
88
+ active: {value: active, enumerable: true, configurable: true},
89
+ x: {value: x, enumerable: true, configurable: true},
90
+ y: {value: y, enumerable: true, configurable: true},
91
+ dx: {value: dx, enumerable: true, configurable: true},
92
+ dy: {value: dy, enumerable: true, configurable: true},
93
+ _: {value: dispatch}
94
+ });
95
+ }
96
+
97
+ DragEvent.prototype.on = function() {
98
+ var value = this._.on.apply(this._, arguments);
99
+ return value === this._ ? this : value;
100
+ };
101
+
102
+ // Ignore right-click, since that should open the context menu.
103
+ function defaultFilter(event) {
104
+ return !event.ctrlKey && !event.button;
105
+ }
106
+
107
+ function defaultContainer() {
108
+ return this.parentNode;
109
+ }
110
+
111
+ function defaultSubject(event, d) {
112
+ return d == null ? {x: event.x, y: event.y} : d;
113
+ }
114
+
115
+ function defaultTouchable() {
116
+ return navigator.maxTouchPoints || ("ontouchstart" in this);
117
+ }
118
+
119
+ function drag() {
120
+ var filter = defaultFilter,
121
+ container = defaultContainer,
122
+ subject = defaultSubject,
123
+ touchable = defaultTouchable,
124
+ gestures = {},
125
+ listeners = dispatch("start", "drag", "end"),
126
+ active = 0,
127
+ mousedownx,
128
+ mousedowny,
129
+ mousemoving,
130
+ touchending,
131
+ clickDistance2 = 0;
132
+
133
+ function drag(selection) {
134
+ selection
135
+ .on("mousedown.drag", mousedowned)
136
+ .filter(touchable)
137
+ .on("touchstart.drag", touchstarted)
138
+ .on("touchmove.drag", touchmoved, nonpassive)
139
+ .on("touchend.drag touchcancel.drag", touchended)
140
+ .style("touch-action", "none")
141
+ .style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
142
+ }
143
+
144
+ function mousedowned(event, d) {
145
+ if (touchending || !filter.call(this, event, d)) return;
146
+ var gesture = beforestart(this, container.call(this, event, d), event, d, "mouse");
147
+ if (!gesture) return;
148
+ select(event.view)
149
+ .on("mousemove.drag", mousemoved, nonpassivecapture)
150
+ .on("mouseup.drag", mouseupped, nonpassivecapture);
151
+ dragDisable(event.view);
152
+ nopropagation(event);
153
+ mousemoving = false;
154
+ mousedownx = event.clientX;
155
+ mousedowny = event.clientY;
156
+ gesture("start", event);
157
+ }
158
+
159
+ function mousemoved(event) {
160
+ noevent(event);
161
+ if (!mousemoving) {
162
+ var dx = event.clientX - mousedownx, dy = event.clientY - mousedowny;
163
+ mousemoving = dx * dx + dy * dy > clickDistance2;
164
+ }
165
+ gestures.mouse("drag", event);
166
+ }
167
+
168
+ function mouseupped(event) {
169
+ select(event.view).on("mousemove.drag mouseup.drag", null);
170
+ yesdrag(event.view, mousemoving);
171
+ noevent(event);
172
+ gestures.mouse("end", event);
173
+ }
174
+
175
+ function touchstarted(event, d) {
176
+ if (!filter.call(this, event, d)) return;
177
+ var touches = event.changedTouches,
178
+ c = container.call(this, event, d),
179
+ n = touches.length, i, gesture;
180
+
181
+ for (i = 0; i < n; ++i) {
182
+ if (gesture = beforestart(this, c, event, d, touches[i].identifier, touches[i])) {
183
+ nopropagation(event);
184
+ gesture("start", event, touches[i]);
185
+ }
186
+ }
187
+ }
188
+
189
+ function touchmoved(event) {
190
+ var touches = event.changedTouches,
191
+ n = touches.length, i, gesture;
192
+
193
+ for (i = 0; i < n; ++i) {
194
+ if (gesture = gestures[touches[i].identifier]) {
195
+ noevent(event);
196
+ gesture("drag", event, touches[i]);
197
+ }
198
+ }
199
+ }
200
+
201
+ function touchended(event) {
202
+ var touches = event.changedTouches,
203
+ n = touches.length, i, gesture;
204
+
205
+ if (touchending) clearTimeout(touchending);
206
+ touchending = setTimeout(function() { touchending = null; }, 500); // Ghost clicks are delayed!
207
+ for (i = 0; i < n; ++i) {
208
+ if (gesture = gestures[touches[i].identifier]) {
209
+ nopropagation(event);
210
+ gesture("end", event, touches[i]);
211
+ }
212
+ }
213
+ }
214
+
215
+ function beforestart(that, container, event, d, identifier, touch) {
216
+ var dispatch = listeners.copy(),
217
+ p = pointer(touch || event, container), dx, dy,
218
+ s;
219
+
220
+ if ((s = subject.call(that, new DragEvent("beforestart", {
221
+ sourceEvent: event,
222
+ target: drag,
223
+ identifier,
224
+ active,
225
+ x: p[0],
226
+ y: p[1],
227
+ dx: 0,
228
+ dy: 0,
229
+ dispatch
230
+ }), d)) == null) return;
231
+
232
+ dx = s.x - p[0] || 0;
233
+ dy = s.y - p[1] || 0;
234
+
235
+ return function gesture(type, event, touch) {
236
+ var p0 = p, n;
237
+ switch (type) {
238
+ case "start": gestures[identifier] = gesture, n = active++; break;
239
+ case "end": delete gestures[identifier], --active; // falls through
240
+ case "drag": p = pointer(touch || event, container), n = active; break;
241
+ }
242
+ dispatch.call(
243
+ type,
244
+ that,
245
+ new DragEvent(type, {
246
+ sourceEvent: event,
247
+ subject: s,
248
+ target: drag,
249
+ identifier,
250
+ active: n,
251
+ x: p[0] + dx,
252
+ y: p[1] + dy,
253
+ dx: p[0] - p0[0],
254
+ dy: p[1] - p0[1],
255
+ dispatch
256
+ }),
257
+ d
258
+ );
259
+ };
260
+ }
261
+
262
+ drag.filter = function(_) {
263
+ return arguments.length ? (filter = typeof _ === "function" ? _ : constant$1(!!_), drag) : filter;
264
+ };
265
+
266
+ drag.container = function(_) {
267
+ return arguments.length ? (container = typeof _ === "function" ? _ : constant$1(_), drag) : container;
268
+ };
269
+
270
+ drag.subject = function(_) {
271
+ return arguments.length ? (subject = typeof _ === "function" ? _ : constant$1(_), drag) : subject;
272
+ };
273
+
274
+ drag.touchable = function(_) {
275
+ return arguments.length ? (touchable = typeof _ === "function" ? _ : constant$1(!!_), drag) : touchable;
276
+ };
277
+
278
+ drag.on = function() {
279
+ var value = listeners.on.apply(listeners, arguments);
280
+ return value === listeners ? drag : value;
281
+ };
282
+
283
+ drag.clickDistance = function(_) {
284
+ return arguments.length ? (clickDistance2 = (_ = +_) * _, drag) : Math.sqrt(clickDistance2);
285
+ };
286
+
287
+ return drag;
288
+ }
289
+
290
+ function quadInOut(t) {
291
+ return ((t *= 2) <= 1 ? t * t : --t * (2 - t) + 1) / 2;
292
+ }
293
+
294
+ const pi$1 = Math.PI,
295
+ tau$1 = 2 * pi$1,
296
+ epsilon = 1e-6,
297
+ tauEpsilon = tau$1 - epsilon;
298
+
299
+ function append(strings) {
300
+ this._ += strings[0];
301
+ for (let i = 1, n = strings.length; i < n; ++i) {
302
+ this._ += arguments[i] + strings[i];
303
+ }
304
+ }
305
+
306
+ function appendRound(digits) {
307
+ let d = Math.floor(digits);
308
+ if (!(d >= 0)) throw new Error(`invalid digits: ${digits}`);
309
+ if (d > 15) return append;
310
+ const k = 10 ** d;
311
+ return function(strings) {
312
+ this._ += strings[0];
313
+ for (let i = 1, n = strings.length; i < n; ++i) {
314
+ this._ += Math.round(arguments[i] * k) / k + strings[i];
315
+ }
316
+ };
317
+ }
318
+
319
+ class Path {
320
+ constructor(digits) {
321
+ this._x0 = this._y0 = // start of current subpath
322
+ this._x1 = this._y1 = null; // end of current subpath
323
+ this._ = "";
324
+ this._append = digits == null ? append : appendRound(digits);
325
+ }
326
+ moveTo(x, y) {
327
+ this._append`M${this._x0 = this._x1 = +x},${this._y0 = this._y1 = +y}`;
328
+ }
329
+ closePath() {
330
+ if (this._x1 !== null) {
331
+ this._x1 = this._x0, this._y1 = this._y0;
332
+ this._append`Z`;
333
+ }
334
+ }
335
+ lineTo(x, y) {
336
+ this._append`L${this._x1 = +x},${this._y1 = +y}`;
337
+ }
338
+ quadraticCurveTo(x1, y1, x, y) {
339
+ this._append`Q${+x1},${+y1},${this._x1 = +x},${this._y1 = +y}`;
340
+ }
341
+ bezierCurveTo(x1, y1, x2, y2, x, y) {
342
+ this._append`C${+x1},${+y1},${+x2},${+y2},${this._x1 = +x},${this._y1 = +y}`;
343
+ }
344
+ arcTo(x1, y1, x2, y2, r) {
345
+ x1 = +x1, y1 = +y1, x2 = +x2, y2 = +y2, r = +r;
346
+
347
+ // Is the radius negative? Error.
348
+ if (r < 0) throw new Error(`negative radius: ${r}`);
349
+
350
+ let x0 = this._x1,
351
+ y0 = this._y1,
352
+ x21 = x2 - x1,
353
+ y21 = y2 - y1,
354
+ x01 = x0 - x1,
355
+ y01 = y0 - y1,
356
+ l01_2 = x01 * x01 + y01 * y01;
357
+
358
+ // Is this path empty? Move to (x1,y1).
359
+ if (this._x1 === null) {
360
+ this._append`M${this._x1 = x1},${this._y1 = y1}`;
361
+ }
362
+
363
+ // Or, is (x1,y1) coincident with (x0,y0)? Do nothing.
364
+ else if (!(l01_2 > epsilon));
365
+
366
+ // Or, are (x0,y0), (x1,y1) and (x2,y2) collinear?
367
+ // Equivalently, is (x1,y1) coincident with (x2,y2)?
368
+ // Or, is the radius zero? Line to (x1,y1).
369
+ else if (!(Math.abs(y01 * x21 - y21 * x01) > epsilon) || !r) {
370
+ this._append`L${this._x1 = x1},${this._y1 = y1}`;
371
+ }
372
+
373
+ // Otherwise, draw an arc!
374
+ else {
375
+ let x20 = x2 - x0,
376
+ y20 = y2 - y0,
377
+ l21_2 = x21 * x21 + y21 * y21,
378
+ l20_2 = x20 * x20 + y20 * y20,
379
+ l21 = Math.sqrt(l21_2),
380
+ l01 = Math.sqrt(l01_2),
381
+ l = r * Math.tan((pi$1 - Math.acos((l21_2 + l01_2 - l20_2) / (2 * l21 * l01))) / 2),
382
+ t01 = l / l01,
383
+ t21 = l / l21;
384
+
385
+ // If the start tangent is not coincident with (x0,y0), line to.
386
+ if (Math.abs(t01 - 1) > epsilon) {
387
+ this._append`L${x1 + t01 * x01},${y1 + t01 * y01}`;
388
+ }
389
+
390
+ this._append`A${r},${r},0,0,${+(y01 * x20 > x01 * y20)},${this._x1 = x1 + t21 * x21},${this._y1 = y1 + t21 * y21}`;
391
+ }
392
+ }
393
+ arc(x, y, r, a0, a1, ccw) {
394
+ x = +x, y = +y, r = +r, ccw = !!ccw;
395
+
396
+ // Is the radius negative? Error.
397
+ if (r < 0) throw new Error(`negative radius: ${r}`);
398
+
399
+ let dx = r * Math.cos(a0),
400
+ dy = r * Math.sin(a0),
401
+ x0 = x + dx,
402
+ y0 = y + dy,
403
+ cw = 1 ^ ccw,
404
+ da = ccw ? a0 - a1 : a1 - a0;
405
+
406
+ // Is this path empty? Move to (x0,y0).
407
+ if (this._x1 === null) {
408
+ this._append`M${x0},${y0}`;
409
+ }
410
+
411
+ // Or, is (x0,y0) not coincident with the previous point? Line to (x0,y0).
412
+ else if (Math.abs(this._x1 - x0) > epsilon || Math.abs(this._y1 - y0) > epsilon) {
413
+ this._append`L${x0},${y0}`;
414
+ }
415
+
416
+ // Is this arc empty? We’re done.
417
+ if (!r) return;
418
+
419
+ // Does the angle go the wrong way? Flip the direction.
420
+ if (da < 0) da = da % tau$1 + tau$1;
421
+
422
+ // Is this a complete circle? Draw two arcs to complete the circle.
423
+ if (da > tauEpsilon) {
424
+ this._append`A${r},${r},0,1,${cw},${x - dx},${y - dy}A${r},${r},0,1,${cw},${this._x1 = x0},${this._y1 = y0}`;
425
+ }
426
+
427
+ // Is this arc non-empty? Draw an arc!
428
+ else if (da > epsilon) {
429
+ this._append`A${r},${r},0,${+(da >= pi$1)},${cw},${this._x1 = x + r * Math.cos(a1)},${this._y1 = y + r * Math.sin(a1)}`;
430
+ }
431
+ }
432
+ rect(x, y, w, h) {
433
+ this._append`M${this._x0 = this._x1 = +x},${this._y0 = this._y1 = +y}h${w = +w}v${+h}h${-w}Z`;
434
+ }
435
+ toString() {
436
+ return this._;
437
+ }
438
+ }
439
+
440
+ function constant(x) {
441
+ return function constant() {
442
+ return x;
443
+ };
444
+ }
445
+
446
+ const cos = Math.cos;
447
+ const sin = Math.sin;
448
+ const sqrt = Math.sqrt;
449
+ const pi = Math.PI;
450
+ const tau = 2 * pi;
451
+
452
+ function withPath(shape) {
453
+ let digits = 3;
454
+
455
+ shape.digits = function(_) {
456
+ if (!arguments.length) return digits;
457
+ if (_ == null) {
458
+ digits = null;
459
+ } else {
460
+ const d = Math.floor(_);
461
+ if (!(d >= 0)) throw new RangeError(`invalid digits: ${_}`);
462
+ digits = d;
463
+ }
464
+ return shape;
465
+ };
466
+
467
+ return () => new Path(digits);
468
+ }
469
+
470
+ function array(x) {
471
+ return typeof x === "object" && "length" in x
472
+ ? x // Array, TypedArray, NodeList, array-like
473
+ : Array.from(x); // Map, Set, iterable, string, or anything else
474
+ }
475
+
476
+ function Linear(context) {
477
+ this._context = context;
478
+ }
479
+
480
+ Linear.prototype = {
481
+ areaStart: function() {
482
+ this._line = 0;
483
+ },
484
+ areaEnd: function() {
485
+ this._line = NaN;
486
+ },
487
+ lineStart: function() {
488
+ this._point = 0;
489
+ },
490
+ lineEnd: function() {
491
+ if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath();
492
+ this._line = 1 - this._line;
493
+ },
494
+ point: function(x, y) {
495
+ x = +x, y = +y;
496
+ switch (this._point) {
497
+ case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break;
498
+ case 1: this._point = 2; // falls through
499
+ default: this._context.lineTo(x, y); break;
500
+ }
501
+ }
502
+ };
503
+
504
+ function curveLinear(context) {
505
+ return new Linear(context);
506
+ }
507
+
508
+ function x(p) {
509
+ return p[0];
510
+ }
511
+
512
+ function y(p) {
513
+ return p[1];
514
+ }
515
+
516
+ function line(x$1, y$1) {
517
+ var defined = constant(true),
518
+ context = null,
519
+ curve = curveLinear,
520
+ output = null,
521
+ path = withPath(line);
522
+
523
+ x$1 = typeof x$1 === "function" ? x$1 : (x$1 === undefined) ? x : constant(x$1);
524
+ y$1 = typeof y$1 === "function" ? y$1 : (y$1 === undefined) ? y : constant(y$1);
525
+
526
+ function line(data) {
527
+ var i,
528
+ n = (data = array(data)).length,
529
+ d,
530
+ defined0 = false,
531
+ buffer;
532
+
533
+ if (context == null) output = curve(buffer = path());
534
+
535
+ for (i = 0; i <= n; ++i) {
536
+ if (!(i < n && defined(d = data[i], i, data)) === defined0) {
537
+ if (defined0 = !defined0) output.lineStart();
538
+ else output.lineEnd();
539
+ }
540
+ if (defined0) output.point(+x$1(d, i, data), +y$1(d, i, data));
541
+ }
542
+
543
+ if (buffer) return output = null, buffer + "" || null;
544
+ }
545
+
546
+ line.x = function(_) {
547
+ return arguments.length ? (x$1 = typeof _ === "function" ? _ : constant(+_), line) : x$1;
548
+ };
549
+
550
+ line.y = function(_) {
551
+ return arguments.length ? (y$1 = typeof _ === "function" ? _ : constant(+_), line) : y$1;
552
+ };
553
+
554
+ line.defined = function(_) {
555
+ return arguments.length ? (defined = typeof _ === "function" ? _ : constant(!!_), line) : defined;
556
+ };
557
+
558
+ line.curve = function(_) {
559
+ return arguments.length ? (curve = _, context != null && (output = curve(context)), line) : curve;
560
+ };
561
+
562
+ line.context = function(_) {
563
+ return arguments.length ? (_ == null ? context = output = null : output = curve(context = _), line) : context;
564
+ };
565
+
566
+ return line;
567
+ }
568
+
569
+ const circle = {
570
+ draw(context, size) {
571
+ const r = sqrt(size / pi);
572
+ context.moveTo(r, 0);
573
+ context.arc(0, 0, r, 0, tau);
574
+ }
575
+ };
576
+
577
+ const tan30 = sqrt(1 / 3);
578
+ const tan30_2 = tan30 * 2;
579
+
580
+ const diamond = {
581
+ draw(context, size) {
582
+ const y = sqrt(size / tan30_2);
583
+ const x = y * tan30;
584
+ context.moveTo(0, -y);
585
+ context.lineTo(x, 0);
586
+ context.lineTo(0, y);
587
+ context.lineTo(-x, 0);
588
+ context.closePath();
589
+ }
590
+ };
591
+
592
+ const ka = 0.89081309152928522810;
593
+ const kr = sin(pi / 10) / sin(7 * pi / 10);
594
+ const kx = sin(tau / 10) * kr;
595
+ const ky = -cos(tau / 10) * kr;
596
+
597
+ const star = {
598
+ draw(context, size) {
599
+ const r = sqrt(size * ka);
600
+ const x = kx * r;
601
+ const y = ky * r;
602
+ context.moveTo(0, -r);
603
+ context.lineTo(x, y);
604
+ for (let i = 1; i < 5; ++i) {
605
+ const a = tau * i / 5;
606
+ const c = cos(a);
607
+ const s = sin(a);
608
+ context.lineTo(s * r, -c * r);
609
+ context.lineTo(c * x - s * y, s * x + c * y);
610
+ }
611
+ context.closePath();
612
+ }
613
+ };
614
+
615
+ const sqrt3 = sqrt(3);
616
+
617
+ const triangle = {
618
+ draw(context, size) {
619
+ const y = -sqrt(size / (sqrt3 * 3));
620
+ context.moveTo(0, y * 2);
621
+ context.lineTo(-sqrt3 * y, -y);
622
+ context.lineTo(sqrt3 * y, -y);
623
+ context.closePath();
624
+ }
625
+ };
626
+
627
+ function Symbol(type, size) {
628
+ let context = null,
629
+ path = withPath(symbol);
630
+
631
+ type = typeof type === "function" ? type : constant(type || circle);
632
+ size = typeof size === "function" ? size : constant(size === undefined ? 64 : +size);
633
+
634
+ function symbol() {
635
+ let buffer;
636
+ if (!context) context = buffer = path();
637
+ type.apply(this, arguments).draw(context, +size.apply(this, arguments));
638
+ if (buffer) return context = null, buffer + "" || null;
639
+ }
640
+
641
+ symbol.type = function(_) {
642
+ return arguments.length ? (type = typeof _ === "function" ? _ : constant(_), symbol) : type;
643
+ };
644
+
645
+ symbol.size = function(_) {
646
+ return arguments.length ? (size = typeof _ === "function" ? _ : constant(+_), symbol) : size;
647
+ };
648
+
649
+ symbol.context = function(_) {
650
+ return arguments.length ? (context = _ == null ? null : _, symbol) : context;
651
+ };
652
+
653
+ return symbol;
654
+ }
655
+
656
+ function point(that, x, y) {
657
+ that._context.bezierCurveTo(
658
+ (2 * that._x0 + that._x1) / 3,
659
+ (2 * that._y0 + that._y1) / 3,
660
+ (that._x0 + 2 * that._x1) / 3,
661
+ (that._y0 + 2 * that._y1) / 3,
662
+ (that._x0 + 4 * that._x1 + x) / 6,
663
+ (that._y0 + 4 * that._y1 + y) / 6
664
+ );
665
+ }
666
+
667
+ function Basis(context) {
668
+ this._context = context;
669
+ }
670
+
671
+ Basis.prototype = {
672
+ areaStart: function() {
673
+ this._line = 0;
674
+ },
675
+ areaEnd: function() {
676
+ this._line = NaN;
677
+ },
678
+ lineStart: function() {
679
+ this._x0 = this._x1 =
680
+ this._y0 = this._y1 = NaN;
681
+ this._point = 0;
682
+ },
683
+ lineEnd: function() {
684
+ switch (this._point) {
685
+ case 3: point(this, this._x1, this._y1); // falls through
686
+ case 2: this._context.lineTo(this._x1, this._y1); break;
687
+ }
688
+ if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath();
689
+ this._line = 1 - this._line;
690
+ },
691
+ point: function(x, y) {
692
+ x = +x, y = +y;
693
+ switch (this._point) {
694
+ case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break;
695
+ case 1: this._point = 2; break;
696
+ case 2: this._point = 3; this._context.lineTo((5 * this._x0 + this._x1) / 6, (5 * this._y0 + this._y1) / 6); // falls through
697
+ default: point(this, x, y); break;
698
+ }
699
+ this._x0 = this._x1, this._x1 = x;
700
+ this._y0 = this._y1, this._y1 = y;
701
+ }
702
+ };
703
+
704
+ function basis(context) {
705
+ return new Basis(context);
706
+ }
707
+
708
+ const chartLineCss = ".sc-digi-chart-line-h{display:block;height:100%;width:100%;position:relative}.sc-digi-chart-line-h .digi-chart-line.sc-digi-chart-line{color:var(--MY-PROP);height:100%;width:100%;min-height:fit-content}.buttonWrapper.sc-digi-chart-line{--digi--button--padding--medium:0 0 0.75rem 0}.chart.sc-digi-chart-line{box-sizing:content-box;width:auto}.chartTitle.sc-digi-chart-line{--digi--typography--h2--margin:0.5rem;--digi--typography--h3--margin:0.5rem;--digi--typography--h4--margin:0.5rem;--digi--typography--h5--margin:0.5rem;--digi--typography--h6--margin:0.5rem;display:flex;justify-content:flex-start;flex-direction:column;align-items:left;text-align:left;padding-bottom:1rem;flex-grow:2}.close.sc-digi-chart-line{--digi--icon--color:rgb(245, 245, 245);cursor:pointer;margin-top:-5px}.legend.sc-digi-chart-line{display:flex;flex-direction:row;flex-wrap:no-wrap;gap:0.5rem;margin:0.5rem 0;margin-top:1.25rem;height:2.675rem;overflow-x:auto;overflow-y:hidden;cursor:default;max-width:100%}.chip.sc-digi-chart-line{box-sizing:border-box}.legend.sc-digi-chart-line::-webkit-scrollbar,.table.sc-digi-chart-line::-webkit-scrollbar{height:10px;width:10px}.legend.sc-digi-chart-line::-webkit-scrollbar-track,.table.sc-digi-chart-line::-webkit-scrollbar-track{background:whitesmoke;border-radius:4px}.legend.sc-digi-chart-line::-webkit-scrollbar-thumb,.table.sc-digi-chart-line::-webkit-scrollbar-thumb{background-color:lightgray;border-radius:4px;border:0}.chartTooltip.sc-digi-chart-line{box-sizing:border-box;position:absolute;background-color:rgba(10, 10, 10, 0.9);color:white;padding:5px 10px;padding-right:5px;border-radius:4px;display:flex;flex-direction:row;align-items:flex-start;box-shadow:rgba(60, 64, 67, 0.3) 0px 1px 2px 0px, rgba(60, 64, 67, 0.15) 0px 2px 6px 2px;font-size:14px;display:none}.scChartStatus.sc-digi-chart-line{border:0;clip:rect(1px, 1px, 1px, 1px);clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap}.table.sc-digi-chart-line{display:none;overflow-y:scroll;height:fit-content;border-radius:4px;padding:0.25rem;background:linear-gradient(white 30%, rgba(255, 255, 255, 0)) center top, linear-gradient(rgba(255, 255, 255, 0), white 70%) center bottom, radial-gradient(farthest-side at 50% 0, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0)) center top, radial-gradient(farthest-side at 50% 100%, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0)) center bottom;background-repeat:no-repeat;background-size:100% 40px, 100% 40px, 100% 14px, 100% 14px;background-attachment:local, local, scroll, scroll}.tableIcon.sc-digi-chart-line{--digi--icon--color:var(--digi--global--color--neutral--grayscale--darker);width:26px;height:26px;pointer-events:none}.tableIcon.sc-digi-chart-line:hover{--digi--icon--color:var(\n --digi--global--color--neutral--grayscale--darkest-3\n )}.tooltipBody.sc-digi-chart-line{display:flex;flex-direction:column;margin-right:5px}.topWrapper.sc-digi-chart-line{display:flex;flex-direction:row;align-items:flex-end;justify-content:space-between;flex-wrap:wrap}";
709
+ const DigiChartLineStyle0 = chartLineCss;
710
+
711
+ const ChartLine = class {
712
+ constructor(hostRef) {
713
+ registerInstance(this, hostRef);
714
+ this._lineTypes = [null, '1.0, 7.0', '9.0, 7.0'];
715
+ this._toggled = false;
716
+ this._tickSize = 0;
717
+ // Selection list from legend chips
718
+ this._selectedLines = [];
719
+ // Dragging
720
+ this._dragStart = 0;
721
+ this._dragDir = 0;
722
+ this._loading = false;
723
+ this.margin = {
724
+ bottom: 0,
725
+ top: 6,
726
+ left: 5,
727
+ right: 15
728
+ };
729
+ this.fontSize = '0.875rem';
730
+ this.xPadding = 5;
731
+ this.yPadding = 8;
732
+ this.xTickSize = 5;
733
+ // How many line types that exists currently
734
+ this.lineTypes = 3;
735
+ // Formats
736
+ this.formatStyle = ',d';
737
+ this.axisNumberFormat = {
738
+ decimal: ',',
739
+ thousands: ' ',
740
+ grouping: [3],
741
+ currency: ['', 'kr']
742
+ };
743
+ // Observer for watching size changes when in line chart mode
744
+ this.lineChartObserver = new ResizeObserver((entries) => {
745
+ entries.forEach(() => {
746
+ this.resizeSvg();
747
+ this.resizeLines();
748
+ this.repositionTooltip(); // Called on both div.resize, and window.resize
749
+ select(this._legendDiv).style('width', this.dims.width + 'px');
750
+ });
751
+ });
752
+ // Observer for watching size changes when in table mode
753
+ this.tableObserver = new ResizeObserver((entries) => {
754
+ entries.forEach(() => {
755
+ select(this._legendDiv).style('width', this.dims.width + 'px');
756
+ this.resizeTable();
757
+ });
758
+ });
759
+ this.dragStart = (e) => {
760
+ const container = select(this._legendDiv).node();
761
+ this._dragStart = e.x - container.offsetLeft;
762
+ this._scrollLeft = container.scrollLeft;
763
+ };
764
+ this.drag = (e) => {
765
+ const container = select(this._legendDiv);
766
+ this._dragDir = e.x;
767
+ const delta = this._dragDir - container.node().offsetLeft;
768
+ const walk = (delta - this._dragStart) * 1; //scroll-fast
769
+ container.property('scrollLeft', this._scrollLeft - walk);
770
+ };
771
+ // Set yTicks
772
+ this.setYTicks = (init = false) => {
773
+ // Fixed number of y-axis lines
774
+ const step = this._chartData.meta && this._chartData.meta.numberOfReferenceLines
775
+ ? this._chartData.meta.numberOfReferenceLines
776
+ : 5, min = this._yAxis.domain()[0], max = this._yAxis.domain()[1], stepValue = (max - min) / (step - 1), tickValues = range(min, max + stepValue, stepValue);
777
+ if (!init) {
778
+ this._yAxisHandle
779
+ .style('font-size', this.fontSize)
780
+ .transition()
781
+ .duration(400)
782
+ .call(axisLeft(this._yAxis)
783
+ .ticks(step)
784
+ .tickPadding(this.yPadding)
785
+ .tickValues(tickValues)
786
+ .tickSize(-(this.dims.width - this.margin.left))
787
+ .tickFormat((d) => formatLocale(this.axisNumberFormat).format(this.formatStyle)(d)))
788
+ .on('end', () => this.leftSetAxis());
789
+ }
790
+ else {
791
+ this._yAxisHandle.style('font-size', this.fontSize).call(axisLeft(this._yAxis)
792
+ .ticks(step)
793
+ .tickPadding(this.yPadding)
794
+ .tickValues(tickValues)
795
+ .tickSize(-(this.dims.width - this.margin.left))
796
+ .tickFormat((d) => formatLocale(this.axisNumberFormat).format(this.formatStyle)(d)));
797
+ }
798
+ this._yAxisHandle
799
+ .selectAll('line')
800
+ .attr('stroke', getComputedStyle(document.documentElement)
801
+ .getPropertyValue('--digi--global--color--neutral--grayscale--darker')
802
+ .trim()
803
+ .toLocaleLowerCase());
804
+ this._yAxisHandle.select('.domain').attr('display', 'none');
805
+ if (init)
806
+ this.leftSetAxis(init);
807
+ };
808
+ // Adding event listeners to the chart
809
+ this.addListenersToChart = () => {
810
+ this._Tipbox
811
+ .style('cursor', 'pointer')
812
+ .on('mousemove', this.drawTooltipLine)
813
+ .on('touchmove', 'ontouchstart' in window || window.navigator.maxTouchPoints
814
+ ? this.drawTooltip
815
+ : null)
816
+ .on('mouseup', this.drawTooltip)
817
+ .on('mouseleave', () => {
818
+ this._secondaryLine.attr('display', 'none');
819
+ if (!this._toggled) {
820
+ this._TooltipLine.attr('display', 'none');
821
+ this._Circles.selectAll('circle').attr('display', 'none');
822
+ }
823
+ });
824
+ };
825
+ // Initialize legend
826
+ this.initLegend = () => {
827
+ const container = select(this._legendDiv);
828
+ select(this._legendDiv).style('width', this.dims.width + 'px');
829
+ container.selectAll('.chip').remove();
830
+ container.call(drag().on('start', this.dragStart).on('drag', this.drag));
831
+ container
832
+ .selectAll('legendChips')
833
+ .data(this._chartData.data.series)
834
+ .join('button')
835
+ .attr('class', 'chip')
836
+ .attr('type', 'button')
837
+ .attr('aria-pressed', false)
838
+ .style('padding', '0.15rem 0.75rem')
839
+ .style('border', '2px solid white')
840
+ .style('border-radius', '6px')
841
+ .style('display', 'flex')
842
+ .style('flex-direction', 'row')
843
+ .style('gap', '0.5rem')
844
+ .style('align-items', 'center')
845
+ .style('flex-wrap', 'nowrap')
846
+ .style('min-width', 'fit-content')
847
+ .style('height', 'calc(2rem - 2px)')
848
+ .style('font-size', this.fontSize)
849
+ .style('white-space', 'nowrap')
850
+ .style('box-sizing', 'border-box')
851
+ .style('background-color', 'white')
852
+ .style('cursor', 'pointer')
853
+ .html((d) => {
854
+ return '<span style="pointer-events:none;">' + d.title + '</span>';
855
+ })
856
+ .on('click', this.togglePath)
857
+ .on('mouseover', this.highlightPath)
858
+ .on('mouseleave', this.colorLines)
859
+ .datum((d) => d)
860
+ .insert('svg', 'span')
861
+ .attr('class', 'legendSvg')
862
+ .attr('pointer-events', 'none')
863
+ .attr('width', 32)
864
+ .attr('height', 28)
865
+ .append('line')
866
+ .attr('stroke', (d) => this.colorFunction(d))
867
+ .attr('stroke-linecap', 'round')
868
+ .attr('stroke-width', 6)
869
+ .attr('stroke-dasharray', (d, i) => this.dashFunction(d, i))
870
+ .attr('x1', 3)
871
+ .attr('x2', 29)
872
+ .attr('y1', '50%')
873
+ .attr('y2', '50%');
874
+ // Only if data contains many lines
875
+ if (this._chartData.data.series.length <= this.lineTypes)
876
+ return;
877
+ container
878
+ .selectAll('.legendSvg')
879
+ .filter((...[, i]) => {
880
+ return i > 2;
881
+ })
882
+ .append('path')
883
+ .attr('d', (...[, i]) => this.symbolType(i, 110))
884
+ .attr('fill', (d) => this.colorFunction(d))
885
+ .attr('transform', 'translate(16,14)');
886
+ };
887
+ // Highlights a line
888
+ this.highlightPath = (event, element) => {
889
+ if (event.target.className != 'chip')
890
+ return;
891
+ const target = select(event.target);
892
+ target.style('border', (d) => '2px solid ' + this.colorFunction(d));
893
+ this._lineChartContainer
894
+ .selectAll('.linePath')
895
+ .transition('highlight')
896
+ .duration(150)
897
+ .attr('stroke', (d, i, nodelist) => {
898
+ if (d.title === element.title) {
899
+ select(nodelist[i]).raise();
900
+ return this.colorFunction(d);
901
+ }
902
+ else
903
+ return '#E3E3E3';
904
+ });
905
+ this._lineChartContainer
906
+ .selectAll('.symbolGroup')
907
+ .attr('fill', (d, i, nodelist) => {
908
+ if (d.title === element.title) {
909
+ select(nodelist[i]).raise();
910
+ }
911
+ });
912
+ this._lineChartContainer
913
+ .selectAll('.symbolGroup')
914
+ .selectAll('.symbol')
915
+ .transition('highlight')
916
+ .duration(150)
917
+ .attr('fill', (d) => {
918
+ if (!d)
919
+ return;
920
+ if (d.title === element.title) {
921
+ return this.colorFunction(d);
922
+ }
923
+ else
924
+ return '#E3E3E3';
925
+ });
926
+ };
927
+ // Selecting a path to view sollely from legend
928
+ this.togglePath = (event) => {
929
+ if (event.target.className != 'chip')
930
+ return;
931
+ const target = select(event.target);
932
+ // Using color of text to identify what state the legend chip is in, so resetting this the last thing we do
933
+ const swap = 'white' === target.style('color');
934
+ target
935
+ .style('border', (d) => '2px solid ' + this.colorFunction(d))
936
+ .style('background-color', (d) => swap ? 'white' : this.colorFunction(d))
937
+ .style('color', () => (swap ? 'black' : 'white'))
938
+ .attr('aria-pressed', target.attr('aria-pressed') == 'false' ? true : false)
939
+ .select('line')
940
+ .attr('stroke', (d) => (swap ? this.colorFunction(d) : 'white'));
941
+ target
942
+ .select('path')
943
+ .attr('fill', (d) => (swap ? this.colorFunction(d) : 'white'));
944
+ if (swap) {
945
+ this._selectedLines = this._selectedLines.filter((elem) => {
946
+ return elem.title === target.datum()['title'] ? false : true;
947
+ });
948
+ }
949
+ else {
950
+ this._selectedLines.push(this._coreSeries.filter((elem) => elem.title === target.datum()['title'])[0]);
951
+ }
952
+ if (this._selectedLines.length < 1)
953
+ this._chartData.data.series = JSON.parse(JSON.stringify(this._coreSeries));
954
+ else {
955
+ this._chartData.data.series.map((serie) => {
956
+ const index = this._selectedLines.findIndex((selected) => {
957
+ return serie.title === selected.title;
958
+ });
959
+ if (index != -1) {
960
+ serie.yValues = this._selectedLines[index].yValues;
961
+ }
962
+ else {
963
+ serie.yValues = [];
964
+ }
965
+ });
966
+ }
967
+ this.updateSvg();
968
+ };
969
+ // Coloring all lines
970
+ this.colorLines = (event) => {
971
+ const target = select(event.target);
972
+ target.style('border', '2px solid white');
973
+ this._lineChartContainer
974
+ .selectAll('.linePath')
975
+ .transition('highlight')
976
+ .duration(150)
977
+ .attr('stroke', (d) => this.colorFunction(d));
978
+ this._lineChartContainer
979
+ .selectAll('.symbolGroup')
980
+ .selectAll('.symbol')
981
+ .transition('highlight')
982
+ .duration(150)
983
+ .attr('fill', (d) => (d ? this.colorFunction(d) : null));
984
+ };
985
+ // Returns a line type given a integer value
986
+ this.dashFunction = (...[, index]) => {
987
+ return this._lineTypes[index % this._lineTypes.length];
988
+ };
989
+ // Initialize the drawing of the lines
990
+ this.initLines = () => {
991
+ this.defineLineAndScale();
992
+ // TODO: do this data appending somewhere else
993
+ this._lineChartContainer
994
+ .selectAll('linePath')
995
+ .data(this.reshapeData(this._chartData.data.series))
996
+ .join('path')
997
+ .attr('class', 'linePath')
998
+ .attr('stroke', (d) => this.colorFunction(d))
999
+ .attr('stroke-linecap', 'round')
1000
+ .attr('stroke-width', (d) => (d.length > 1 ? 4 : 6))
1001
+ .attr('stroke-dasharray', (d, i) => d.length > 1 ? this.dashFunction(d, i) : null)
1002
+ .attr('fill', 'none')
1003
+ .attr('d', (d) => this._LineFunc(d.line));
1004
+ this.addSymbols();
1005
+ };
1006
+ this.defineLineAndScale = () => {
1007
+ this._LineFunc = line()
1008
+ .defined((d) => d[1] != null && d[1] != undefined && !isNaN(d[1]))
1009
+ .x((d) => this._lineScale(d[0]))
1010
+ .y((d) => this._yAxis(d[1]));
1011
+ };
1012
+ // Modifies data object adds a line member to object, line is an array of pairs of number: [number, number][]
1013
+ // Line is used to feed into _LineFunc
1014
+ this.reshapeData = (series) => {
1015
+ return series.map((obj) => {
1016
+ obj.line = this._chartData.data.xValues.map((elem, ind) => {
1017
+ return [elem, obj.yValues[ind]];
1018
+ });
1019
+ obj.length = obj.yValues.filter((e) => e != null && e != undefined).length;
1020
+ return obj;
1021
+ });
1022
+ };
1023
+ // Adding symbols to lines where needed
1024
+ this.addSymbols = (transition = false) => {
1025
+ // Remove all old symbols
1026
+ this._lineChartContainer
1027
+ .selectAll('.symbolGroup')
1028
+ .data(this.reshapeData(this._chartData.data.series.filter((...[, index]) => index > 2)))
1029
+ .join((enter) => {
1030
+ if (!transition) {
1031
+ enter
1032
+ .append('g')
1033
+ .attr('class', 'symbolGroup')
1034
+ .selectAll('symbols')
1035
+ .data((d, i) => {
1036
+ return d.line.map((num) => {
1037
+ if (num[1] != null)
1038
+ return {
1039
+ val: num[1],
1040
+ x: num[0],
1041
+ title: d.title,
1042
+ colorToken: d.colorToken,
1043
+ index: i
1044
+ };
1045
+ else
1046
+ return null;
1047
+ });
1048
+ })
1049
+ .join('path')
1050
+ .attr('class', 'symbol')
1051
+ .attr('d', (d) => (d ? this.symbolType(d.index) : null))
1052
+ .attr('fill', (d) => (d ? this.colorFunction(d) : null))
1053
+ .attr('transform', (d) => d
1054
+ ? `translate(${this._lineScale(d.x)},${this._yAxis(d.val)})`
1055
+ : null);
1056
+ }
1057
+ else {
1058
+ enter
1059
+ .append('g')
1060
+ .attr('class', 'symbolGroup')
1061
+ .selectAll('symbol')
1062
+ .data((d, i) => {
1063
+ return d.line.map((num) => {
1064
+ if (num[1] != null)
1065
+ return {
1066
+ val: num[1],
1067
+ x: num[0],
1068
+ title: d.title,
1069
+ colorToken: d.colorToken,
1070
+ index: i
1071
+ };
1072
+ else
1073
+ return null;
1074
+ });
1075
+ })
1076
+ .join('path')
1077
+ .attr('class', 'symbol')
1078
+ .attr('d', (d) => (d ? this.symbolType(d.index) : null))
1079
+ .attr('fill', (d) => (d ? this.colorFunction(d) : null))
1080
+ .attr('transform', (d) => d
1081
+ ? `translate(${this._lineScale(d.x)},${this._yAxis(d.val)})`
1082
+ : null);
1083
+ }
1084
+ }, (update) => {
1085
+ if (!transition) {
1086
+ update
1087
+ .selectAll('.symbol')
1088
+ .data((d, i) => {
1089
+ return d.line.map((num) => {
1090
+ if (num[1] != null)
1091
+ return {
1092
+ val: num[1],
1093
+ x: num[0],
1094
+ title: d.title,
1095
+ colorToken: d.colorToken,
1096
+ index: i
1097
+ };
1098
+ else
1099
+ return null;
1100
+ });
1101
+ })
1102
+ .join('path')
1103
+ .attr('class', 'symbol')
1104
+ .attr('d', (d) => (d ? this.symbolType(d.index) : null))
1105
+ .attr('fill', (d) => (d ? this.colorFunction(d) : null))
1106
+ .attr('transform', (d) => d
1107
+ ? `translate(${this._lineScale(d.x)},${this._yAxis(d.val)})`
1108
+ : null);
1109
+ }
1110
+ else {
1111
+ update
1112
+ .selectAll('path')
1113
+ .data((d, i) => {
1114
+ const toReturn = d.line.map((num) => {
1115
+ if (num[1] != null)
1116
+ return {
1117
+ val: num[1],
1118
+ x: num[0],
1119
+ title: d.title,
1120
+ colorToken: d.colorToken,
1121
+ index: i
1122
+ };
1123
+ else
1124
+ return null;
1125
+ });
1126
+ return toReturn.filter((e) => e);
1127
+ })
1128
+ .join((enter) => {
1129
+ enter
1130
+ .append('path')
1131
+ .attr('class', 'symbol')
1132
+ .attr('d', (d) => d ? this.symbolType(d.index) : null)
1133
+ .attr('fill', (d) => d ? this.colorFunction(d) : null)
1134
+ .attr('transform', (d) => d
1135
+ ? `translate(${this._lineScale(d.x)},${this._yAxis(d.val)})`
1136
+ : null)
1137
+ .attr('opacity', 0)
1138
+ .transition()
1139
+ .duration(400)
1140
+ .ease(polyInOut)
1141
+ .attr('opacity', 1);
1142
+ }, (update) => {
1143
+ update
1144
+ .transition()
1145
+ .duration(400)
1146
+ .ease(polyInOut)
1147
+ .attr('d', (d) => d ? this.symbolType(d.index) : null)
1148
+ .attr('fill', (d) => d ? this.colorFunction(d) : null)
1149
+ .attr('transform', (d) => d
1150
+ ? `translate(${this._lineScale(d.x)},${this._yAxis(d.val)})`
1151
+ : null);
1152
+ }, (exit) => exit.remove());
1153
+ }
1154
+ }, (exit) => exit.remove());
1155
+ };
1156
+ // Returns a symbol type given a index, currently we have support for 10 lines
1157
+ this.symbolType = (index, size) => {
1158
+ if (index < this.lineTypes)
1159
+ return Symbol()
1160
+ .type(circle)
1161
+ .size(size ? size : 90)();
1162
+ else if (index >= this.lineTypes && index < this.lineTypes * 2)
1163
+ return Symbol()
1164
+ .type(diamond)
1165
+ .size(size ? size : 90)();
1166
+ else
1167
+ return Symbol()
1168
+ .type(star)
1169
+ .size(size ? size : 90)();
1170
+ };
1171
+ // Setting dimension variable
1172
+ this.setDims = (onlyHeight = false) => {
1173
+ // Get title dimensions
1174
+ const tempTitle = select(this._titleDiv).node().getBoundingClientRect(), tempLegend = select(this._legendDiv).node().getBoundingClientRect();
1175
+ const rem = parseFloat(getComputedStyle(document.documentElement).fontSize);
1176
+ if (!onlyHeight)
1177
+ this.dims = select(this._chartDiv).node().getBoundingClientRect();
1178
+ this.dims.height =
1179
+ this._maxHeight - tempLegend.height - tempTitle.height - 1.75 * rem;
1180
+ };
1181
+ // Resizing svg element and its children
1182
+ this.resizeSvg = () => {
1183
+ if (this._loading)
1184
+ return this.loadingResize();
1185
+ this.setDims();
1186
+ this._svg.attr('width', this.dims.width).attr('height', this.dims.height);
1187
+ /**** Update yAxis ****/
1188
+ this._yAxis.range([this.dims.height - this.margin.bottom, this.margin.top]);
1189
+ // Fixed number of y-axis lines
1190
+ this.setYTicks(true);
1191
+ /**** Update xAxis ****/
1192
+ this._xAxis.range([
1193
+ 0,
1194
+ this.dims.width - this.margin.left - this.margin.right
1195
+ ]);
1196
+ const ticks = Math.min(Math.max(Math.floor((this.dims.width - this.margin.left - this.margin.right) /
1197
+ this._tickSize) - 2, 1), this._chartData.data.xValues.length);
1198
+ this._xAxisHandle
1199
+ .attr('transform', 'translate(0,' + (this.dims.height - this.margin.bottom) + ')')
1200
+ .call(axisBottom(this._xAxis)
1201
+ .ticks(ticks)
1202
+ .tickPadding(this.xPadding)
1203
+ .tickFormat((d) => {
1204
+ if (this._chartData.data.xValueNames)
1205
+ return this._chartData.data.xValueNames[this._chartData.data.xValues.indexOf(d)];
1206
+ else
1207
+ return d;
1208
+ }));
1209
+ this._Tipbox
1210
+ .attr('width', this.dims.width - this.margin.left / 2)
1211
+ .attr('height', this.dims.height - this.margin.top - this.margin.bottom)
1212
+ .attr('transform', `translate(${this.margin.left / 2},${this.margin.top})`);
1213
+ };
1214
+ // resizing chart while loading
1215
+ this.loadingResize = () => {
1216
+ this.setDims();
1217
+ this._svg.attr('width', this.dims.width);
1218
+ this.setYTicks();
1219
+ this._xAxis.range([
1220
+ 0,
1221
+ this.dims.width - this.margin.left - this.margin.right
1222
+ ]);
1223
+ const ticks = Math.min(Math.floor((this.dims.width - this.margin.left - this.margin.right) /
1224
+ this._tickSize) - 2, this._xAxis.domain()[1]);
1225
+ this._xAxisHandle.call(axisBottom(this._xAxis)
1226
+ .ticks(ticks)
1227
+ .tickPadding(this.xPadding)
1228
+ .tickFormat((d) => {
1229
+ if (this._chartData.data && this._chartData.data.xValueNames)
1230
+ return this._chartData.data.xValueNames[this._chartData.data.xValues.indexOf(d)];
1231
+ else
1232
+ return d;
1233
+ }));
1234
+ this._lineScale.range([
1235
+ 0,
1236
+ this.dims.width - this.margin.left - this.margin.right
1237
+ ]);
1238
+ const LineFunc = line()
1239
+ .defined((d) => d[1] != null)
1240
+ .x((d) => this._lineScale(d[0]))
1241
+ .y((d) => this._yAxis(d[1]))
1242
+ .curve(basis);
1243
+ this._lineChartContainer
1244
+ .selectAll('.linePath')
1245
+ .attr('d', (d) => LineFunc(d));
1246
+ };
1247
+ this.resizeLines = () => {
1248
+ if (this._loading)
1249
+ return;
1250
+ this._lineScale.range([
1251
+ 0,
1252
+ this.dims.width - this.margin.left - this.margin.right
1253
+ ]);
1254
+ this.defineLineAndScale();
1255
+ this._lineChartContainer
1256
+ .selectAll('.linePath')
1257
+ .attr('stroke', (d) => this.colorFunction(d))
1258
+ .attr('d', (d) => this._LineFunc(d.line));
1259
+ this._lineChartContainer
1260
+ .selectAll('.symbolGroup')
1261
+ .selectAll('.symbol')
1262
+ .attr('transform', (d, i) => d
1263
+ ? `translate(${this._lineScale(this._chartData.data.xValues[i])},${this._yAxis(d.val)})`
1264
+ : null);
1265
+ };
1266
+ this.colorFunction = (properties) => {
1267
+ return properties.colorToken
1268
+ ? getComputedStyle(document.documentElement)
1269
+ .getPropertyValue(properties.colorToken)
1270
+ .trim()
1271
+ .toLocaleLowerCase()
1272
+ : this._Color(properties.title);
1273
+ };
1274
+ this.drawTooltipLine = (event) => {
1275
+ if (this._toggled)
1276
+ return this.drawDottedLine(event);
1277
+ this.drawMainLineAndCircles(event);
1278
+ };
1279
+ this.closeTooltip = () => {
1280
+ this._toggled = false;
1281
+ this._tooltip.style('display', 'none');
1282
+ this._secondaryLine.attr('display', 'none');
1283
+ this._TooltipLine.attr('display', 'none');
1284
+ this._Circles.selectAll('circle').attr('display', 'none');
1285
+ this._Circles
1286
+ .selectAll('circle')
1287
+ .attr('fill', 'white')
1288
+ .attr('stroke', (d) => this.colorFunction(d));
1289
+ this._svg.select('.tooltipPointer').remove();
1290
+ };
1291
+ this.drawDottedLine = (event) => {
1292
+ this._hoverPoint = this.closest(Math.round(this._lineScale.invert(pointer(event, this._Tipbox.node())[0] - this.margin.left / 2)));
1293
+ if (this._hoverPoint === this._tooltipPoint)
1294
+ return this._secondaryLine.attr('display', 'none');
1295
+ this._secondaryLine
1296
+ .attr('display', null)
1297
+ .attr('stroke', 'gray')
1298
+ .attr('stroke-dasharray', 4)
1299
+ .attr('x1', this._xAxis(this._hoverPoint.toString()) + this.margin.left)
1300
+ .attr('x2', this._xAxis(this._hoverPoint.toString()) + this.margin.left)
1301
+ .attr('y1', this._yAxis(this._maxVal))
1302
+ .attr('y2', this.dims.height - this.margin.bottom)
1303
+ .style('pointer-events', 'none');
1304
+ };
1305
+ this.drawMainLineAndCircles = (event) => {
1306
+ this._hoverPoint = this.touchPosition(event);
1307
+ const stringPoint = this._hoverPoint.toString();
1308
+ this._TooltipLine
1309
+ .attr('display', null)
1310
+ .attr('stroke', 'gray')
1311
+ .attr('x1', this._xAxis(stringPoint) + this.margin.left)
1312
+ .attr('x2', this._xAxis(stringPoint) + this.margin.left)
1313
+ .attr('y1', this._yAxis(this._maxVal))
1314
+ .attr('y2', this.dims.height - this.margin.bottom)
1315
+ .style('pointer-events', 'none');
1316
+ this._Circles
1317
+ .selectAll('circle')
1318
+ .attr('display', null)
1319
+ .attr('pointer-events', 'none');
1320
+ this.positionCircles(stringPoint);
1321
+ };
1322
+ // Returns the position/index to draw tooltip/tooltip line
1323
+ this.touchPosition = (event) => {
1324
+ if (event.type === 'touchmove') {
1325
+ event.preventDefault();
1326
+ return this.closest(Math.round(this._lineScale.invert(pointer(event.touches[0], this._Tipbox.node())[0] -
1327
+ this.margin.left / 2)));
1328
+ }
1329
+ else {
1330
+ return this.closest(Math.round(this._lineScale.invert(pointer(event, this._Tipbox.node())[0] - this.margin.left / 2)));
1331
+ }
1332
+ };
1333
+ // Function for drawing tooltip
1334
+ this.drawTooltip = (event) => {
1335
+ this.drawMainLineAndCircles(event);
1336
+ this._toggled = true;
1337
+ this._tooltipPoint = this.touchPosition(event);
1338
+ this._tooltipDataIndex = this._chartData.data.xValues.indexOf(this._tooltipPoint);
1339
+ // Heading
1340
+ this._tooltip.style('display', 'flex');
1341
+ const tooltipBody = this._tooltip.select('.tooltipBody');
1342
+ tooltipBody
1343
+ .select(this._tooltipHeading)
1344
+ .style('margin', '0 0.75rem 0 0 ')
1345
+ .html(() => {
1346
+ if (this._chartData.data.xValueNames)
1347
+ return this._chartData.data.xValueNames[this._chartData.data.xValues.indexOf(this._tooltipPoint)];
1348
+ return this._tooltipPoint;
1349
+ });
1350
+ // Body
1351
+ tooltipBody
1352
+ .selectAll('div')
1353
+ .data(this._chartData.data.series)
1354
+ .join('div')
1355
+ .style('display', 'flex')
1356
+ .style('flex-direction', 'row')
1357
+ .style('flex-wrap', 'nowrap')
1358
+ .style('white-space', 'nowrap')
1359
+ .style('justify-content', 'space-between')
1360
+ .html((d) => {
1361
+ return d.yValues[this._tooltipDataIndex] != null
1362
+ ? '<span>' +
1363
+ d.title +
1364
+ '</span><span style="margin-left:0.75rem;">' +
1365
+ formatLocale(this.axisNumberFormat).format(this.formatStyle)(d.yValues[this._tooltipDataIndex]) +
1366
+ '</span>'
1367
+ : null;
1368
+ });
1369
+ this.positionTooltipWithinBounds(this._xAxis(this._tooltipPoint.toString()) + this.margin.left);
1370
+ this._Circles
1371
+ .selectAll('circle')
1372
+ .attr('fill', (d) => this.colorFunction(d))
1373
+ .attr('stroke', 'white');
1374
+ this._svg.select('.tooltipPointer').remove();
1375
+ const sym = Symbol().type(triangle).size(60);
1376
+ this._svg
1377
+ .append('path')
1378
+ .attr('d', sym)
1379
+ .attr('class', 'tooltipPointer')
1380
+ .attr('fill', 'rgba(10, 10, 10, 0.90)')
1381
+ .style('filter', 'drop-shadow(gray 0px -1px 1px)')
1382
+ .attr('transform', `translate(${this._xAxis(this._tooltipPoint.toString()) + this.margin.left},${this._yAxis(this._maxVal) - 7}) rotate(180) scale(1.5,1.0)`);
1383
+ };
1384
+ this.initYAxis = (empty) => {
1385
+ // Y Axis
1386
+ this._yAxis = linear()
1387
+ .domain([0, empty ? 10 : this._maxVal])
1388
+ .nice(3)
1389
+ .range([this.dims.height - this.margin.bottom, this.margin.top]);
1390
+ // The magic number is just needed in initialization, because getting the exact size is impossible during the initialization
1391
+ this.margin.left =
1392
+ this.getTextSize(formatLocale(this.axisNumberFormat).format(this.formatStyle)(this._yAxis.domain()[1])) +
1393
+ this.yPadding +
1394
+ 3;
1395
+ this._lineChartContainer = this._svg
1396
+ .append('g')
1397
+ .attr('transform', `translate(${this.margin.left},0)`);
1398
+ this._yAxisHandle = this._lineChartContainer
1399
+ .append('g')
1400
+ .attr('class', 'yAxis');
1401
+ this.setYTicks(true);
1402
+ };
1403
+ this.initXAxis = (empty) => {
1404
+ this._lineChartContainer.select('.xAxis').remove();
1405
+ // X axis
1406
+ if (!empty) {
1407
+ if (this._chartData.data.xValueNames)
1408
+ this.margin.right =
1409
+ this.getTextSize(this._chartData.data.xValueNames[this._chartData.data.xValueNames.length - 1]) /
1410
+ 2 +
1411
+ 1;
1412
+ else
1413
+ this.margin.right =
1414
+ this.getTextSize(max(this._chartData.data.xValues).toString()) /
1415
+ 2 +
1416
+ 1;
1417
+ }
1418
+ this._xAxis = linear()
1419
+ .domain([
1420
+ empty ? 1 : min(this._chartData.data.xValues),
1421
+ empty ? 10 : max(this._chartData.data.xValues)
1422
+ ]) // This is the min and the max of the data
1423
+ .range([0, this.dims.width - this.margin.left - this.margin.right]);
1424
+ this._lineScale = linear()
1425
+ .domain([
1426
+ empty ? 1 : min(this._chartData.data.xValues),
1427
+ empty ? 10 : max(this._chartData.data.xValues)
1428
+ ]) // This is the min and the max of the data
1429
+ .range([0, this.dims.width - this.margin.left - this.margin.right]);
1430
+ const ticks = Math.min(Math.max(Math.floor((this.dims.width - this.margin.left - this.margin.right) /
1431
+ this._tickSize) - 2, 2), empty ? 10 : this._chartData.data.xValues.length);
1432
+ this._xAxisHandle = this._lineChartContainer
1433
+ .append('g')
1434
+ .attr('transform', 'translate(0,' + (this.dims.height - this.margin.bottom) + ')')
1435
+ .attr('class', 'xAxis')
1436
+ .style('font-size', this.fontSize)
1437
+ .call(axisBottom(this._xAxis)
1438
+ .ticks(ticks)
1439
+ .tickSize(this.xTickSize)
1440
+ .tickPadding(this.xPadding)
1441
+ .tickFormat((d) => {
1442
+ if (!empty && this._chartData.data.xValueNames)
1443
+ return this._chartData.data.xValueNames[this._chartData.data.xValues.indexOf(d)];
1444
+ else
1445
+ return d;
1446
+ }));
1447
+ // Removing the domain
1448
+ this._xAxisHandle.select('.domain').attr('display', 'none');
1449
+ this._xAxisHandle
1450
+ .selectAll('line')
1451
+ .attr('stroke-linecap', 'round')
1452
+ .attr('stroke', getComputedStyle(document.documentElement)
1453
+ .getPropertyValue('--digi--global--color--neutral--grayscale--darkest-3')
1454
+ .trim()
1455
+ .toLocaleLowerCase());
1456
+ };
1457
+ this.positionCircles = (point, transition) => {
1458
+ if (transition) {
1459
+ this._Circles
1460
+ .selectAll('circle')
1461
+ .transition('positioncircles')
1462
+ .duration(transition)
1463
+ .attr('cx', () => {
1464
+ return this._xAxis(point) + this.margin.left;
1465
+ })
1466
+ .attr('cy', (d, i, circleList) => {
1467
+ const selData = d.yValues[this._chartData.data.xValues.indexOf(parseInt(point))];
1468
+ if (this._yAxis(selData))
1469
+ return this._yAxis(selData);
1470
+ else {
1471
+ select(circleList[i]).attr('display', 'none');
1472
+ return null;
1473
+ }
1474
+ });
1475
+ }
1476
+ else {
1477
+ this._Circles
1478
+ .selectAll('circle')
1479
+ .attr('cx', () => {
1480
+ return this._xAxis(point) + this.margin.left;
1481
+ })
1482
+ .attr('cy', (d, i, circleList) => {
1483
+ const selData = d.yValues[this._chartData.data.xValues.indexOf(parseInt(point))];
1484
+ if (this._yAxis(selData))
1485
+ return this._yAxis(selData);
1486
+ else {
1487
+ select(circleList[i]).attr('display', 'none');
1488
+ return null;
1489
+ }
1490
+ });
1491
+ }
1492
+ };
1493
+ this.repositionTooltip = () => {
1494
+ if (!this._toggled)
1495
+ return;
1496
+ const stringPoint = this._chartData.data.xValues[this._tooltipDataIndex].toString();
1497
+ this._TooltipLine
1498
+ .attr('stroke', 'gray')
1499
+ .attr('x1', this._xAxis(stringPoint) + this.margin.left)
1500
+ .attr('x2', this._xAxis(stringPoint) + this.margin.left)
1501
+ .attr('y1', this._yAxis(this._maxVal))
1502
+ .attr('y2', this.dims.height - this.margin.bottom);
1503
+ this.positionTooltipWithinBounds(this._xAxis(stringPoint) + this.margin.left);
1504
+ this._svg
1505
+ .select('.tooltipPointer')
1506
+ .attr('transform', `translate(${this._xAxis(this._tooltipPoint.toString()) + this.margin.left},${this._yAxis(this._maxVal) - 7}) rotate(180) scale(1.5,1.0)`);
1507
+ this.positionCircles(stringPoint);
1508
+ };
1509
+ // Checks if tooltip bounding box is outside svg width, if so, moves tooltip within svg bounds
1510
+ this.positionTooltipWithinBounds = (pos, transitionTimer) => {
1511
+ this._tooltip.style('transform', () => {
1512
+ // We reset the position of the tooltip, and adjust for the maximum value, -1px for it to align perfectly
1513
+ return `translateY(${this._yAxis(this._maxVal) - this._tooltip.node().getBoundingClientRect().height - 9}px)`;
1514
+ });
1515
+ const rect = this._chartDiv.getBoundingClientRect();
1516
+ const comparativePosition = pos + rect.left;
1517
+ const tooltipWidth = this._tooltip.node().getBoundingClientRect().width / 2;
1518
+ if (rect.left < comparativePosition - tooltipWidth &&
1519
+ rect.right > comparativePosition + tooltipWidth) {
1520
+ this._tooltip.style('left', pos - tooltipWidth + 'px');
1521
+ }
1522
+ else if (rect.right < comparativePosition + tooltipWidth) {
1523
+ this._tooltip.style('left', pos -
1524
+ this._tooltip.node().getBoundingClientRect().width +
1525
+ Math.max(this.margin.right, 10) +
1526
+ 'px');
1527
+ }
1528
+ else if (rect.left > comparativePosition - tooltipWidth) {
1529
+ if (transitionTimer)
1530
+ this._tooltip
1531
+ .transition('moveTooltip')
1532
+ .duration(transitionTimer)
1533
+ .ease(polyInOut)
1534
+ .style('left', pos - this.margin.left + 'px');
1535
+ else
1536
+ this._tooltip.style('left', pos - this.margin.left + 'px');
1537
+ }
1538
+ else {
1539
+ this._tooltip.style('left', pos -
1540
+ document.getElementById(this.afId).getBoundingClientRect().width / 2 +
1541
+ 'px');
1542
+ }
1543
+ };
1544
+ this.mapColorToLine = () => {
1545
+ // list of group names
1546
+ this._Color = ordinal()
1547
+ .domain(this._chartData.data.series.map(function (d) {
1548
+ return d.title;
1549
+ }))
1550
+ .range([
1551
+ '#00005a',
1552
+ '#D43372',
1553
+ '#058470',
1554
+ '#0058A3',
1555
+ '#556D22',
1556
+ '#1616B2',
1557
+ '#AA295B',
1558
+ '#035548'
1559
+ ]);
1560
+ };
1561
+ this.computeMaxVal = () => {
1562
+ // Compute max value from datasets
1563
+ this._maxVal = parseFloat(max(this._chartData.data.series, (d) => max(d['yValues'])));
1564
+ };
1565
+ // Updates number format if specified to be in percentage
1566
+ this.checkPercentage = () => {
1567
+ if (this._chartData.meta && this._chartData.meta.percentage)
1568
+ this.formatStyle = '.1%';
1569
+ else
1570
+ this.formatStyle = ',d';
1571
+ };
1572
+ this.closest = (target) => {
1573
+ return this._chartData.data.xValues.reduce(function (prev, curr) {
1574
+ return Math.abs(curr - target) < Math.abs(prev - target) ? curr : prev;
1575
+ });
1576
+ };
1577
+ // Removes resize observer for chart and inits table
1578
+ this.activateTable = (event) => {
1579
+ this.closeTooltip();
1580
+ this.lineChartObserver.disconnect();
1581
+ this.tableObserver.observe(this._chartDiv);
1582
+ this._status.innerHTML = '<p>Visas som tabell</p>';
1583
+ select(this._host).select('.tableButton').style('display', 'none');
1584
+ select(this._host).select('.chartButton').style('display', null);
1585
+ event.target.nextSibling.lastChild.focus();
1586
+ const duration = 150;
1587
+ this._svg
1588
+ .attr('opacity', 1)
1589
+ .transition('fadeout')
1590
+ .duration(duration)
1591
+ .attr('opacity', 0)
1592
+ .on('end', () => {
1593
+ this._svg.remove();
1594
+ this._legendDiv.style['display'] = 'none';
1595
+ this._tableDiv.style['display'] = 'block';
1596
+ this.setTableContent();
1597
+ this.setTableDimensions();
1598
+ select(this._tableDiv)
1599
+ .style('opacity', 0)
1600
+ .transition('fadein')
1601
+ .duration(duration)
1602
+ .style('opacity', 1);
1603
+ });
1604
+ select(this._legendDiv)
1605
+ .style('opacity', 1)
1606
+ .transition('fadeout')
1607
+ .duration(duration)
1608
+ .style('opacity', 0);
1609
+ };
1610
+ // Resize table
1611
+ this.resizeTable = () => {
1612
+ this.setDims();
1613
+ this.setTableDimensions();
1614
+ };
1615
+ // Removes observer and calls init functions for line chart
1616
+ this.reInitChart = (event) => {
1617
+ this.tableObserver.disconnect();
1618
+ this._status.innerHTML = '<p>Visas som diagram</p>';
1619
+ select(this._host).select('.tableButton').style('display', null);
1620
+ select(this._host).select('.chartButton').style('display', 'none');
1621
+ event.target.previousSibling.lastChild.focus();
1622
+ const table = select(this._tableDiv);
1623
+ table
1624
+ .style('opacity', 1)
1625
+ .transition()
1626
+ .duration(150)
1627
+ .style('opacity', 0)
1628
+ .on('end', () => {
1629
+ table.style('display', 'none');
1630
+ this.initSvg();
1631
+ this.initLines();
1632
+ this._svg
1633
+ .attr('opacity', 0)
1634
+ .transition()
1635
+ .duration(150)
1636
+ .attr('opacity', 1);
1637
+ select(this._legendDiv)
1638
+ .style('display', null)
1639
+ .style('opacity', 0)
1640
+ .transition()
1641
+ .duration(150)
1642
+ .style('opacity', 1);
1643
+ });
1644
+ };
1645
+ this.afHeadingLevel = undefined;
1646
+ this.afId = randomIdGenerator('tooltip');
1647
+ this.afChartData = undefined;
1648
+ }
1649
+ afChartDataUpdate() {
1650
+ const data = this.afChartData;
1651
+ if (typeof data === 'object') {
1652
+ this._chartData = Object.assign({}, data);
1653
+ return;
1654
+ }
1655
+ this._chartData = JSON.parse(data);
1656
+ // Making deep copy of this
1657
+ if (this._chartData.data)
1658
+ this._coreSeries = JSON.parse(JSON.stringify(this._chartData.data.series));
1659
+ }
1660
+ initSvg() {
1661
+ this.margin.bottom =
1662
+ Number(window
1663
+ .getComputedStyle(document.body)
1664
+ .getPropertyValue('font-size')
1665
+ .match(/\d+/)[0]) *
1666
+ Number(this.fontSize.replace(/[^\d.]|\.(?=.*\.)/g, '')) +
1667
+ this.xPadding +
1668
+ this.xTickSize;
1669
+ this.lineChartObserver.observe(this._chartDiv);
1670
+ select(this._chartDiv).select('svg').remove();
1671
+ // Initialize an empty div, that we can place info in for tooltip
1672
+ // Styling for tooltip is in .scss file
1673
+ this._tooltip = select('#' + this.afId);
1674
+ this._tooltip.select('.close').on('click', this.closeTooltip);
1675
+ this._tooltipHeading =
1676
+ 'h' + (parseInt(this.afHeadingLevel.replace(/\D/g, '')) + 1);
1677
+ // Add heading placeholder for heading
1678
+ this._tooltip
1679
+ .selectAll('.tooltipBody')
1680
+ .append(this._tooltipHeading) // increment heading level by one
1681
+ .style('margin', '0 0.75rem')
1682
+ .style('font-weight', '500');
1683
+ this._maxHeight = select(this._host)
1684
+ .node()
1685
+ .parentNode.getBoundingClientRect().height;
1686
+ this.setDims();
1687
+ this.setTickSize();
1688
+ this.checkPercentage();
1689
+ select(this._chartDiv).attr('height', this.dims.height + 'px');
1690
+ // Appending svg
1691
+ this._svg = select(this._chartDiv)
1692
+ .append('svg')
1693
+ .attr('aria-hidden', true)
1694
+ .attr('role', 'img')
1695
+ .attr('aria-label', this._chartData && this._chartData.title
1696
+ ? 'Linjediagram om ' + this._chartData.title.toLowerCase()
1697
+ : 'Linjediagram');
1698
+ this._svg.attr('width', this.dims.width).attr('height', this.dims.height);
1699
+ this.mapColorToLine();
1700
+ this._TooltipLine = this._svg
1701
+ .append('line')
1702
+ .attr('id', 'toolTipLine' + this.afId);
1703
+ this._secondaryLine = this._svg
1704
+ .append('line')
1705
+ .attr('id', 'secondaryLine' + this.afId);
1706
+ this.computeMaxVal();
1707
+ this.initYAxis();
1708
+ this.initXAxis();
1709
+ this._Tipbox = this._svg
1710
+ .append('rect')
1711
+ .attr('class', 'svgRect')
1712
+ .attr('width', this.dims.width - this.margin.left / 2)
1713
+ .attr('height', this.dims.height - this.margin.top - this.margin.bottom)
1714
+ .attr('opacity', 0)
1715
+ .attr('transform', `translate(${this.margin.left / 2},0)`);
1716
+ this.addListenersToChart();
1717
+ this._Circles = this._svg
1718
+ .append('g')
1719
+ .attr('class', 'circleGroup')
1720
+ .on('mousemove', this.drawTooltipLine);
1721
+ this._Circles
1722
+ .selectAll('circle')
1723
+ .data(this._chartData.data.series)
1724
+ .join('circle')
1725
+ .attr('stroke', (d) => this.colorFunction(d))
1726
+ .attr('fill', 'white')
1727
+ .attr('stroke-width', '1px')
1728
+ .attr('r', 7)
1729
+ .attr('display', 'none');
1730
+ select(window).on('resize.' + this.afId, this.repositionTooltip);
1731
+ }
1732
+ // Initializing chart with empty dataset
1733
+ initEmpty() {
1734
+ this.margin.bottom =
1735
+ Number(window
1736
+ .getComputedStyle(document.body)
1737
+ .getPropertyValue('font-size')
1738
+ .match(/\d+/)[0]) *
1739
+ Number(this.fontSize.replace(/[^\d.]|\.(?=.*\.)/g, '')) +
1740
+ this.xPadding +
1741
+ this.xTickSize;
1742
+ select(this._chartDiv).select('svg').remove();
1743
+ // Initialize an empty div, that we can place info in for tooltip
1744
+ // Styling for tooltip is in .scss file
1745
+ this._tooltip = select('#' + this.afId);
1746
+ select('digi-icon-x').on('click', this.closeTooltip);
1747
+ this._tooltipHeading =
1748
+ 'h' + (parseInt(this.afHeadingLevel.replace(/\D/g, '')) + 1);
1749
+ // Add heading placeholder for heading
1750
+ this._tooltip
1751
+ .selectAll('.tooltipBody')
1752
+ .append(this._tooltipHeading) // increment heading level by one
1753
+ .style('margin', '0 0.75rem')
1754
+ .style('font-weight', '500');
1755
+ this._maxHeight = select(this._host)
1756
+ .node()
1757
+ .parentNode.getBoundingClientRect().height;
1758
+ this.setDims();
1759
+ select(this._chartDiv).attr('height', this.dims.height + 'px');
1760
+ this._svg = select(this._chartDiv)
1761
+ .append('svg')
1762
+ .attr('aria-hidden', true);
1763
+ this._svg.attr('width', this.dims.width).attr('height', this.dims.height);
1764
+ this._TooltipLine = this._svg
1765
+ .append('line')
1766
+ .attr('id', 'toolTipLine' + this.afId);
1767
+ this._secondaryLine = this._svg
1768
+ .append('line')
1769
+ .attr('id', 'secondaryLine' + this.afId);
1770
+ this.initYAxis(true);
1771
+ this.initXAxis(true);
1772
+ this._Tipbox = this._svg
1773
+ .append('rect')
1774
+ .attr('class', 'svgRect')
1775
+ .attr('width', this.dims.width - this.margin.left / 2)
1776
+ .attr('height', this.dims.height - this.margin.top - this.margin.bottom)
1777
+ .attr('opacity', 0)
1778
+ .attr('transform', `translate(${this.margin.left / 2},0)`);
1779
+ this._Circles = this._svg
1780
+ .append('g')
1781
+ .attr('class', 'circleGroup')
1782
+ .on('mousemove', this.drawTooltipLine);
1783
+ this.defineLineAndScale();
1784
+ this.lineChartObserver.observe(this._chartDiv);
1785
+ this.loadingState(true);
1786
+ }
1787
+ loadingState(empty) {
1788
+ this._loading = true;
1789
+ select('.tableButton').style('display', 'none');
1790
+ const duration = 400;
1791
+ const LineFunc = line()
1792
+ .defined((d) => d[1] != null)
1793
+ .x((d) => this._lineScale(d[0]))
1794
+ .y((d) => this._yAxis(d[1]))
1795
+ .curve(basis);
1796
+ // close potentially open tooltip
1797
+ this.closeTooltip();
1798
+ // Remove hover listeners from chart
1799
+ this._Tipbox
1800
+ .style('cursor', 'wait')
1801
+ .on('mousemove', null)
1802
+ .on('touchmove', null)
1803
+ .on('mouseup', null)
1804
+ .on('mouseleave', null);
1805
+ select(this._titleDiv)
1806
+ .select(this.afHeadingLevel)
1807
+ .html(`${_t.loading}...`);
1808
+ const height = select(this._titleDiv).style('height');
1809
+ select(this._titleDiv)
1810
+ .style('height', this._prevHeight)
1811
+ .transition('adjust')
1812
+ .duration(400)
1813
+ .style('height', height)
1814
+ .on('end', () => select(this._titleDiv).style('height', null));
1815
+ select(this._legendDiv).style('display', 'none');
1816
+ const animateRandomLine = () => {
1817
+ let firstVal = this._xAxis.domain()[0];
1818
+ const randomData = [...Array(this._xAxis.domain()[1])].map(() => {
1819
+ const dataPoint = [
1820
+ firstVal,
1821
+ Math.round(Math.random() * this._yAxis.domain()[1] * 100) / 100
1822
+ ]; // This assumes domain is from 0 to maxVal
1823
+ firstVal++;
1824
+ return dataPoint;
1825
+ });
1826
+ this._lineChartContainer.selectAll('.linePath').remove();
1827
+ this._lineChartContainer
1828
+ .selectAll('linePath')
1829
+ .data([randomData])
1830
+ .join('path')
1831
+ .attr('class', 'linePath')
1832
+ .attr('stroke', 'lightgray')
1833
+ .attr('stroke-linecap', 'round')
1834
+ .attr('stroke-width', 4)
1835
+ .attr('fill', 'none')
1836
+ .attr('d', (d) => LineFunc(d))
1837
+ .transition()
1838
+ .duration(duration * 3)
1839
+ .ease(quadInOut)
1840
+ .attrTween('stroke-dasharray', function () {
1841
+ const length = this.getTotalLength();
1842
+ return interpolate(`0,${length}`, `${length},${length}`);
1843
+ })
1844
+ .on('end', () => {
1845
+ this._lineChartContainer
1846
+ .selectAll('.linePath')
1847
+ .attr('stroke-dasharray', function () {
1848
+ const length = this.getTotalLength();
1849
+ return length + ' ' + length;
1850
+ })
1851
+ .attr('stroke-dashoffset', 0)
1852
+ .transition()
1853
+ .duration(duration * 3)
1854
+ .ease(quadInOut)
1855
+ .attr('stroke-dashoffset', function () {
1856
+ return -this.getTotalLength();
1857
+ })
1858
+ .on('end', () => animateRandomLine());
1859
+ });
1860
+ };
1861
+ const flattenLines = () => {
1862
+ const data = this._lineChartContainer
1863
+ .selectAll('.linePath')
1864
+ .data()
1865
+ .map((elem) => {
1866
+ elem.line = elem.line.map((point) => {
1867
+ return point[1]
1868
+ ? [point[0], this._yAxis.domain()[0]]
1869
+ : [point[0], undefined];
1870
+ });
1871
+ return elem;
1872
+ });
1873
+ this._lineChartContainer
1874
+ .selectAll('.linePath')
1875
+ .data(data)
1876
+ .transition()
1877
+ .duration(duration)
1878
+ .ease(polyInOut)
1879
+ .attr('d', (d) => this._LineFunc(d.line))
1880
+ .on('end', (...[, i]) => (i === 0 ? animateRandomLine() : null));
1881
+ this._lineChartContainer
1882
+ .selectAll('.symbolGroup')
1883
+ .selectAll('.symbol')
1884
+ .transition()
1885
+ .duration(duration)
1886
+ .ease(linear$1)
1887
+ .attr('transform', (d) => d
1888
+ ? `translate(${this._lineScale(d.x)},${this._yAxis(this._yAxis.domain()[0])})`
1889
+ : null)
1890
+ .attr('opacity', 0);
1891
+ };
1892
+ // Start loadingstate, either from empty set or last set
1893
+ if (empty)
1894
+ animateRandomLine();
1895
+ else
1896
+ flattenLines();
1897
+ }
1898
+ updateSvg() {
1899
+ // displaying legend again
1900
+ if (this._loading) {
1901
+ select(this._host).select('.tableButton').style('display', null);
1902
+ select(this._legendDiv).style('display', null);
1903
+ select(this._titleDiv).style('height', null);
1904
+ }
1905
+ if (this._chartData.data.xValueNames)
1906
+ this.margin.right =
1907
+ this.getTextSize(this._chartData.data.xValueNames[this._chartData.data.xValueNames.length - 1]) /
1908
+ 2 +
1909
+ 1;
1910
+ else
1911
+ this.margin.right =
1912
+ this.getTextSize(max(this._chartData.data.xValues).toString()) / 2 +
1913
+ 1;
1914
+ this.checkPercentage();
1915
+ this.setDims(true);
1916
+ this.mapColorToLine();
1917
+ this.computeMaxVal();
1918
+ this.setTickSize();
1919
+ select(this._chartDiv).attr('height', this.dims.height + 'px');
1920
+ // Updating Svg attributes
1921
+ this._svg
1922
+ .attr('width', this.dims.width + 'px')
1923
+ .attr('height', this.dims.height + 'px')
1924
+ .attr('aria-label', this._chartData && this._chartData.title
1925
+ ? 'Linjediagram om ' + this._chartData.title.toLowerCase()
1926
+ : 'Linjediagram');
1927
+ // Y Axis
1928
+ this._yAxis = linear()
1929
+ .domain([0, this._maxVal])
1930
+ .nice(3)
1931
+ .range([this.dims.height - this.margin.bottom, this.margin.top]);
1932
+ // Updating margins
1933
+ this.margin.left =
1934
+ this.getTextSize(formatLocale(this.axisNumberFormat).format(this.formatStyle)(this._yAxis.domain()[1])) +
1935
+ this.yPadding +
1936
+ 3;
1937
+ /**** Update xAxis ****/
1938
+ const oldDomain = this._xAxis.domain();
1939
+ this.initXAxis();
1940
+ this._lineChartContainer
1941
+ .transition('position')
1942
+ .duration(400)
1943
+ .ease(polyInOut)
1944
+ .attr('width', this.dims.width)
1945
+ .attr('height', this.dims.height)
1946
+ .attr('transform', `translate(${this.margin.left},0)`);
1947
+ this.setYTicks();
1948
+ this.defineLineAndScale();
1949
+ //this.leftSetAxis();
1950
+ this.addSymbols(true);
1951
+ if (this._loading) {
1952
+ select(this._host).select('.tableButton').style('display', null);
1953
+ this.addListenersToChart();
1954
+ const height = select(this._titleDiv).style('height');
1955
+ select(this._titleDiv)
1956
+ .style('height', this._prevHeight)
1957
+ .transition('adjust')
1958
+ .duration(400)
1959
+ .style('height', height)
1960
+ .on('end', () => select(this._titleDiv).style('height', null));
1961
+ select(this._legendDiv)
1962
+ .style('opacity', 0)
1963
+ .transition()
1964
+ .duration(400)
1965
+ .ease(polyInOut)
1966
+ .style('opacity', 1);
1967
+ this._lineChartContainer.selectAll('.linePath').on('end', null);
1968
+ // Setting starting state for symbols
1969
+ this._lineChartContainer
1970
+ .selectAll('.symbolGroup')
1971
+ .selectAll('.symbol')
1972
+ .attr('opacity', 0)
1973
+ .attr('transform', (d) => d
1974
+ ? `translate(${this._lineScale(d.x)},${this._yAxis(this._yAxis.domain()[0])})`
1975
+ : null);
1976
+ this._lineChartContainer
1977
+ .selectAll('.linePath')
1978
+ .transition()
1979
+ .duration(400)
1980
+ .ease(quadInOut)
1981
+ .attr('stroke-dashoffset', function () {
1982
+ return -this.getTotalLength();
1983
+ })
1984
+ .on('end', () => {
1985
+ this._lineChartContainer
1986
+ .selectAll('.linePath')
1987
+ .data(this.reshapeData(this._chartData.data.series))
1988
+ .join('path')
1989
+ .attr('class', 'linePath')
1990
+ .attr('stroke', (d) => this.colorFunction(d))
1991
+ .attr('stroke-linecap', 'round')
1992
+ .attr('stroke-width', 4)
1993
+ .attr('fill', 'none')
1994
+ .attr('stroke-dasharray', this.dashFunction)
1995
+ .attr('stroke-dashoffset', null)
1996
+ .attr('d', (d) => this._LineFunc(d.line.map((pair) => [
1997
+ pair[0],
1998
+ this._yAxis.domain()[0]
1999
+ ])));
2000
+ // Transitioning in lines
2001
+ this._lineChartContainer
2002
+ .selectAll('.linePath')
2003
+ .transition()
2004
+ .duration(400)
2005
+ .ease(polyInOut)
2006
+ .attr('d', (d) => this._LineFunc(d.line));
2007
+ // Transitioning in symbols
2008
+ this._lineChartContainer
2009
+ .selectAll('.symbolGroup')
2010
+ .selectAll('.symbol')
2011
+ .transition()
2012
+ .duration(400)
2013
+ .ease(polyInOut)
2014
+ .attr('transform', (d) => d
2015
+ ? `translate(${this._lineScale(d.x)},${this._yAxis(d.val)})`
2016
+ : null)
2017
+ .attr('opacity', 1);
2018
+ this._loading = false;
2019
+ });
2020
+ }
2021
+ else {
2022
+ this._lineChartContainer
2023
+ .selectAll('.linePath')
2024
+ .data(this.reshapeData(this._chartData.data.series))
2025
+ .join('path')
2026
+ .transition()
2027
+ .duration(400)
2028
+ .ease(polyInOut)
2029
+ .attr('class', 'linePath')
2030
+ .attr('stroke', (d) => this.colorFunction(d))
2031
+ .attr('stroke-linecap', 'round')
2032
+ .attr('stroke-width', (d) => (d.length > 1 ? 4 : 6))
2033
+ .attr('fill', 'none')
2034
+ .attr('stroke-dasharray', (d, i) => d.length > 1 ? this.dashFunction(d, i) : null)
2035
+ .attr('d', (d) => this._LineFunc(d.line));
2036
+ }
2037
+ // If we have the exact same domain, the tooltip may continue to be active
2038
+ if (this._toggled && oldDomain === this._xAxis.domain()) {
2039
+ const stringPoint = this._chartData.data.xValues[this._tooltipDataIndex].toString();
2040
+ this._Circles
2041
+ .selectAll('circle')
2042
+ .data(this._chartData.data.series)
2043
+ .join('circle')
2044
+ .transition('New circles')
2045
+ .duration(400)
2046
+ .ease(polyInOut)
2047
+ .attr('stroke', 'white')
2048
+ .attr('fill', (d) => this.colorFunction(d))
2049
+ .attr('stroke-width', '1px')
2050
+ .attr('r', 7);
2051
+ this.positionCircles(stringPoint, 400);
2052
+ const oldPos = this._TooltipLine.attr('y1');
2053
+ this._TooltipLine
2054
+ .transition()
2055
+ .duration(400)
2056
+ .ease(polyInOut)
2057
+ .attr('x1', this._xAxis(stringPoint) + this.margin.left)
2058
+ .attr('x2', this._xAxis(stringPoint) + this.margin.left)
2059
+ .attr('y1', this._yAxis(this._maxVal))
2060
+ .attr('y2', this.dims.height - this.margin.bottom);
2061
+ const tooltipBody = this._tooltip.select('.tooltipBody');
2062
+ tooltipBody
2063
+ .select(this._tooltipHeading)
2064
+ .style('margin', '0 0.75rem')
2065
+ .html(() => {
2066
+ if (this._chartData.data.xValueNames)
2067
+ return this._chartData.data.xValueNames[this._tooltipPoint - 1];
2068
+ return this._tooltipPoint;
2069
+ });
2070
+ // Body
2071
+ tooltipBody
2072
+ .selectAll('div')
2073
+ .data(this._chartData.data.series)
2074
+ .join('div')
2075
+ .style('display', 'flex')
2076
+ .style('flex-direction', 'row')
2077
+ .style('flex-wrap', 'nowrap')
2078
+ .style('white-space', 'nowrap')
2079
+ .style('justify-content', 'space-between')
2080
+ .html((d) => {
2081
+ return ('<span>' +
2082
+ d.title +
2083
+ ':&nbsp</span><span class="tooltipVal">' +
2084
+ d.yValues[this._tooltipDataIndex] +
2085
+ '</span>');
2086
+ });
2087
+ this.positionTooltipWithinBounds(this._xAxis(stringPoint) + this.margin.left, 400);
2088
+ this._tooltip
2089
+ .style('transform', () => {
2090
+ // We reset the position of the tooltip, and adjust for the maximum value, -1px for it to align perfectly
2091
+ return `translateY(${oldPos - this._tooltip.node().getBoundingClientRect().height - 9}px)`;
2092
+ })
2093
+ .transition()
2094
+ .duration(400)
2095
+ .ease(polyInOut)
2096
+ .style('transform', () => {
2097
+ // We reset the position of the tooltip, and adjust for the maximum value, -1px for it to align perfectly
2098
+ return `translateY(${this._yAxis(this._maxVal) - this._tooltip.node().getBoundingClientRect().height - 9}px)`;
2099
+ });
2100
+ this._svg
2101
+ .select('.tooltipPointer')
2102
+ .transition()
2103
+ .duration(400)
2104
+ .ease(polyInOut)
2105
+ .attr('transform', `translate(${this._xAxis(stringPoint) + this.margin.left},${this._yAxis(this._maxVal) - 7}) rotate(180) scale(1.5,1.0)`);
2106
+ }
2107
+ else {
2108
+ this._Circles
2109
+ .selectAll('circle')
2110
+ .data(this._chartData.data.series)
2111
+ .join('circle')
2112
+ .attr('stroke', (d) => this.colorFunction(d))
2113
+ .attr('fill', 'white')
2114
+ .attr('stroke-width', '1px')
2115
+ .attr('r', 7)
2116
+ .attr('display', 'none');
2117
+ this.closeTooltip();
2118
+ }
2119
+ }
2120
+ componentWillLoad() {
2121
+ this.afChartDataUpdate();
2122
+ }
2123
+ componentDidLoad() {
2124
+ if (Object.keys(this._chartData).length === 0)
2125
+ return this.initEmpty();
2126
+ // clearing selection
2127
+ this._selectedLines = [];
2128
+ this.initSvg();
2129
+ this.initLegend();
2130
+ this.initLines();
2131
+ document.fonts.onloadingdone = () => {
2132
+ this.setTickSize();
2133
+ this.resizeSvg();
2134
+ };
2135
+ }
2136
+ componentWillUpdate() {
2137
+ this._prevHeight = select(this._titleDiv).style('height');
2138
+ }
2139
+ componentDidUpdate() {
2140
+ if (Object.keys(this._chartData).length === 0)
2141
+ return this.loadingState();
2142
+ // clearing selection
2143
+ this._selectedLines = [];
2144
+ this.updateSvg();
2145
+ this.initLegend();
2146
+ this.updateTableContent();
2147
+ }
2148
+ disconnectedCallback() {
2149
+ this.lineChartObserver.disconnect();
2150
+ }
2151
+ // Returns pixelwidth of text given the current fontSize (costly function using .each)
2152
+ getTextSize(text) {
2153
+ const textWidth = [];
2154
+ const svg = select(this._chartDiv).append('svg');
2155
+ svg
2156
+ .selectAll('dummyText')
2157
+ .data([text])
2158
+ .join('text')
2159
+ .attr('font-size', this.fontSize)
2160
+ .attr('font-family', 'sans-serif')
2161
+ .text((d) => d)
2162
+ .each((...[, i, nodelist]) => {
2163
+ const thisWidth = nodelist[i].getComputedTextLength() + 5; // A little extra padding, text sizes seems to be a little small compared to real life
2164
+ textWidth.push(thisWidth);
2165
+ nodelist[i].remove();
2166
+ });
2167
+ svg.remove().exit();
2168
+ return textWidth[0];
2169
+ }
2170
+ // Goes through all tick values and checks the biggest in size, this one will decide the default tick-size
2171
+ setTickSize() {
2172
+ // Padding on both sides comined
2173
+ const textPadding = 25; // 12.5 pixel padding on each side
2174
+ if (this._chartData.data.xValueNames) {
2175
+ for (const elem of this._chartData.data.xValueNames) {
2176
+ const size = this.getTextSize(elem) + textPadding;
2177
+ if (size > this._tickSize)
2178
+ this._tickSize = size;
2179
+ }
2180
+ }
2181
+ else {
2182
+ for (const elem of this._chartData.data.xValues) {
2183
+ const size = this.getTextSize(elem.toString()) + textPadding;
2184
+ if (size > this._tickSize)
2185
+ this._tickSize = size;
2186
+ }
2187
+ }
2188
+ }
2189
+ // Left-orients Y-axis text
2190
+ leftSetAxis(init = false) {
2191
+ const shiftArray = [];
2192
+ if (!init) {
2193
+ this._yAxisHandle
2194
+ .selectAll('text')
2195
+ .transition('shuffle text')
2196
+ .duration(400)
2197
+ .attr('transform', (...[, i, nodelist]) => {
2198
+ const size = nodelist[i].getComputedTextLength();
2199
+ shiftArray.push(size);
2200
+ return `translate(${-1 * (this.margin.left - (size + this.yPadding))},0)`;
2201
+ });
2202
+ this._yAxisHandle
2203
+ .selectAll('line')
2204
+ .transition('shuffle line')
2205
+ .duration(400)
2206
+ .attr('x1', (...[, i]) => {
2207
+ return -1 * (this.margin.left - (shiftArray[i] + this.yPadding));
2208
+ });
2209
+ }
2210
+ else {
2211
+ this._yAxisHandle
2212
+ .selectAll('text')
2213
+ .attr('transform', (...[, i, nodelist]) => {
2214
+ const size = nodelist[i].getComputedTextLength();
2215
+ shiftArray.push(size);
2216
+ return `translate(${-1 * (this.margin.left - (size + this.yPadding))},0)`;
2217
+ });
2218
+ this._yAxisHandle.selectAll('line').attr('x1', (...[, i]) => {
2219
+ return -1 * (this.margin.left - (shiftArray[i] + this.yPadding));
2220
+ });
2221
+ }
2222
+ }
2223
+ // Updating data if content changes
2224
+ updateTableContent() {
2225
+ if (this._tableDiv.style['display'] === '' ||
2226
+ this._tableDiv.style['display'] === 'none')
2227
+ return;
2228
+ this.setTableContent();
2229
+ this.animateTableDimensions();
2230
+ }
2231
+ // Setting table content from this._chartData
2232
+ setTableContent() {
2233
+ this._tableDiv.innerHTML = `<digi-table af-size="small" af-variation="primary"> <table><caption>${this._chartData.title}</caption><thead><tr>${this.headings()}</tr></thead><tbody>${this.tableBody()}</tbody></table></digi-table>`;
2234
+ }
2235
+ setTableDimensions() {
2236
+ const table = select(this._tableDiv);
2237
+ table
2238
+ // The last value is for compensating the padding set on the table element, changing padding in css, will need change in these two lines
2239
+ .style('height', this._maxHeight -
2240
+ select(this._titleDiv).node().getBoundingClientRect().height -
2241
+ parseFloat(getComputedStyle(document.documentElement).fontSize) *
2242
+ 0.65 +
2243
+ 'px');
2244
+ table.style('width', this.dims.width -
2245
+ parseFloat(getComputedStyle(document.documentElement).fontSize) * 0.65 +
2246
+ 'px');
2247
+ }
2248
+ animateTableDimensions() {
2249
+ const height = select(this._titleDiv).style('height');
2250
+ select(this._titleDiv)
2251
+ .style('height', this._prevHeight)
2252
+ .transition('adjust')
2253
+ .duration(400)
2254
+ .style('height', height)
2255
+ .on('end', () => select(this._titleDiv).style('height', null));
2256
+ const table = select(this._tableDiv);
2257
+ table
2258
+ .transition('adjustHeight')
2259
+ .duration(400)
2260
+ // The last value is for compensating the padding set on the table element, changing padding in css, will need change in these two lines
2261
+ .style('height', this._maxHeight -
2262
+ (parseFloat(height) +
2263
+ parseFloat(getComputedStyle(document.documentElement).fontSize) *
2264
+ 1.25) -
2265
+ parseFloat(getComputedStyle(document.documentElement).fontSize) *
2266
+ 0.65 +
2267
+ 'px');
2268
+ table.style('width', this.dims.width -
2269
+ parseFloat(getComputedStyle(document.documentElement).fontSize) * 0.65 +
2270
+ 'px');
2271
+ }
2272
+ // Extracting all headings from data and returning a string with <th>-elements with headings
2273
+ headings() {
2274
+ let headingsString = `<th scope="col">${this._chartData.x}</th>`;
2275
+ this._coreSeries.forEach((elem) => {
2276
+ headingsString = headingsString.concat(`<th scope="col">${elem.title}</th>`);
2277
+ });
2278
+ return headingsString;
2279
+ }
2280
+ // Building the table body
2281
+ tableBody() {
2282
+ let body = '';
2283
+ const loopable = this._chartData.data.xValueNames
2284
+ ? this._chartData.data.xValueNames
2285
+ : this._chartData.data.xValues;
2286
+ loopable.forEach((elem, index) => {
2287
+ let cells = '';
2288
+ this._coreSeries.forEach((serie) => {
2289
+ cells = cells.concat(`<td>${serie.yValues[index] != null ? formatLocale(this.axisNumberFormat).format(this.formatStyle)(serie.yValues[index]) : '-'}</td>`);
2290
+ });
2291
+ body = body.concat(`<tr><th scope='row'>${elem}${cells}</th></tr>`);
2292
+ });
2293
+ return body;
2294
+ }
2295
+ render() {
2296
+ let heading = '';
2297
+ if (!this._chartData.subTitle)
2298
+ heading = `<${this.afHeadingLevel}>${this._chartData.title}</${this.afHeadingLevel}>`;
2299
+ else
2300
+ heading = `<${this.afHeadingLevel}>${this._chartData.title}</${this.afHeadingLevel}><p>${this._chartData.subTitle}</p>`;
2301
+ return (h("host", { key: '23524b77e8aa2bb1cae912a08c4f35791074a769', ref: (el) => (this._host = el) }, h("div", { key: '75c7c1a8be55953b5547c5a3dd956027af73fbd1', class: "topWrapper", ref: (el) => (this._titleDiv = el) }, h("digi-typography", { key: '76e755f765d16611ecf82c2980f660f28cb0239a', class: "chartTitle", innerHTML: heading }), h("digi-button", { key: '6665f4a0c7f9ea09b938bd690f1ad2f2838f0c9c', class: "buttonWrapper tableButton", "af-size": "medium", "af-variation": "function", "af-full-width": "false", onAfOnClick: this.activateTable, afAriaLabel: `Visa tabell ${this._chartData.title ? this._chartData.title.toLowerCase() : ''}` }, h("digi-icon-table", { key: '05aee665d9cd4d743c37cda816a3f5a3fe3128f5', slot: "icon" }), "Visa tabell"), h("digi-button", { key: '9f42b7ac02cb3f45d5d2503a9e12836bd76ce862', style: { display: 'none' }, class: "buttonWrapper chartButton", "af-size": "medium", "af-variation": "function", "af-full-width": "false", onAfOnClick: this.reInitChart, afAriaLabel: `Visa diagram ${this._chartData.title ? this._chartData.title.toLowerCase() : ''}` }, h("digi-icon-chart", { key: '43e9db95020bf3d24c68a24b269a179d70d8d056', slot: "icon" }), "Visa diagram"), h("div", { key: 'fc14ac6bf87466a5655dc5416bac08d0627a41ef', class: "scChartStatus", role: "status", ref: (el) => (this._status = el) })), h("div", { key: 'd65b4ea0b2a3a0abdc7a94e1cfb82e425ba50d2e', class: "chartTooltip", id: this.afId }, h("div", { key: '0ecff411dd746d6f21b53ae0d39729a55bedd957', class: "tooltipBody" }), h("digi-icon-x", { key: '9dd0ba013b81972e3e74b2e068b808f443ba7bf4', class: "close" }), ' '), h("div", { key: '371ba97658cd0e4f3a251bff860c45a43e9da9f1', class: "chart", ref: (el) => (this._chartDiv = el) }), h("div", { key: 'b4f5e4c1bc605f857910ec423f9de0285ac27e88', class: "legend", ref: (el) => (this._legendDiv = el) }), h("div", { key: '6bcc5645b85e62d321a2c37cd365b2d36b577b9a', class: "table", ref: (el) => (this._tableDiv = el) }, ' ')));
2302
+ }
2303
+ get element() { return getElement(this); }
2304
+ static get watchers() { return {
2305
+ "afChartData": ["afChartDataUpdate"]
2306
+ }; }
2307
+ };
2308
+ ChartLine.style = DigiChartLineStyle0;
2309
+
2310
+ export { ChartLine as digi_chart_line };