@iamproperty/components 7.0.0 → 7.1.0--beta2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/css/components/actionbar.css.map +1 -1
- package/assets/css/components/actionbar.global.css.map +1 -1
- package/assets/css/components/address-lookup.css.map +1 -1
- package/assets/css/components/applied-filters.css.map +1 -1
- package/assets/css/components/barchart.component.css +1 -1
- package/assets/css/components/barchart.component.css.map +1 -1
- package/assets/css/components/card.component.css +1 -1
- package/assets/css/components/card.component.css.map +1 -1
- package/assets/css/components/card.module.css.map +1 -1
- package/assets/css/components/carousel.component.css +1 -1
- package/assets/css/components/carousel.component.css.map +1 -1
- package/assets/css/components/carousel.config.css.map +1 -1
- package/assets/css/components/charts.config.css.map +1 -1
- package/assets/css/components/charts.css +1 -1
- package/assets/css/components/charts.css.map +1 -1
- package/assets/css/components/charts.module.css +1 -1
- package/assets/css/components/charts.module.css.map +1 -1
- package/assets/css/components/collapsible-side.css.map +1 -1
- package/assets/css/components/fileupload.css.map +1 -1
- package/assets/css/components/filter-card.component.css.map +1 -1
- package/assets/css/components/header.css.map +1 -1
- package/assets/css/components/inline-edit.css.map +1 -1
- package/assets/css/components/inline-edit.preload.css.map +1 -1
- package/assets/css/components/marketing.css.map +1 -1
- package/assets/css/components/multi-step.component.css.map +1 -1
- package/assets/css/components/multiselect.css +1 -1
- package/assets/css/components/multiselect.css.map +1 -1
- package/assets/css/components/multiselect.preload.css.map +1 -1
- package/assets/css/components/nav.css +1 -1
- package/assets/css/components/nav.css.map +1 -1
- package/assets/css/components/nav.docs.css.map +1 -1
- package/assets/css/components/nav.global.css +1 -1
- package/assets/css/components/nav.global.css.map +1 -1
- package/assets/css/components/nav.old.css +1 -1
- package/assets/css/components/nav.old.css.map +1 -1
- package/assets/css/components/nav.preload.css.map +1 -1
- package/assets/css/components/notification.css.map +1 -1
- package/assets/css/components/notification.global.css.map +1 -1
- package/assets/css/components/pagination.css.map +1 -1
- package/assets/css/components/property-searchbar.css +1 -1
- package/assets/css/components/property-searchbar.css.map +1 -1
- package/assets/css/components/record-card.component.css.map +1 -1
- package/assets/css/components/slider.css.map +1 -1
- package/assets/css/components/snapshot.css.map +1 -1
- package/assets/css/components/stepper.css.map +1 -1
- package/assets/css/components/table.css +1 -1
- package/assets/css/components/table.css.map +1 -1
- package/assets/css/components/table.global.css +1 -1
- package/assets/css/components/table.global.css.map +1 -1
- package/assets/css/components/tabs.css.map +1 -1
- package/assets/css/components/testimonial.css.map +1 -1
- package/assets/css/components/timeline.css +1 -1
- package/assets/css/components/timeline.css.map +1 -1
- package/assets/css/components/video-card.component.css.map +1 -1
- package/assets/css/core.min.css +1 -1
- package/assets/css/core.min.css.map +1 -1
- package/assets/css/style.min.css +1 -1
- package/assets/css/style.min.css.map +1 -1
- package/assets/js/components/_global.js +8 -8
- package/assets/js/components/accordion/accordion.component.js +13 -10
- package/assets/js/components/accordion/accordion.component.min.js +4 -4
- package/assets/js/components/accordion/accordion.component.min.js.map +1 -1
- package/assets/js/components/actionbar/actionbar.component.js +97 -83
- package/assets/js/components/actionbar/actionbar.component.min.js +5 -5
- package/assets/js/components/actionbar/actionbar.component.min.js.map +1 -1
- package/assets/js/components/address-lookup/address-lookup.component.js +30 -26
- package/assets/js/components/address-lookup/address-lookup.component.min.js +4 -4
- package/assets/js/components/address-lookup/address-lookup.component.min.js.map +1 -1
- package/assets/js/components/applied-filters/applied-filters.component.js +10 -6
- package/assets/js/components/applied-filters/applied-filters.component.min.js +3 -3
- package/assets/js/components/applied-filters/applied-filters.component.min.js.map +1 -1
- package/assets/js/components/barchart/barchart.component.js +8 -7
- package/assets/js/components/barchart/barchart.component.min.js +4 -4
- package/assets/js/components/barchart/barchart.component.min.js.map +1 -1
- package/assets/js/components/card/card.component.js +27 -12
- package/assets/js/components/card/card.component.min.js +3 -3
- package/assets/js/components/card/card.component.min.js.map +1 -1
- package/assets/js/components/carousel/carousel.component.js +18 -12
- package/assets/js/components/carousel/carousel.component.min.js +4 -4
- package/assets/js/components/carousel/carousel.component.min.js.map +1 -1
- package/assets/js/components/chart/chart.component.js +9 -8
- package/assets/js/components/collapsible-side/collapsible-side.component.js +20 -8
- package/assets/js/components/collapsible-side/collapsible-side.component.min.js +1 -1
- package/assets/js/components/collapsible-side/collapsible-side.component.min.js.map +1 -1
- package/assets/js/components/fileupload/fileupload.component.js +11 -7
- package/assets/js/components/fileupload/fileupload.component.min.js +2 -2
- package/assets/js/components/fileupload/fileupload.component.min.js.map +1 -1
- package/assets/js/components/filter-card/filter-card.component.js +19 -9
- package/assets/js/components/filter-card/filter-card.component.min.js +2 -2
- package/assets/js/components/filter-card/filter-card.component.min.js.map +1 -1
- package/assets/js/components/filterlist/filterlist.component.js +10 -6
- package/assets/js/components/filterlist/filterlist.component.min.js +3 -3
- package/assets/js/components/filterlist/filterlist.component.min.js.map +1 -1
- package/assets/js/components/header/header.component.js +8 -4
- package/assets/js/components/header/header.component.min.js +1 -1
- package/assets/js/components/header/header.component.min.js.map +1 -1
- package/assets/js/components/inline-edit/inline-edit.component.js +43 -23
- package/assets/js/components/inline-edit/inline-edit.component.min.js +4 -4
- package/assets/js/components/inline-edit/inline-edit.component.min.js.map +1 -1
- package/assets/js/components/marketing/marketing.component.js +11 -5
- package/assets/js/components/marketing/marketing.component.min.js +1 -1
- package/assets/js/components/marketing/marketing.component.min.js.map +1 -1
- package/assets/js/components/multi-step/multi-step.component.js +22 -19
- package/assets/js/components/multiselect/multiselect.component.js +62 -45
- package/assets/js/components/multiselect/multiselect.component.min.js +5 -5
- package/assets/js/components/multiselect/multiselect.component.min.js.map +1 -1
- package/assets/js/components/nav/nav.component.js +57 -38
- package/assets/js/components/nav/nav.component.min.js +5 -5
- package/assets/js/components/nav/nav.component.min.js.map +1 -1
- package/assets/js/components/notification/notification.component.js +9 -5
- package/assets/js/components/notification/notification.component.min.js +5 -5
- package/assets/js/components/notification/notification.component.min.js.map +1 -1
- package/assets/js/components/pagination/pagination.component.js +18 -14
- package/assets/js/components/pagination/pagination.component.min.js +2 -2
- package/assets/js/components/pagination/pagination.component.min.js.map +1 -1
- package/assets/js/components/record-card/record-card.component.js +10 -8
- package/assets/js/components/record-card/record-card.component.min.js +2 -2
- package/assets/js/components/record-card/record-card.component.min.js.map +1 -1
- package/assets/js/components/search/search.component.js +22 -17
- package/assets/js/components/search/search.component.min.js +4 -4
- package/assets/js/components/search/search.component.min.js.map +1 -1
- package/assets/js/components/slider/slider.component.js +25 -21
- package/assets/js/components/slider/slider.component.min.js +3 -3
- package/assets/js/components/slider/slider.component.min.js.map +1 -1
- package/assets/js/components/table/table.component.js +30 -24
- package/assets/js/components/table/table.component.min.js +7 -7
- package/assets/js/components/table/table.component.min.js.map +1 -1
- package/assets/js/components/tabs/tabs.component.js +10 -6
- package/assets/js/components/tabs/tabs.component.min.js +3 -3
- package/assets/js/components/tabs/tabs.component.min.js.map +1 -1
- package/assets/js/components/video-card/video-card.component.js +45 -33
- package/assets/js/components/video-card/video-card.component.min.js +3 -3
- package/assets/js/components/video-card/video-card.component.min.js.map +1 -1
- package/assets/js/components.bundle.js +1 -1
- package/assets/js/components.bundle.js.map +1 -1
- package/assets/js/components.js +35 -8
- package/assets/js/modules/applied-filters.js +20 -20
- package/assets/js/modules/carousel.js +65 -60
- package/assets/js/modules/chart.js +184 -134
- package/assets/js/modules/chart.module.js +74 -63
- package/assets/js/modules/data-layer.js +17 -17
- package/assets/js/modules/dialogs.js +47 -38
- package/assets/js/modules/drawer.js +1 -1
- package/assets/js/modules/dynamicEvents.js +24 -24
- package/assets/js/modules/file-upload.js +8 -9
- package/assets/js/modules/fileupload.js +5 -5
- package/assets/js/modules/filterlist.js +4 -4
- package/assets/js/modules/form.js +22 -18
- package/assets/js/modules/helpers.js +54 -44
- package/assets/js/modules/inputs.js +25 -21
- package/assets/js/modules/nav.js +3 -1
- package/assets/js/modules/notification.js +6 -6
- package/assets/js/modules/orderablelist.js +12 -12
- package/assets/js/modules/pagination.js +5 -5
- package/assets/js/modules/table.js +242 -181
- package/assets/js/modules/tabs.js +71 -60
- package/assets/js/modules/testimonial.js +11 -12
- package/assets/js/scripts.bundle.js +1 -1
- package/assets/js/scripts.bundle.js.map +1 -1
- package/assets/js/scripts.bundle.min.js +1 -1
- package/assets/js/scripts.bundle.min.js.map +1 -1
- package/assets/js/scripts.js +1 -1
- package/assets/js/tests/chart.spec.js +5 -5
- package/assets/js/tests/filterlist.spec.js +2 -2
- package/assets/js/tests/slider.spec.js +2 -2
- package/assets/js/tests/table.spec.js +2 -2
- package/assets/js/vendor/hibp.js +4 -4
- package/assets/sass/_components.scss +28 -40
- package/assets/sass/_corefiles.scss +22 -29
- package/assets/sass/_elements.scss +19 -19
- package/assets/sass/_fonts.scss +10 -7
- package/assets/sass/_func.scss +14 -14
- package/assets/sass/_functions/functions.scss +115 -90
- package/assets/sass/_functions/mixins.scss +72 -112
- package/assets/sass/_functions/utilities.scss +447 -393
- package/assets/sass/_functions/variables.scss +1357 -1371
- package/assets/sass/_print.scss +18 -16
- package/assets/sass/_tests/colours.spec.scss +15 -14
- package/assets/sass/_tests/func.spec.scss +1 -2
- package/assets/sass/_tests/mixins.spec.scss +9 -14
- package/assets/sass/_tests/typography.spec.scss +1 -2
- package/assets/sass/_utilities.scss +8 -12
- package/assets/sass/components/actionbar.global.scss +45 -64
- package/assets/sass/components/actionbar.scss +58 -84
- package/assets/sass/components/address-lookup.scss +9 -11
- package/assets/sass/components/applied-filters.scss +3 -7
- package/assets/sass/components/barchart.component.scss +68 -99
- package/assets/sass/components/card.component.scss +35 -50
- package/assets/sass/components/card.module.scss +34 -37
- package/assets/sass/components/carousel.component.scss +198 -177
- package/assets/sass/components/carousel.config.scss +13 -19
- package/assets/sass/components/charts.config.scss +16 -23
- package/assets/sass/components/charts.module.scss +139 -178
- package/assets/sass/components/charts.scss +173 -232
- package/assets/sass/components/collapsible-side.scss +65 -98
- package/assets/sass/components/fileupload.scss +17 -23
- package/assets/sass/components/filter-card.component.scss +21 -28
- package/assets/sass/components/header.scss +24 -37
- package/assets/sass/components/inline-edit.preload.scss +24 -45
- package/assets/sass/components/inline-edit.scss +4 -5
- package/assets/sass/components/marketing.scss +19 -14
- package/assets/sass/components/multi-step.component.scss +36 -42
- package/assets/sass/components/multiselect.preload.scss +9 -12
- package/assets/sass/components/multiselect.scss +20 -24
- package/assets/sass/components/nav.docs.scss +7 -15
- package/assets/sass/components/nav.global.scss +123 -177
- package/assets/sass/components/nav.old.scss +64 -135
- package/assets/sass/components/nav.preload.scss +11 -12
- package/assets/sass/components/nav.scss +126 -173
- package/assets/sass/components/notification.global.scss +2 -3
- package/assets/sass/components/notification.scss +17 -32
- package/assets/sass/components/pagination.scss +32 -44
- package/assets/sass/components/property-searchbar.scss +2 -6
- package/assets/sass/components/record-card.component.scss +42 -55
- package/assets/sass/components/slider.scss +38 -35
- package/assets/sass/components/snapshot.scss +4 -10
- package/assets/sass/components/stepper.scss +14 -22
- package/assets/sass/components/table.global.scss +130 -171
- package/assets/sass/components/table.scss +17 -27
- package/assets/sass/components/tabs.scss +23 -32
- package/assets/sass/components/testimonial.scss +6 -14
- package/assets/sass/components/timeline.scss +8 -12
- package/assets/sass/components/video-card.component.scss +9 -14
- package/assets/sass/components.reset.scss +5 -5
- package/assets/sass/core.scss +3 -3
- package/assets/sass/elements/admin-panel.scss +41 -45
- package/assets/sass/elements/badge-tag.scss +16 -26
- package/assets/sass/elements/brand.scss +13 -16
- package/assets/sass/elements/buttons.scss +80 -106
- package/assets/sass/elements/container.scss +24 -133
- package/assets/sass/elements/details.scss +30 -50
- package/assets/sass/elements/dialog.scss +4 -6
- package/assets/sass/elements/forms.scss +421 -437
- package/assets/sass/elements/icons.scss +3 -4
- package/assets/sass/elements/links.scss +17 -25
- package/assets/sass/elements/lists.scss +30 -47
- package/assets/sass/elements/media.scss +1 -4
- package/assets/sass/elements/modal.scss +54 -80
- package/assets/sass/elements/popover.scss +28 -45
- package/assets/sass/elements/progress.scss +30 -40
- package/assets/sass/elements/table.element.scss +10 -15
- package/assets/sass/elements/tooltips.scss +27 -49
- package/assets/sass/elements/type.scss +47 -53
- package/assets/sass/email.scss +7 -9
- package/assets/sass/error.scss +23 -20
- package/assets/sass/foundations/bs_grid.scss +0 -1
- package/assets/sass/foundations/grid.scss +120 -122
- package/assets/sass/foundations/reboot.scss +27 -35
- package/assets/sass/foundations/root.scss +21 -31
- package/assets/sass/helpers/dynamic.scss +5 -5
- package/assets/sass/helpers/line-clamp.scss +1 -2
- package/assets/sass/helpers/max-height.scss +28 -36
- package/assets/sass/helpers/wider-colours.scss +2 -5
- package/assets/sass/main.scss +4 -4
- package/assets/sass/templates/auth.scss +11 -18
- package/assets/sass/templates/form.scss +16 -29
- package/assets/ts/components/_global.ts +14 -17
- package/assets/ts/components/accordion/accordion.component.ts +23 -19
- package/assets/ts/components/actionbar/README.md +8 -7
- package/assets/ts/components/actionbar/actionbar.component.ts +170 -220
- package/assets/ts/components/address-lookup/address-lookup.component.ts +94 -130
- package/assets/ts/components/applied-filters/README.md +1 -1
- package/assets/ts/components/applied-filters/applied-filters.component.ts +16 -15
- package/assets/ts/components/barchart/barchart.component.ts +29 -26
- package/assets/ts/components/card/card.component.ts +56 -57
- package/assets/ts/components/carousel/README.md +8 -9
- package/assets/ts/components/carousel/carousel.component.ts +30 -33
- package/assets/ts/components/chart/README.md +1 -3
- package/assets/ts/components/chart/chart.component.ts +24 -36
- package/assets/ts/components/collapsible-side/README.md +1 -1
- package/assets/ts/components/collapsible-side/collapsible-side.component.ts +44 -57
- package/assets/ts/components/fileupload/README.md +3 -3
- package/assets/ts/components/fileupload/fileupload.component.ts +23 -28
- package/assets/ts/components/filter-card/filter-card.component.ts +32 -33
- package/assets/ts/components/filterlist/README.md +3 -3
- package/assets/ts/components/filterlist/filterlist.component.ts +18 -16
- package/assets/ts/components/header/README.md +8 -9
- package/assets/ts/components/header/header.component.ts +15 -16
- package/assets/ts/components/inline-edit/README.md +1 -0
- package/assets/ts/components/inline-edit/inline-edit.component.ts +71 -71
- package/assets/ts/components/marketing/marketing.component.ts +17 -16
- package/assets/ts/components/multi-step/multi-step.component.ts +114 -156
- package/assets/ts/components/multiselect/README.md +5 -5
- package/assets/ts/components/multiselect/multiselect.component.ts +116 -133
- package/assets/ts/components/nav/README.md +13 -13
- package/assets/ts/components/nav/nav.component.ts +171 -167
- package/assets/ts/components/notification/README.md +9 -9
- package/assets/ts/components/notification/notification.component.ts +33 -32
- package/assets/ts/components/pagination/README.md +12 -12
- package/assets/ts/components/pagination/pagination.component.ts +51 -69
- package/assets/ts/components/record-card/record-card.component.ts +24 -34
- package/assets/ts/components/search/README.md +6 -7
- package/assets/ts/components/search/search.component.ts +75 -91
- package/assets/ts/components/slider/slider.component.ts +62 -77
- package/assets/ts/components/table/README.md +8 -8
- package/assets/ts/components/table/table.component.ts +97 -134
- package/assets/ts/components/tabs/README.md +4 -4
- package/assets/ts/components/tabs/tabs.component.ts +16 -14
- package/assets/ts/components/video-card/video-card.component.ts +89 -93
- package/assets/ts/components.ts +44 -20
- package/assets/ts/html.d.ts +1 -7
- package/assets/ts/modules/applied-filters.ts +104 -135
- package/assets/ts/modules/card.module.ts +13 -18
- package/assets/ts/modules/carousel.ts +194 -195
- package/assets/ts/modules/chart.module.ts +201 -246
- package/assets/ts/modules/chart.ts +454 -472
- package/assets/ts/modules/data-layer.md +35 -31
- package/assets/ts/modules/data-layer.ts +18 -18
- package/assets/ts/modules/dialogs.ts +113 -117
- package/assets/ts/modules/drawer.ts +7 -9
- package/assets/ts/modules/dynamicEvents.ts +67 -100
- package/assets/ts/modules/file-upload.ts +43 -40
- package/assets/ts/modules/fileupload.ts +38 -60
- package/assets/ts/modules/filterlist.ts +14 -20
- package/assets/ts/modules/form.ts +126 -128
- package/assets/ts/modules/helpers.ts +114 -120
- package/assets/ts/modules/inputs.ts +88 -120
- package/assets/ts/modules/nav.ts +19 -18
- package/assets/ts/modules/notification.ts +28 -32
- package/assets/ts/modules/orderablelist.ts +90 -82
- package/assets/ts/modules/pagination.ts +14 -19
- package/assets/ts/modules/table.ts +516 -599
- package/assets/ts/modules/tabs.ts +120 -145
- package/assets/ts/modules/testimonial.ts +59 -64
- package/assets/ts/scripts.ts +7 -9
- package/assets/ts/tests/chart.spec.ts +11 -20
- package/assets/ts/tests/data-layer.spec.js +3 -4
- package/assets/ts/tests/filterlist.spec.ts +3 -6
- package/assets/ts/tests/slider.spec.ts +9 -15
- package/assets/ts/tests/table.spec.ts +7 -24
- package/assets/ts/vendor/hibp.ts +43 -43
- package/dist/components.es.js +280 -270
- package/dist/components.umd.js +67 -67
- package/dist/style.css +1 -1
- package/package.json +14 -4
- package/src/components/Accordion/Accordion.spec.js +25 -31
- package/src/components/Accordion/Accordion.vue +16 -19
- package/src/components/Accordion/AccordionItem.vue +39 -37
- package/src/components/Accordion/README.md +10 -12
- package/src/components/Actionbar/Actionbar.vue +15 -18
- package/src/components/Actionbar/README.md +8 -7
- package/src/components/AddressLookup/AddressLookup.vue +14 -16
- package/src/components/AppliedFilters/AppliedFilters.vue +14 -16
- package/src/components/Banner/Banner.spec.js +13 -15
- package/src/components/Banner/Banner.vue +19 -19
- package/src/components/Banner/README.md +8 -10
- package/src/components/BarChart/BarChart.vue +14 -16
- package/src/components/Card/Card.vue +13 -16
- package/src/components/Card/README.md +8 -8
- package/src/components/Carousel/Carousel.vue +15 -18
- package/src/components/Carousel/README.md +7 -7
- package/src/components/Chart/Chart.spec.js +64 -87
- package/src/components/Chart/Chart.vue +41 -40
- package/src/components/Chart/README.md +8 -9
- package/src/components/CollapsibleSideMenu/CollapsibleSideMenu.vue +8 -10
- package/src/components/CollapsibleSideMenu/README.md +1 -1
- package/src/components/FileUpload/FileUpload.vue +35 -40
- package/src/components/FileUpload/README.md +3 -3
- package/src/components/FilterCard/FilterCard.vue +14 -16
- package/src/components/Filterlist/Filterlist.vue +7 -9
- package/src/components/Filterlist/README.md +3 -3
- package/src/components/Header/Header.vue +23 -26
- package/src/components/Header/README.md +8 -9
- package/src/components/InlineEdit/InlineEdit.vue +26 -32
- package/src/components/Input/Input.vue +323 -233
- package/src/components/Input/README.md +11 -11
- package/src/components/Marketing/Marketing.vue +24 -27
- package/src/components/Marketing/README.md +7 -7
- package/src/components/MultiStep/MultiStep.vue +13 -15
- package/src/components/Multiselect/Multiselect.vue +14 -17
- package/src/components/Nav/Nav.vue +15 -29
- package/src/components/Nav/README.md +12 -12
- package/src/components/Nav-old/Nav.vue +88 -93
- package/src/components/Nav-old/README.md +11 -12
- package/src/components/NoteFeed/NoteFeed.vue +59 -56
- package/src/components/NoteFeed/README.md +6 -6
- package/src/components/Notification/Notification.vue +11 -15
- package/src/components/Notification/README.md +9 -9
- package/src/components/Pagination/Pagination.vue +14 -24
- package/src/components/Pagination/README.md +12 -12
- package/src/components/PropertySearchbar/PropertySearchbar.vue +191 -160
- package/src/components/PropertySearchbar/README.md +14 -15
- package/src/components/RecordCard/RecordCard.vue +14 -16
- package/src/components/Search/README.md +1 -1
- package/src/components/Search/Search.vue +13 -16
- package/src/components/Slider/Slider.vue +13 -16
- package/src/components/Snapshot/README.md +9 -10
- package/src/components/Snapshot/Snapshot.vue +15 -17
- package/src/components/Stepper/README.md +12 -13
- package/src/components/Stepper/Step.vue +22 -18
- package/src/components/Stepper/Stepper.spec.js +41 -46
- package/src/components/Stepper/Stepper.vue +17 -18
- package/src/components/Table/README.md +12 -11
- package/src/components/Table/Table.spec.js +17 -28
- package/src/components/Table/Table.vue +49 -48
- package/src/components/Tabs/README.md +8 -8
- package/src/components/Tabs/Tab.vue +21 -21
- package/src/components/Tabs/Tabs.vue +14 -17
- package/src/components/Testimonial/README.md +11 -12
- package/src/components/Testimonial/Testimonial.spec.js +22 -26
- package/src/components/Testimonial/Testimonial.vue +31 -25
- package/src/components/Timeline/README.md +3 -3
- package/src/components/Timeline/Timeline.spec.js +9 -11
- package/src/components/Timeline/Timeline.vue +10 -10
- package/src/components/VideoCard/VideoCard.vue +14 -16
- package/src/foundations/Logo/Logo.spec.js +30 -30
- package/src/foundations/Logo/Logo.vue +28 -28
- package/src/foundations/Logo/README.md +5 -4
- package/src/helpers/strings.js +11 -8
- package/src/index.js +27 -28
- package/src/vue-shim.d.ts +4 -4
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { ucfirst, unsnake, numberOfDays } from './helpers'
|
|
2
|
-
|
|
3
|
-
// #region Functions that setup and trigger other functions
|
|
4
|
-
export const setupChart = (chartElement:any,chartOuter:any,tableElement:any) => {
|
|
1
|
+
import { ucfirst, unsnake, numberOfDays } from './helpers';
|
|
5
2
|
|
|
3
|
+
// #region Functions that setup and trigger other functions
|
|
4
|
+
export const setupChart = (chartElement: any, chartOuter: any, tableElement: any) => {
|
|
6
5
|
// #region Reset the chart
|
|
7
6
|
// empty divs to re-populate
|
|
8
7
|
const chartOptions = chartOuter.querySelector('.chart__options');
|
|
@@ -15,65 +14,66 @@ export const setupChart = (chartElement:any,chartOuter:any,tableElement:any) =>
|
|
|
15
14
|
chartYaxis.innerHTML = ``;
|
|
16
15
|
|
|
17
16
|
// Remove old input fields
|
|
18
|
-
Array.from(chartOuter.querySelectorAll(':scope > input[type="checkbox"],:scope > input[type="radio"]')).map(
|
|
17
|
+
Array.from(chartOuter.querySelectorAll(':scope > input[type="checkbox"],:scope > input[type="radio"]')).map(
|
|
18
|
+
(element: any) => {
|
|
19
|
+
element.remove();
|
|
20
|
+
}
|
|
21
|
+
);
|
|
19
22
|
// #endregion
|
|
20
23
|
|
|
21
|
-
createTypeSwitcher(chartElement,chartKey,chartOptions);
|
|
24
|
+
createTypeSwitcher(chartElement, chartKey, chartOptions);
|
|
22
25
|
|
|
23
|
-
|
|
26
|
+
const { xaxis, type } = getChartData(chartElement, chartOuter);
|
|
24
27
|
|
|
25
|
-
setCellData(chartElement,chartOuter,tableElement);
|
|
28
|
+
setCellData(chartElement, chartOuter, tableElement);
|
|
26
29
|
|
|
27
|
-
createChartKey(chartOuter,tableElement,chartKey);
|
|
28
|
-
createChartGuidelines(chartElement,chartOuter,chartGuidelines);
|
|
29
|
-
createChartYaxis(chartElement,chartOuter,chartYaxis);
|
|
30
|
+
createChartKey(chartOuter, tableElement, chartKey);
|
|
31
|
+
createChartGuidelines(chartElement, chartOuter, chartGuidelines);
|
|
32
|
+
createChartYaxis(chartElement, chartOuter, chartYaxis);
|
|
30
33
|
|
|
31
|
-
const availableTypes = chartElement.hasAttribute('data-types')
|
|
34
|
+
const availableTypes = chartElement.hasAttribute('data-types')
|
|
35
|
+
? chartElement.getAttribute('data-types').split(',')
|
|
36
|
+
: [type];
|
|
32
37
|
|
|
33
|
-
if(availableTypes.includes('line')){
|
|
34
|
-
createLines(chartElement,chartOuter);
|
|
38
|
+
if (availableTypes.includes('line')) {
|
|
39
|
+
createLines(chartElement, chartOuter);
|
|
35
40
|
}
|
|
36
41
|
|
|
37
|
-
if(availableTypes.includes('pie'))
|
|
38
|
-
createPies(chartOuter);
|
|
42
|
+
if (availableTypes.includes('pie')) createPies(chartOuter);
|
|
39
43
|
|
|
40
|
-
if(xaxis){
|
|
41
|
-
createXaxis(chartElement,chartOuter,xaxis);
|
|
44
|
+
if (xaxis) {
|
|
45
|
+
createXaxis(chartElement, chartOuter, xaxis);
|
|
42
46
|
}
|
|
43
47
|
|
|
44
|
-
if(chartElement.hasAttribute('data-slope'))
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if(chartElement.classList.contains('chart--show-totals'))
|
|
49
|
-
createKeyTotals(chartElement,chartOuter);
|
|
48
|
+
if (chartElement.hasAttribute('data-slope'))
|
|
49
|
+
// Need to check attribute is there not its value
|
|
50
|
+
createSlope(chartElement, chartOuter);
|
|
50
51
|
|
|
52
|
+
if (chartElement.classList.contains('chart--show-totals')) createKeyTotals(chartElement, chartOuter);
|
|
51
53
|
|
|
52
|
-
if(availableTypes.includes('bar') || availableTypes.includes('dumbbell') || availableTypes.includes('responsive'))
|
|
54
|
+
if (availableTypes.includes('bar') || availableTypes.includes('dumbbell') || availableTypes.includes('responsive'))
|
|
53
55
|
setLongestLabel(chartOuter);
|
|
54
56
|
|
|
55
|
-
|
|
56
57
|
// Event handlers
|
|
57
|
-
setEventHandlers(chartElement,chartOuter);
|
|
58
|
+
setEventHandlers(chartElement, chartOuter);
|
|
58
59
|
|
|
59
60
|
return true;
|
|
60
61
|
};
|
|
61
62
|
// #endregion
|
|
62
63
|
|
|
63
64
|
// #region Event handlers and observers
|
|
64
|
-
export const setEventHandlers = function(chartElement:any,chartOuter:any) {
|
|
65
|
+
export const setEventHandlers = function (chartElement: any, chartOuter: any) {
|
|
65
66
|
const showData = chartOuter.querySelectorAll(':scope > input[type="checkbox"]');
|
|
66
67
|
|
|
68
|
+
const { type } = getChartData(chartElement, chartOuter);
|
|
67
69
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
const availableTypes = chartElement.hasAttribute('data-types')
|
|
71
|
+
? chartElement.getAttribute('data-types').split(',')
|
|
72
|
+
: [type];
|
|
71
73
|
|
|
72
|
-
for (
|
|
73
|
-
showData[i].addEventListener('change', function() {
|
|
74
|
-
|
|
75
|
-
if(availableTypes.includes('pie'))
|
|
76
|
-
createPies(chartOuter);
|
|
74
|
+
for (let i = 0; i < showData.length; i++) {
|
|
75
|
+
showData[i].addEventListener('change', function () {
|
|
76
|
+
if (availableTypes.includes('pie')) createPies(chartOuter);
|
|
77
77
|
|
|
78
78
|
//setupOptionalContent(chartElement,min,max); // TODO: move this to the observer and just update the data attribute
|
|
79
79
|
});
|
|
@@ -89,25 +89,24 @@ export const setEventHandlers = function(chartElement:any,chartOuter:any) {
|
|
|
89
89
|
*/
|
|
90
90
|
};
|
|
91
91
|
|
|
92
|
-
export const setEventObservers = function(chartElement:any,chartOuter:any) {
|
|
93
|
-
|
|
94
|
-
if(chartElement.hasAttribute('data-series'))
|
|
95
|
-
return false;
|
|
92
|
+
export const setEventObservers = function (chartElement: any, chartOuter: any) {
|
|
93
|
+
if (chartElement.hasAttribute('data-series')) return false;
|
|
96
94
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const attributesUpdated = (mutationList:any, observer:any) => {
|
|
95
|
+
const table = chartElement.querySelector('table');
|
|
96
|
+
const newTable = chartOuter.querySelector('table');
|
|
101
97
|
|
|
98
|
+
const attributesUpdated = (mutationList: any, observer: any) => {
|
|
102
99
|
observer.disconnect();
|
|
103
100
|
observer2.disconnect();
|
|
104
101
|
|
|
105
102
|
for (const mutation of mutationList) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
103
|
+
if (
|
|
104
|
+
mutation.attributeName == 'class' ||
|
|
105
|
+
(mutation.type === 'attributes' && mutation.attributeName === 'data-total') ||
|
|
106
|
+
mutation.type === 'attributes'
|
|
107
|
+
) {
|
|
109
108
|
newTable.innerHTML = table.innerHTML;
|
|
110
|
-
setupChart(chartElement,chartOuter,newTable);
|
|
109
|
+
setupChart(chartElement, chartOuter, newTable);
|
|
111
110
|
}
|
|
112
111
|
}
|
|
113
112
|
|
|
@@ -115,17 +114,14 @@ export const setEventObservers = function(chartElement:any,chartOuter:any) {
|
|
|
115
114
|
observer2.observe(chartElement, { attributes: true });
|
|
116
115
|
};
|
|
117
116
|
|
|
118
|
-
const tableUpdated = (mutationList:any, observer:any) => {
|
|
119
|
-
|
|
117
|
+
const tableUpdated = (mutationList: any, observer: any) => {
|
|
120
118
|
observer.disconnect();
|
|
121
119
|
observer2.disconnect();
|
|
122
120
|
|
|
123
121
|
for (const mutation of mutationList) {
|
|
124
|
-
|
|
125
|
-
if(mutation.type == "characterData" || (mutation.type == "childList" && mutation.addedNodes.length)){
|
|
126
|
-
|
|
122
|
+
if (mutation.type == 'characterData' || (mutation.type == 'childList' && mutation.addedNodes.length)) {
|
|
127
123
|
newTable.innerHTML = table.innerHTML;
|
|
128
|
-
setupChart(chartElement,chartOuter,newTable);
|
|
124
|
+
setupChart(chartElement, chartOuter, newTable);
|
|
129
125
|
}
|
|
130
126
|
}
|
|
131
127
|
|
|
@@ -133,9 +129,8 @@ export const setEventObservers = function(chartElement:any,chartOuter:any) {
|
|
|
133
129
|
observer2.observe(chartElement, { attributes: true });
|
|
134
130
|
};
|
|
135
131
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
let observer2 = new MutationObserver(attributesUpdated);
|
|
132
|
+
const observer = new MutationObserver(tableUpdated);
|
|
133
|
+
const observer2 = new MutationObserver(attributesUpdated);
|
|
139
134
|
|
|
140
135
|
observer.observe(table, { characterData: true, subtree: true });
|
|
141
136
|
observer2.observe(chartElement, { attributes: true });
|
|
@@ -145,284 +140,288 @@ export const setEventObservers = function(chartElement:any,chartOuter:any) {
|
|
|
145
140
|
// #endregion
|
|
146
141
|
|
|
147
142
|
// #region GET functions
|
|
148
|
-
export const getChartData = function(chartElement:any,chartOuter:any){
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
143
|
+
export const getChartData = function (chartElement: any, chartOuter: any) {
|
|
144
|
+
const table = chartOuter.querySelector('.chart__wrapper table');
|
|
145
|
+
|
|
146
|
+
const min: any = chartElement.hasAttribute('data-min') ? chartElement.getAttribute('data-min') : 0;
|
|
147
|
+
const max: any = chartElement.hasAttribute('data-max')
|
|
148
|
+
? chartElement.getAttribute('data-max')
|
|
149
|
+
: getLargestValue(table);
|
|
150
|
+
const type: string = chartElement.hasAttribute('data-type') ? chartElement.getAttribute('data-type') : 'column';
|
|
151
|
+
const yaxis: any = chartElement.hasAttribute('data-yaxis') ? chartElement.getAttribute('data-yaxis').split(',') : [];
|
|
152
|
+
const guidelines: any = chartElement.hasAttribute('data-guidelines')
|
|
153
|
+
? chartElement.getAttribute('data-guidelines').split(',')
|
|
154
|
+
: [];
|
|
155
|
+
const targets: any = chartElement.hasAttribute('data-targets')
|
|
156
|
+
? JSON.parse(chartElement.getAttribute('data-targets'))
|
|
157
|
+
: null;
|
|
158
|
+
const events: any = chartElement.hasAttribute('data-events')
|
|
159
|
+
? JSON.parse(chartElement.getAttribute('data-events'))
|
|
160
|
+
: null;
|
|
161
|
+
const xaxis: any = chartElement.hasAttribute('data-xaxis')
|
|
162
|
+
? chartElement.getAttribute('data-xaxis').split(',')
|
|
163
|
+
: null;
|
|
164
|
+
const increment = chartElement.hasAttribute('data-increment') ? chartElement.getAttribute('data-increment') : null;
|
|
165
|
+
|
|
166
|
+
const start: any = chartElement.hasAttribute('data-start') ? chartElement.getAttribute('data-start') : 0;
|
|
167
|
+
const end: any = chartElement.hasAttribute('data-end')
|
|
168
|
+
? chartElement.getAttribute('data-end')
|
|
169
|
+
: getLargestValue(table); // TODO - get largest value from the data-xaxis
|
|
170
|
+
|
|
171
|
+
const slope: any = chartElement.hasAttribute('data-slope') ? chartElement.getAttribute('data-slope') : null;
|
|
172
|
+
const yInt: any = chartElement.hasAttribute('data-yint') ? chartElement.getAttribute('data-yint') : null;
|
|
173
|
+
|
|
174
|
+
return {
|
|
175
|
+
min,
|
|
176
|
+
max,
|
|
177
|
+
type,
|
|
178
|
+
yaxis,
|
|
179
|
+
targets,
|
|
180
|
+
events,
|
|
181
|
+
xaxis,
|
|
182
|
+
increment,
|
|
183
|
+
start,
|
|
184
|
+
end,
|
|
185
|
+
slope,
|
|
186
|
+
yInt,
|
|
187
|
+
guidelines,
|
|
188
|
+
};
|
|
189
|
+
};
|
|
176
190
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
currentValue =
|
|
180
|
-
currentValue = currentValue.replace('
|
|
191
|
+
function getLargestValue(table: any) {
|
|
192
|
+
const values = Array.from(table.querySelectorAll('tbody td:not(:first-child)')).map((element: any) => {
|
|
193
|
+
let currentValue: string | number = String(element.textContent);
|
|
194
|
+
currentValue = currentValue.replace('£', '');
|
|
195
|
+
currentValue = currentValue.replace('%', '');
|
|
196
|
+
currentValue = currentValue.replace(',', '');
|
|
181
197
|
currentValue = Number.parseFloat(currentValue);
|
|
182
198
|
|
|
183
199
|
return currentValue;
|
|
184
|
-
})
|
|
200
|
+
});
|
|
185
201
|
|
|
186
|
-
|
|
202
|
+
const largetValue: number = Math.max(...values);
|
|
187
203
|
|
|
188
204
|
// TO DO round to the nearest 10, 100, 1000 and so on
|
|
189
205
|
return Math.ceil(largetValue);
|
|
190
206
|
}
|
|
191
207
|
|
|
192
|
-
const getValues = function(value:number,min:any,max:any,start?:number){
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
cleanValue = cleanValue.replace('
|
|
196
|
-
cleanValue = cleanValue.replace('
|
|
197
|
-
cleanValue = cleanValue.replace(',','');
|
|
208
|
+
const getValues = function (value: number, min: any, max: any, start?: number) {
|
|
209
|
+
let cleanValue: string | number = String(value);
|
|
210
|
+
cleanValue = cleanValue.replace('£', '');
|
|
211
|
+
cleanValue = cleanValue.replace('%', '');
|
|
212
|
+
cleanValue = cleanValue.replace(',', '');
|
|
198
213
|
cleanValue = Number.parseFloat(cleanValue);
|
|
199
214
|
|
|
200
|
-
let percent = ((cleanValue - min)/(max - min)) * 100;
|
|
215
|
+
let percent = ((cleanValue - min) / (max - min)) * 100;
|
|
201
216
|
let axis = percent;
|
|
202
217
|
let bottom = 0;
|
|
203
218
|
|
|
204
|
-
if (start && start != 0){
|
|
205
|
-
bottom = ((start - min)/(max - min)) * 100;
|
|
219
|
+
if (start && start != 0) {
|
|
220
|
+
bottom = ((start - min) / (max - min)) * 100;
|
|
206
221
|
}
|
|
207
222
|
|
|
208
223
|
// If the value is negative the position below the 0 line
|
|
209
|
-
if(min < 0){
|
|
210
|
-
bottom = Math.abs((
|
|
224
|
+
if (min < 0) {
|
|
225
|
+
bottom = Math.abs((min / (max - min)) * 100);
|
|
211
226
|
|
|
212
|
-
if(cleanValue < 0){
|
|
227
|
+
if (cleanValue < 0) {
|
|
213
228
|
percent = bottom - percent;
|
|
214
229
|
bottom = bottom - percent;
|
|
215
230
|
axis = bottom;
|
|
216
|
-
}
|
|
217
|
-
else {
|
|
231
|
+
} else {
|
|
218
232
|
percent = percent - bottom;
|
|
219
233
|
axis = percent + bottom;
|
|
220
234
|
}
|
|
221
235
|
}
|
|
222
236
|
|
|
223
|
-
return { percent, axis, bottom};
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
function getCoordinatesForPercent(percent:number, pieCount:number) {
|
|
237
|
+
return { percent, axis, bottom };
|
|
238
|
+
};
|
|
227
239
|
|
|
240
|
+
function getCoordinatesForPercent(percent: number, pieCount: number) {
|
|
228
241
|
// This moves the start point to the top middle point like a clock
|
|
229
|
-
if(pieCount > 1)
|
|
230
|
-
percent = percent - 0.25;
|
|
242
|
+
if (pieCount > 1) percent = percent - 0.25;
|
|
231
243
|
|
|
232
244
|
const x = Math.cos(2 * Math.PI * percent);
|
|
233
245
|
const y = Math.sin(2 * Math.PI * percent);
|
|
234
|
-
return [x*100, y*100];
|
|
246
|
+
return [x * 100, y * 100];
|
|
235
247
|
}
|
|
236
248
|
|
|
237
249
|
// #endregion
|
|
238
250
|
|
|
239
251
|
// #region SET functions - set data attributes and classes
|
|
240
|
-
export const setCellData = function(chartElement:any,chartOuter:any,table:any){
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
252
|
+
export const setCellData = function (chartElement: any, chartOuter: any, table: any) {
|
|
253
|
+
let { min, max } = getChartData(chartElement, chartOuter);
|
|
254
|
+
|
|
255
|
+
const chartType = chartElement.getAttribute('data-type');
|
|
256
|
+
const increment = chartElement.getAttribute('data-increment');
|
|
257
|
+
const incrementStart = chartElement.getAttribute('data-start');
|
|
258
|
+
const incrementEnd = chartElement.getAttribute('data-end');
|
|
259
|
+
const startDay = min;
|
|
260
|
+
|
|
250
261
|
// Change how gant charts are configured as this just seems bizarre now
|
|
251
|
-
if(increment ==
|
|
252
|
-
|
|
253
|
-
max = numberOfDays(min,max);
|
|
262
|
+
if (increment == 'days') {
|
|
263
|
+
max = numberOfDays(min, max);
|
|
254
264
|
min = 0;
|
|
255
265
|
|
|
256
|
-
chartElement.querySelector('tbody').setAttribute('style'
|
|
266
|
+
chartElement.querySelector('tbody').setAttribute('style', `--single-day:${(1 / max) * 100}%;`);
|
|
257
267
|
}
|
|
258
268
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
let coverageStart:number = 100;
|
|
264
|
-
let coverageEnd:number = 0;
|
|
265
|
-
let cumulativeComparison:number = 0;
|
|
269
|
+
Array.from(table.querySelectorAll('tbody tr')).forEach((tr: any, index) => {
|
|
270
|
+
const group = tr.querySelector('td:first-child, th:first-child')
|
|
271
|
+
? tr.querySelector('td:first-child, th:first-child').innerHTML
|
|
272
|
+
: '';
|
|
273
|
+
let coverageStart: number = 100;
|
|
274
|
+
let coverageEnd: number = 0;
|
|
275
|
+
let cumulativeComparison: number = 0;
|
|
266
276
|
// For waffle charts
|
|
267
|
-
let previousAfter:number = 0;
|
|
268
|
-
let rowPosition:number = 0;
|
|
269
|
-
let totalPercent:number = 0;
|
|
277
|
+
let previousAfter: number = 0;
|
|
278
|
+
let rowPosition: number = 0;
|
|
279
|
+
let totalPercent: number = 0;
|
|
270
280
|
|
|
271
281
|
// Set the data numeric value if not set
|
|
272
|
-
Array.from(tr.querySelectorAll('td:not([data-numeric]):not(:first-child)')).forEach((td:any) => {
|
|
273
|
-
|
|
274
|
-
let value = parseFloat(td.textContent.replace('£','').replace('%','').replace(',',''));
|
|
282
|
+
Array.from(tr.querySelectorAll('td:not([data-numeric]):not(:first-child)')).forEach((td: any) => {
|
|
283
|
+
let value = parseFloat(td.textContent.replace('£', '').replace('%', '').replace(',', ''));
|
|
275
284
|
let start = 0;
|
|
276
|
-
if(increment ==
|
|
277
|
-
|
|
278
|
-
if(dates[1]){
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
start = numberOfDays(startDay,dates[0]) - 1;
|
|
285
|
+
if (increment == 'days') {
|
|
286
|
+
const dates = td.textContent.split(' - ');
|
|
287
|
+
if (dates[1]) {
|
|
288
|
+
value = numberOfDays(dates[0], dates[1]);
|
|
289
|
+
start = numberOfDays(startDay, dates[0]) - 1;
|
|
282
290
|
}
|
|
283
291
|
}
|
|
284
|
-
|
|
285
|
-
td.setAttribute('data-numeric',value);
|
|
286
|
-
td.setAttribute('data-start',start);
|
|
292
|
+
|
|
293
|
+
td.setAttribute('data-numeric', value);
|
|
294
|
+
td.setAttribute('data-start', start);
|
|
287
295
|
});
|
|
288
296
|
|
|
289
297
|
// Set the data label value if not set
|
|
290
|
-
Array.from(tr.querySelectorAll('td:not([data-label])')).forEach((td:any, index) => {
|
|
291
|
-
|
|
292
|
-
td.setAttribute('data-label',table.querySelectorAll('thead th')[index].textContent);
|
|
298
|
+
Array.from(tr.querySelectorAll('td:not([data-label])')).forEach((td: any, index) => {
|
|
299
|
+
td.setAttribute('data-label', table.querySelectorAll('thead th')[index].textContent);
|
|
293
300
|
});
|
|
294
301
|
|
|
295
|
-
if(tr.querySelector('[data-label="Total"]')){
|
|
296
|
-
tr.setAttribute(
|
|
302
|
+
if (tr.querySelector('[data-label="Total"]')) {
|
|
303
|
+
tr.setAttribute(
|
|
304
|
+
'data-total',
|
|
305
|
+
tr.querySelector('[data-label="Total"][data-numeric]').getAttribute('data-numeric')
|
|
306
|
+
);
|
|
297
307
|
}
|
|
298
308
|
|
|
299
|
-
if(tr.querySelector('[data-label="Min"]')){
|
|
300
|
-
tr.setAttribute('data-min',tr.querySelector('[data-label="Min"][data-numeric]').getAttribute('data-numeric'));
|
|
309
|
+
if (tr.querySelector('[data-label="Min"]')) {
|
|
310
|
+
tr.setAttribute('data-min', tr.querySelector('[data-label="Min"][data-numeric]').getAttribute('data-numeric'));
|
|
301
311
|
}
|
|
302
|
-
if(tr.querySelector('[data-label="Max"]')){
|
|
303
|
-
tr.setAttribute('data-max',tr.querySelector('[data-label="Max"][data-numeric]').getAttribute('data-numeric'));
|
|
312
|
+
if (tr.querySelector('[data-label="Max"]')) {
|
|
313
|
+
tr.setAttribute('data-max', tr.querySelector('[data-label="Max"][data-numeric]').getAttribute('data-numeric'));
|
|
304
314
|
}
|
|
305
315
|
|
|
306
|
-
if((chartType ==
|
|
307
|
-
|
|
316
|
+
if ((chartType == 'proportional' || chartType == 'waffle') && !tr.hasAttribute('data-total')) {
|
|
308
317
|
let total = 0;
|
|
309
318
|
|
|
310
|
-
Array.from(tr.querySelectorAll('td[data-numeric]:not(:first-child)')).forEach((td:any) => {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
if(display == 'none')
|
|
314
|
-
return;
|
|
319
|
+
Array.from(tr.querySelectorAll('td[data-numeric]:not(:first-child)')).forEach((td: any) => {
|
|
320
|
+
const display = getComputedStyle(td).display;
|
|
321
|
+
if (display == 'none') return;
|
|
315
322
|
|
|
316
323
|
total += Number.parseFloat(td.getAttribute('data-numeric'));
|
|
317
324
|
});
|
|
318
325
|
|
|
319
|
-
tr.setAttribute('data-total',total);
|
|
326
|
+
tr.setAttribute('data-total', total);
|
|
320
327
|
}
|
|
321
328
|
|
|
322
|
-
|
|
323
|
-
|
|
329
|
+
const rowMin = tr.hasAttribute('data-min') ? tr.getAttribute('data-min') : min;
|
|
330
|
+
const rowMax = tr.hasAttribute('data-max') ? tr.getAttribute('data-max') : max;
|
|
324
331
|
|
|
325
332
|
// Add a useful index css var for the use of animatons.
|
|
326
|
-
tr.setAttribute('style'
|
|
333
|
+
tr.setAttribute('style', `--row-index:${index + 1};`);
|
|
327
334
|
|
|
328
|
-
if(rowMin < 0){
|
|
329
|
-
|
|
330
|
-
chartElement.setAttribute('style'
|
|
335
|
+
if (rowMin < 0) {
|
|
336
|
+
const minBottom = Math.abs((rowMin / (rowMax - rowMin)) * 100);
|
|
337
|
+
chartElement.setAttribute('style', `--min-bottom: ${minBottom}%;`);
|
|
331
338
|
}
|
|
332
339
|
|
|
333
340
|
// Add css vars to cells
|
|
334
|
-
Array.from(
|
|
341
|
+
Array.from(
|
|
342
|
+
tr.querySelectorAll('td[data-numeric]:not([data-label="Min"]):not([data-label="Max"]):not(:first-child)')
|
|
343
|
+
).forEach((td: any) => {
|
|
344
|
+
const display = getComputedStyle(td).display;
|
|
345
|
+
if (display == 'none') return;
|
|
335
346
|
|
|
336
|
-
let display = getComputedStyle(td).display;
|
|
337
|
-
if(display == 'none')
|
|
338
|
-
return;
|
|
339
|
-
|
|
340
347
|
const label = td.getAttribute('data-label');
|
|
341
348
|
const content = td.innerHTML;
|
|
342
349
|
const value = Number.parseFloat(td.getAttribute('data-numeric'));
|
|
343
350
|
const start = Number.parseFloat(td.getAttribute('data-start'));
|
|
344
351
|
|
|
345
|
-
if(!td.querySelector('span[data-group]'))
|
|
352
|
+
if (!td.querySelector('span[data-group]'))
|
|
346
353
|
td.innerHTML = `<span data-group="${group}" data-label="${label}">${content}</span>`;
|
|
347
354
|
|
|
348
|
-
if(!td.hasAttribute('style')){
|
|
349
|
-
|
|
350
|
-
let { percent, bottom, axis } = getValues(value,rowMin,rowMax,start);
|
|
355
|
+
if (!td.hasAttribute('style')) {
|
|
356
|
+
const { percent, bottom, axis } = getValues(value, rowMin, rowMax, start);
|
|
351
357
|
|
|
352
|
-
td.setAttribute('data-percent',percent)
|
|
353
|
-
td.setAttribute(
|
|
358
|
+
td.setAttribute('data-percent', percent);
|
|
359
|
+
td.setAttribute('style', `--bottom:${bottom}%;--percent:${percent}%;--axis:${axis}%;`);
|
|
354
360
|
|
|
355
|
-
if(tr.hasAttribute('data-total')){
|
|
356
|
-
|
|
357
|
-
|
|
361
|
+
if (tr.hasAttribute('data-total')) {
|
|
362
|
+
const rowTotal = tr.getAttribute('data-total');
|
|
363
|
+
const comparison = ((value - rowMin) / rowTotal) * 100;
|
|
358
364
|
cumulativeComparison += comparison;
|
|
359
|
-
td.setAttribute('data-comparison',comparison);
|
|
360
|
-
td.style.setProperty('--cumulative-comparision'
|
|
361
|
-
td.style.setProperty('--comparison'
|
|
365
|
+
td.setAttribute('data-comparison', comparison);
|
|
366
|
+
td.style.setProperty('--cumulative-comparision', `${cumulativeComparison}%`);
|
|
367
|
+
td.style.setProperty('--comparison', `${comparison}%`);
|
|
362
368
|
}
|
|
363
369
|
|
|
364
|
-
if(chartElement.classList.contains(
|
|
365
|
-
|
|
366
|
-
td.style.setProperty('--order'
|
|
370
|
+
if (chartElement.classList.contains('chart--value-order')) {
|
|
371
|
+
const order: number = 10000 - Math.round(percent * 100);
|
|
372
|
+
td.style.setProperty('--order', `${order}%`);
|
|
367
373
|
}
|
|
368
374
|
|
|
369
|
-
if(chartType ==
|
|
370
|
-
if(percent < coverageStart){
|
|
371
|
-
tr.style.setProperty('--coverage-start'
|
|
375
|
+
if (chartType == 'dumbbell') {
|
|
376
|
+
if (percent < coverageStart) {
|
|
377
|
+
tr.style.setProperty('--coverage-start', `${percent}%`);
|
|
372
378
|
coverageStart = percent;
|
|
373
379
|
}
|
|
374
|
-
|
|
375
|
-
if(percent > coverageEnd){
|
|
376
|
-
tr.style.setProperty('--coverage-end'
|
|
380
|
+
|
|
381
|
+
if (percent > coverageEnd) {
|
|
382
|
+
tr.style.setProperty('--coverage-end', `${percent}%`);
|
|
377
383
|
coverageEnd = percent;
|
|
378
384
|
}
|
|
379
385
|
}
|
|
380
386
|
|
|
381
|
-
if(chartType ==
|
|
382
|
-
|
|
387
|
+
if (chartType == 'waffle') {
|
|
383
388
|
let actualPercent = Math.round(td.getAttribute('data-comparison'));
|
|
384
389
|
|
|
385
390
|
// Prevent the chart from spilling out of the top
|
|
386
391
|
totalPercent += actualPercent;
|
|
387
|
-
if(totalPercent > 100)
|
|
388
|
-
actualPercent = actualPercent - (totalPercent - 100);
|
|
389
|
-
|
|
390
|
-
let percentMinusAfter = previousAfter != 0 ? actualPercent - (10 - previousAfter) : actualPercent;
|
|
391
|
-
let rowHeight = percentMinusAfter < 10 ? 10 : Math.floor(percentMinusAfter/10)*10;
|
|
392
|
-
let rowWidth = percentMinusAfter < 10 ? percentMinusAfter*10 : 100;
|
|
393
|
-
let maxWidth = actualPercent*10;
|
|
392
|
+
if (totalPercent > 100) actualPercent = actualPercent - (totalPercent - 100);
|
|
394
393
|
|
|
394
|
+
const percentMinusAfter = previousAfter != 0 ? actualPercent - (10 - previousAfter) : actualPercent;
|
|
395
|
+
const rowHeight = percentMinusAfter < 10 ? 10 : Math.floor(percentMinusAfter / 10) * 10;
|
|
396
|
+
const rowWidth = percentMinusAfter < 10 ? percentMinusAfter * 10 : 100;
|
|
397
|
+
const maxWidth = actualPercent * 10;
|
|
395
398
|
|
|
396
|
-
|
|
397
|
-
td.style.setProperty('--
|
|
398
|
-
td.style.setProperty('--
|
|
399
|
-
td.style.setProperty('--
|
|
400
|
-
td.style.setProperty('--maxWidth',`${maxWidth}%`);
|
|
399
|
+
td.style.setProperty('--rowPosition', `${rowPosition}%`);
|
|
400
|
+
td.style.setProperty('--rowHeight', `${rowHeight}%`);
|
|
401
|
+
td.style.setProperty('--rowWidth', `${rowWidth}%`);
|
|
402
|
+
td.style.setProperty('--maxWidth', `${maxWidth}%`);
|
|
401
403
|
|
|
402
404
|
// Create the psuedo element variables for the the block that sticks out BELOW the main row
|
|
403
405
|
let beforeWidth = 0;
|
|
404
|
-
if(previousAfter != 0){
|
|
405
|
-
beforeWidth = 100 -
|
|
406
|
+
if (previousAfter != 0) {
|
|
407
|
+
beforeWidth = 100 - previousAfter * 10;
|
|
406
408
|
|
|
407
|
-
td.style.setProperty('--beforeWidth'
|
|
408
|
-
td.style.setProperty('--beforeHeight'
|
|
409
|
-
td.style.setProperty('--beforeLeft'
|
|
409
|
+
td.style.setProperty('--beforeWidth', `${beforeWidth}%`);
|
|
410
|
+
td.style.setProperty('--beforeHeight', `${(10 / rowHeight) * 100}%`);
|
|
411
|
+
td.style.setProperty('--beforeLeft', `${previousAfter * 10}%`);
|
|
410
412
|
}
|
|
411
413
|
|
|
412
414
|
// Create the psuedo element variables for the the block that sticks out ABOVE the main row
|
|
413
|
-
|
|
414
|
-
|
|
415
|
+
const afterWidth = Math.round(percentMinusAfter - rowHeight) * 10;
|
|
416
|
+
const afterHeight = (10 / rowHeight) * 100;
|
|
415
417
|
|
|
416
|
-
td.style.setProperty('--afterWidth'
|
|
417
|
-
td.style.setProperty('--afterHeight'
|
|
418
|
+
td.style.setProperty('--afterWidth', `${afterWidth}%`);
|
|
419
|
+
td.style.setProperty('--afterHeight', `${afterHeight}%`);
|
|
418
420
|
|
|
419
421
|
// If the row width plus the previous after is under 10 it needs to be added to the new previousAfter variable
|
|
420
|
-
if(previousAfter + beforeWidth/10 + rowWidth/10 < 10
|
|
421
|
-
|
|
422
|
-
else
|
|
423
|
-
previousAfter = percentMinusAfter;
|
|
424
|
-
else
|
|
425
|
-
previousAfter = afterWidth/10;
|
|
422
|
+
if (previousAfter + beforeWidth / 10 + rowWidth / 10 < 10) previousAfter += beforeWidth / 10 + rowWidth / 10;
|
|
423
|
+
else if (percentMinusAfter < 10) previousAfter = percentMinusAfter;
|
|
424
|
+
else previousAfter = afterWidth / 10;
|
|
426
425
|
|
|
427
426
|
// Add to the row position so that the new row is shoved up if needed
|
|
428
427
|
rowPosition += (rowWidth > 0 ? rowHeight : 0) + (afterWidth > 0 ? 10 : 0);
|
|
@@ -430,233 +429,237 @@ export const setCellData = function(chartElement:any,chartOuter:any,table:any){
|
|
|
430
429
|
}
|
|
431
430
|
|
|
432
431
|
// totals
|
|
433
|
-
if(chartElement.classList.contains('chart--show-totals')){
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
chartElement.querySelector(`.key[data-label="${label}"]`).
|
|
440
|
-
|
|
441
|
-
|
|
432
|
+
if (chartElement.classList.contains('chart--show-totals')) {
|
|
433
|
+
const chartTotal = chartElement.getAttribute('data-total')
|
|
434
|
+
? Number.parseFloat(chartElement.getAttribute('data-total'))
|
|
435
|
+
: 0;
|
|
436
|
+
const keyTotal =
|
|
437
|
+
chartElement.querySelector(`.key[data-label="${label}"]`) &&
|
|
438
|
+
chartElement.querySelector(`.key[data-label="${label}"]`).getAttribute('data-total')
|
|
439
|
+
? Number.parseFloat(chartElement.querySelector(`.key[data-label="${label}"]`).getAttribute('data-total'))
|
|
440
|
+
: 0;
|
|
441
|
+
|
|
442
|
+
if (chartElement.querySelector(`.key[data-label="${label}"]`))
|
|
443
|
+
chartElement.querySelector(`.key[data-label="${label}"]`).setAttribute('data-total', keyTotal + value);
|
|
444
|
+
|
|
445
|
+
chartElement.setAttribute('data-total', chartTotal + value);
|
|
442
446
|
}
|
|
443
447
|
});
|
|
444
448
|
|
|
445
449
|
// Values for incremental charts i.e. histograms...
|
|
446
|
-
if(increment && incrementStart && incrementEnd){
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
+
if (increment && incrementStart && incrementEnd) {
|
|
451
|
+
const firstCellValue = parseFloat(
|
|
452
|
+
tr.querySelector('td:first-child').textContent.replace('£', '').replace('%', '').replace(',', '')
|
|
453
|
+
);
|
|
454
|
+
const position = ((firstCellValue - incrementStart) / (incrementEnd - incrementStart)) * 100;
|
|
455
|
+
tr.setAttribute('style', `--position:${position}%;`);
|
|
450
456
|
}
|
|
451
457
|
});
|
|
452
|
-
}
|
|
458
|
+
};
|
|
453
459
|
|
|
454
|
-
export const setLongestLabel = function(chartOuter:any){
|
|
455
|
-
|
|
456
|
-
|
|
460
|
+
export const setLongestLabel = function (chartOuter: any) {
|
|
461
|
+
const chartWrapper = chartOuter.querySelector('.chart__wrapper');
|
|
462
|
+
const table = chartOuter.querySelector('.chart table');
|
|
457
463
|
// set the longest label attr so that the bar chart knows what margin to set on the left
|
|
458
464
|
let longestLabel = '';
|
|
459
465
|
Array.from(table.querySelectorAll('tbody tr td:first-child')).forEach((td: any) => {
|
|
460
|
-
if(typeof td.textContent !=
|
|
466
|
+
if (typeof td.textContent != 'undefined' && td.textContent.length > longestLabel.length)
|
|
461
467
|
longestLabel = td.textContent;
|
|
462
468
|
});
|
|
463
|
-
chartWrapper.setAttribute('data-longest-label',longestLabel);
|
|
469
|
+
chartWrapper.setAttribute('data-longest-label', longestLabel);
|
|
464
470
|
|
|
465
471
|
// set the longest data set attr so that the bar chart knows what margin to set on the left
|
|
466
472
|
let longestSet = '';
|
|
467
473
|
Array.from(table.querySelectorAll('thead tr th')).forEach((td: any) => {
|
|
468
|
-
if(td.textContent.length > longestSet.length)
|
|
469
|
-
longestSet = td.textContent;
|
|
474
|
+
if (td.textContent.length > longestSet.length) longestSet = td.textContent;
|
|
470
475
|
});
|
|
471
|
-
chartWrapper.setAttribute('data-set-label',longestSet);
|
|
476
|
+
chartWrapper.setAttribute('data-set-label', longestSet);
|
|
472
477
|
};
|
|
473
478
|
// #endregion
|
|
474
479
|
|
|
475
480
|
// #region CREATE function
|
|
476
|
-
export const createTypeSwitcher = function(chartElement:any,chartKey:any,chartOptions:any){
|
|
477
|
-
|
|
478
|
-
const
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
481
|
+
export const createTypeSwitcher = function (chartElement: any, chartKey: any, chartOptions: any) {
|
|
482
|
+
const chartID = `chart-${Date.now() + (Math.floor(Math.random() * 100) + 1)}`;
|
|
483
|
+
const availableTypes = chartElement.hasAttribute('data-types')
|
|
484
|
+
? chartElement.getAttribute('data-types').split(',')
|
|
485
|
+
: [];
|
|
486
|
+
|
|
487
|
+
if (!chartElement.hasAttribute('data-types') && chartElement.hasAttribute('data-type'))
|
|
488
|
+
chartKey.insertAdjacentHTML(
|
|
489
|
+
'afterend',
|
|
490
|
+
`<input type="radio" name="chart-type" value="${chartElement.getAttribute('data-type')}" checked="">`
|
|
491
|
+
);
|
|
492
|
+
else if (chartElement.hasAttribute('data-types')) {
|
|
493
|
+
const chartType = chartElement.hasAttribute('data-type') ? chartElement.getAttribute('data-type') : 'column';
|
|
494
|
+
chartOptions.insertAdjacentHTML(
|
|
495
|
+
'beforebegin',
|
|
496
|
+
availableTypes
|
|
497
|
+
.map(
|
|
498
|
+
(type: any) =>
|
|
499
|
+
`<input type="radio" name="chart-type" value="${type}" id="${chartID}-${type}" ${chartType == type ? 'checked=""' : ''}>`
|
|
500
|
+
)
|
|
501
|
+
.join('')
|
|
502
|
+
);
|
|
503
|
+
chartOptions.insertAdjacentHTML(
|
|
504
|
+
'beforeend',
|
|
505
|
+
availableTypes.map((type: any) => `<label for="${chartID}-${type}">${type}</label>`).join('')
|
|
506
|
+
);
|
|
488
507
|
}
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
export const createChartKey = function(chartOuter:any,tableElement:any,chartKey:any){
|
|
508
|
+
};
|
|
492
509
|
|
|
493
|
-
|
|
510
|
+
export const createChartKey = function (chartOuter: any, tableElement: any, chartKey: any) {
|
|
511
|
+
const chartID = `chart-${Date.now() + (Math.floor(Math.random() * 100) + 1)}`;
|
|
494
512
|
//const chartOuter = chartElement.querySelector('.chart__outer');
|
|
495
513
|
|
|
496
|
-
let previousInput:any;
|
|
497
|
-
|
|
514
|
+
let previousInput: any;
|
|
498
515
|
|
|
499
|
-
|
|
516
|
+
const headings = Array.from(tableElement.querySelectorAll('thead th'));
|
|
500
517
|
|
|
501
|
-
headings.forEach((arrayElement:any
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
previousInput = createChartKeyItem(chartID,index,arrayElement.textContent,chartKey,chartOuter,previousInput);
|
|
518
|
+
headings.forEach((arrayElement: any, index) => {
|
|
519
|
+
if (index != 0) {
|
|
520
|
+
previousInput = createChartKeyItem(chartID, index, arrayElement.textContent, chartKey, chartOuter, previousInput);
|
|
506
521
|
}
|
|
507
522
|
|
|
508
|
-
if(index == 50){
|
|
523
|
+
if (index == 50) {
|
|
509
524
|
headings.length = index + 1;
|
|
510
525
|
}
|
|
511
526
|
});
|
|
512
527
|
|
|
513
528
|
return true;
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
function createChartKeyItem(chartID:string,index:number,text:Array<string>,chartKey:any,chartOuter:any,previousInput:any){
|
|
517
|
-
let input = document.createElement('input');
|
|
518
|
-
input.setAttribute('name',`${chartID}-dataset-${index}`);
|
|
519
|
-
input.setAttribute('id',`${chartID}-dataset-${index}`);
|
|
520
|
-
input.setAttribute('checked',`checked`);
|
|
521
|
-
input.setAttribute('type',`checkbox`);
|
|
529
|
+
};
|
|
522
530
|
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
531
|
+
function createChartKeyItem(
|
|
532
|
+
chartID: string,
|
|
533
|
+
index: number,
|
|
534
|
+
text: Array<string>,
|
|
535
|
+
chartKey: any,
|
|
536
|
+
chartOuter: any,
|
|
537
|
+
previousInput: any
|
|
538
|
+
) {
|
|
539
|
+
const input = document.createElement('input');
|
|
540
|
+
input.setAttribute('name', `${chartID}-dataset-${index}`);
|
|
541
|
+
input.setAttribute('id', `${chartID}-dataset-${index}`);
|
|
542
|
+
input.setAttribute('checked', `checked`);
|
|
543
|
+
input.setAttribute('type', `checkbox`);
|
|
544
|
+
|
|
545
|
+
if (index == 1) chartOuter.prepend(input);
|
|
546
|
+
else chartOuter.insertBefore(input, previousInput.nextSibling);
|
|
527
547
|
|
|
528
548
|
previousInput = input;
|
|
529
549
|
|
|
530
|
-
|
|
531
|
-
label.setAttribute('class'
|
|
532
|
-
label.setAttribute('for'
|
|
533
|
-
label.setAttribute('data-label'
|
|
550
|
+
const label = document.createElement('label');
|
|
551
|
+
label.setAttribute('class', `key btn btn-action`);
|
|
552
|
+
label.setAttribute('for', `${chartID}-dataset-${index}`);
|
|
553
|
+
label.setAttribute('data-label', `${text}`);
|
|
534
554
|
label.innerHTML = `${text}`;
|
|
535
555
|
chartKey.append(label);
|
|
536
556
|
|
|
537
557
|
return previousInput;
|
|
538
558
|
}
|
|
539
559
|
|
|
540
|
-
export const createChartGuidelines = function(chartElement:any,chartOuter:any,chartGuidelines:any){
|
|
541
|
-
|
|
542
|
-
let {min, max, yaxis, increment, guidelines} = getChartData(chartElement,chartOuter);
|
|
560
|
+
export const createChartGuidelines = function (chartElement: any, chartOuter: any, chartGuidelines: any) {
|
|
561
|
+
let { min, max, yaxis, increment, guidelines } = getChartData(chartElement, chartOuter);
|
|
543
562
|
|
|
544
|
-
if(guidelines.length)
|
|
545
|
-
yaxis = guidelines;
|
|
563
|
+
if (guidelines.length) yaxis = guidelines;
|
|
546
564
|
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
max = numberOfDays(min,max);
|
|
565
|
+
const startDay = min;
|
|
566
|
+
if (increment == 'days') {
|
|
567
|
+
max = numberOfDays(min, max);
|
|
552
568
|
min = 0;
|
|
553
569
|
}
|
|
554
570
|
|
|
555
|
-
if(!chartGuidelines){
|
|
571
|
+
if (!chartGuidelines) {
|
|
556
572
|
chartGuidelines = document.createElement('div');
|
|
557
|
-
chartGuidelines.setAttribute('class','chart__guidelines');
|
|
573
|
+
chartGuidelines.setAttribute('class', 'chart__guidelines');
|
|
558
574
|
}
|
|
559
575
|
|
|
560
576
|
chartGuidelines.innerHTML = '';
|
|
561
|
-
for (
|
|
562
|
-
|
|
563
|
-
let value = parseFloat(yaxis[i].replace('£','').replace('%','').replace(',',''));
|
|
577
|
+
for (let i = 0; i < yaxis.length; i++) {
|
|
578
|
+
let value = parseFloat(yaxis[i].replace('£', '').replace('%', '').replace(',', ''));
|
|
564
579
|
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
value = numberOfDays(startDay,yaxis[i]) - 1;
|
|
580
|
+
if (increment == 'days') {
|
|
581
|
+
value = numberOfDays(startDay, yaxis[i]) - 1;
|
|
569
582
|
}
|
|
570
583
|
|
|
571
|
-
|
|
584
|
+
const { axis } = getValues(value, min, max);
|
|
572
585
|
chartGuidelines.innerHTML += `<div class="guideline" style="--percent:${axis}%;"><span>${yaxis[i]}</span></div>`;
|
|
573
586
|
}
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
export const createChartYaxis = function(chartElement:any,chartOuter:any,chartYaxis:any){
|
|
577
|
-
|
|
578
|
-
let {min, max, yaxis, increment} = getChartData(chartElement,chartOuter);
|
|
587
|
+
};
|
|
579
588
|
|
|
580
|
-
|
|
589
|
+
export const createChartYaxis = function (chartElement: any, chartOuter: any, chartYaxis: any) {
|
|
590
|
+
let { min, max, yaxis, increment } = getChartData(chartElement, chartOuter);
|
|
581
591
|
|
|
582
|
-
|
|
592
|
+
const startDay = min;
|
|
583
593
|
|
|
584
|
-
|
|
594
|
+
if (increment == 'days') {
|
|
595
|
+
max = numberOfDays(min, max);
|
|
585
596
|
min = 0;
|
|
586
597
|
}
|
|
587
598
|
|
|
588
|
-
if(!chartYaxis){
|
|
599
|
+
if (!chartYaxis) {
|
|
589
600
|
chartYaxis = document.createElement('div');
|
|
590
|
-
chartYaxis.setAttribute('class','chart__yaxis');
|
|
601
|
+
chartYaxis.setAttribute('class', 'chart__yaxis');
|
|
591
602
|
}
|
|
592
603
|
|
|
593
604
|
chartYaxis.innerHTML = '';
|
|
594
|
-
for (
|
|
595
|
-
|
|
596
|
-
let value = parseFloat(yaxis[i].replace('£','').replace('%',''));
|
|
597
|
-
|
|
598
|
-
if(increment == "days"){
|
|
605
|
+
for (let i = 0; i < yaxis.length; i++) {
|
|
606
|
+
let value = parseFloat(yaxis[i].replace('£', '').replace('%', ''));
|
|
599
607
|
|
|
600
|
-
|
|
601
|
-
|
|
608
|
+
if (increment == 'days') {
|
|
609
|
+
value = numberOfDays(startDay, yaxis[i]);
|
|
602
610
|
}
|
|
603
611
|
|
|
604
|
-
|
|
612
|
+
const { axis } = getValues(value, min, max);
|
|
605
613
|
chartYaxis.innerHTML += `<div class="axis__point" style="--percent:${axis}%;"><span>${yaxis[i]}</span></div>`;
|
|
606
614
|
}
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
export const createXaxis = function(chartElement:any,chartOuter:any,xaxis:any){
|
|
615
|
+
};
|
|
610
616
|
|
|
617
|
+
export const createXaxis = function (chartElement: any, chartOuter: any, xaxis: any) {
|
|
611
618
|
const chart = chartOuter.querySelector('.chart');
|
|
612
619
|
let chartXaxis = chartOuter.querySelector('.chart__xaxis');
|
|
613
620
|
|
|
614
|
-
|
|
621
|
+
const { increment, start, end } = getChartData(chartElement, chartOuter);
|
|
615
622
|
|
|
616
|
-
if(!chartXaxis){
|
|
623
|
+
if (!chartXaxis) {
|
|
617
624
|
chartXaxis = document.createElement('div');
|
|
618
|
-
chartXaxis.setAttribute('class','chart__xaxis');
|
|
625
|
+
chartXaxis.setAttribute('class', 'chart__xaxis');
|
|
619
626
|
}
|
|
620
|
-
if(increment && start && end){
|
|
627
|
+
if (increment && start && end) {
|
|
621
628
|
chartXaxis.innerHTML = '';
|
|
622
|
-
for (
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
let position = ((value - start)/(end - start)) * 100;
|
|
629
|
+
for (let i = 0; i < xaxis.length; i++) {
|
|
630
|
+
const value = parseFloat(xaxis[i].replace('£', '').replace('%', ''));
|
|
631
|
+
const position = ((value - start) / (end - start)) * 100;
|
|
626
632
|
|
|
627
633
|
chartXaxis.innerHTML += `<div class="axis__point" style="--percent:${position}%;"><span>${xaxis[i]}</span></div>`;
|
|
628
634
|
}
|
|
629
635
|
}
|
|
630
636
|
chart.prepend(chartXaxis);
|
|
631
|
-
}
|
|
637
|
+
};
|
|
638
|
+
|
|
639
|
+
export const createLines = function (chartElement: any, chartOuter: any) {
|
|
640
|
+
const { min, max } = getChartData(chartElement, chartOuter);
|
|
632
641
|
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
let {min, max} = getChartData(chartElement,chartOuter);
|
|
636
|
-
|
|
637
|
-
let chartType = chartElement.getAttribute('data-type');
|
|
642
|
+
const chartType = chartElement.getAttribute('data-type');
|
|
638
643
|
let returnString = '';
|
|
639
644
|
//let chartWrapper = chartOuter.querySelector('.chart__wrapper');
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
let spacer = 200/(itemCount - 1);
|
|
645
|
+
const linesWrapper = chartOuter.querySelector('.chart__lines');
|
|
646
|
+
|
|
647
|
+
const items = Array.from(chartOuter.querySelectorAll('tbody tr'));
|
|
648
|
+
const lines = [];
|
|
649
|
+
const linesCount = chartOuter.querySelectorAll('thead th:not(:first-child)').length;
|
|
650
|
+
const commands = [];
|
|
651
|
+
const animatelines = [];
|
|
652
|
+
const itemCount = items.length <= 1000 ? items.length : 1000;
|
|
653
|
+
let spacer = 200 / (itemCount - 1);
|
|
649
654
|
let spacerIndent = 0;
|
|
650
655
|
|
|
651
|
-
if(chartType ==
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
spacerIndent = spacer/2;
|
|
656
|
+
if (chartType == 'combo') {
|
|
657
|
+
spacer = 200 / itemCount;
|
|
658
|
+
spacerIndent = spacer / 2;
|
|
655
659
|
}
|
|
656
660
|
|
|
657
661
|
// Creates the lines array from the fields array
|
|
658
|
-
for(let i = 0; i < linesCount; i++){
|
|
659
|
-
|
|
662
|
+
for (let i = 0; i < linesCount; i++) {
|
|
660
663
|
lines[i] = '';
|
|
661
664
|
animatelines[i] = '';
|
|
662
665
|
commands[i] = 'M';
|
|
@@ -665,26 +668,21 @@ export const createLines = function(chartElement:any,chartOuter:any){
|
|
|
665
668
|
// populate the lines array from the items array
|
|
666
669
|
let counter = 0;
|
|
667
670
|
|
|
668
|
-
Array.from(chartOuter.querySelectorAll('tbody tr')).forEach((item:any) => {
|
|
669
|
-
|
|
671
|
+
Array.from(chartOuter.querySelectorAll('tbody tr')).forEach((item: any) => {
|
|
670
672
|
const display = getComputedStyle(item).display;
|
|
671
673
|
|
|
672
|
-
if(display !=
|
|
673
|
-
|
|
674
|
-
|
|
674
|
+
if (display != 'none') {
|
|
675
|
+
Array.from(item.querySelectorAll('td:not(:first-child)')).forEach((cell: any, subindex) => {
|
|
676
|
+
if (!cell.classList.contains('chart__bar')) {
|
|
677
|
+
const value = cell.getAttribute('data-numeric');
|
|
675
678
|
|
|
676
|
-
|
|
679
|
+
const { axis } = getValues(value, min, max);
|
|
677
680
|
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
let { axis } = getValues(value,min,max);
|
|
681
|
-
|
|
682
|
-
if(!Number.isNaN(axis)){
|
|
683
|
-
lines[subindex] += `${commands[subindex]} ${(spacerIndent) + (spacer * counter)} ${100-axis} `;
|
|
681
|
+
if (!Number.isNaN(axis)) {
|
|
682
|
+
lines[subindex] += `${commands[subindex]} ${spacerIndent + spacer * counter} ${100 - axis} `;
|
|
684
683
|
animatelines[subindex] += `${commands[subindex]} ${spacer * counter} 100 `;
|
|
685
684
|
commands[subindex] = 'L';
|
|
686
|
-
}
|
|
687
|
-
else {
|
|
685
|
+
} else {
|
|
688
686
|
commands[subindex] = 'M';
|
|
689
687
|
}
|
|
690
688
|
}
|
|
@@ -692,54 +690,48 @@ export const createLines = function(chartElement:any,chartOuter:any){
|
|
|
692
690
|
|
|
693
691
|
counter++;
|
|
694
692
|
}
|
|
695
|
-
|
|
696
693
|
});
|
|
697
694
|
|
|
698
695
|
lines.forEach((line, index) => {
|
|
699
|
-
|
|
700
696
|
returnString += `
|
|
701
697
|
<svg viewBox="0 0 200 100" class="line" preserveAspectRatio="none">
|
|
702
698
|
<path fill="none" d="${line}" style="--path: path('${animatelines[index]}');"></path>
|
|
703
|
-
</svg
|
|
699
|
+
</svg>`;
|
|
704
700
|
});
|
|
705
701
|
|
|
706
702
|
linesWrapper.innerHTML = returnString;
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
export const createPies = function(chartOuter:any){
|
|
703
|
+
};
|
|
710
704
|
|
|
705
|
+
export const createPies = function (chartOuter: any) {
|
|
711
706
|
let returnString = '';
|
|
712
|
-
|
|
707
|
+
const chartInner = chartOuter.querySelector('.chart');
|
|
713
708
|
let pieWrapper = chartOuter.querySelector('.pies');
|
|
714
709
|
|
|
715
|
-
if(!pieWrapper){
|
|
716
|
-
pieWrapper = document.createElement(
|
|
717
|
-
pieWrapper.setAttribute('class','pies');
|
|
710
|
+
if (!pieWrapper) {
|
|
711
|
+
pieWrapper = document.createElement('div');
|
|
712
|
+
pieWrapper.setAttribute('class', 'pies');
|
|
718
713
|
chartInner.append(pieWrapper);
|
|
719
714
|
}
|
|
720
715
|
|
|
721
|
-
Array.from(chartInner.querySelectorAll('tbody tr')).forEach((item:any, index) => {
|
|
722
|
-
|
|
716
|
+
Array.from(chartInner.querySelectorAll('tbody tr')).forEach((item: any, index) => {
|
|
723
717
|
let paths = '';
|
|
724
718
|
let tooltips = '';
|
|
725
719
|
let cumulativePercent = 0;
|
|
726
720
|
let total = 0;
|
|
727
|
-
|
|
728
|
-
|
|
721
|
+
const titleKey = item.querySelectorAll('td')[0];
|
|
722
|
+
const title = titleKey.innerHTML;
|
|
729
723
|
let pieCount = 0;
|
|
730
724
|
|
|
731
725
|
// Work out the total amount
|
|
732
|
-
Array.from(item.querySelectorAll('td')).forEach((td:any, subindex) => {
|
|
733
|
-
|
|
726
|
+
Array.from(item.querySelectorAll('td')).forEach((td: any, subindex) => {
|
|
734
727
|
const display = getComputedStyle(td).display;
|
|
735
728
|
|
|
736
|
-
if(subindex != 0 && display != 'none'){
|
|
737
|
-
|
|
729
|
+
if (subindex != 0 && display != 'none') {
|
|
738
730
|
let value = td.getAttribute('data-numeric');
|
|
739
731
|
|
|
740
|
-
value = value.replace('£','');
|
|
741
|
-
value = value.replace('%','');
|
|
742
|
-
value = value.replace(',','');
|
|
732
|
+
value = value.replace('£', '');
|
|
733
|
+
value = value.replace('%', '');
|
|
734
|
+
value = value.replace(',', '');
|
|
743
735
|
value = Number.parseInt(value);
|
|
744
736
|
|
|
745
737
|
total += value;
|
|
@@ -748,86 +740,78 @@ export const createPies = function(chartOuter:any){
|
|
|
748
740
|
});
|
|
749
741
|
|
|
750
742
|
// Create the paths
|
|
751
|
-
Array.from(item.querySelectorAll('td')).forEach((td:any, subindex) => {
|
|
752
|
-
|
|
743
|
+
Array.from(item.querySelectorAll('td')).forEach((td: any, subindex) => {
|
|
753
744
|
const display = getComputedStyle(td).display;
|
|
754
745
|
|
|
755
|
-
if (subindex != 0 && pieCount == 1 && display !=
|
|
756
|
-
|
|
746
|
+
if (subindex != 0 && pieCount == 1 && display != 'none') {
|
|
757
747
|
const pathData = `M 0 0 L 100 0 A 100 100 0 1 1 100 -0.01 L 0 0`;
|
|
758
748
|
|
|
759
749
|
paths += `<path d="${pathData}" style="${td.getAttribute('style')} --path-index: ${subindex};"></path>`;
|
|
760
750
|
tooltips += `<foreignObject x="-70" y="-70" width="140" height="140" ><div><span class="h5 mb-0"><span class="total d-block">${ucfirst(unsnake(title))}</span> ${ucfirst(unsnake(td.getAttribute('data-label')))}<br/> ${td.innerHTML}${td.hasAttribute('data-second') ? `${td.getAttribute('data-second-label')}: ${td.getAttribute('data-second')}` : ''}</span></div></foreignObject>`;
|
|
761
|
-
}
|
|
762
|
-
else if(subindex != 0){
|
|
763
|
-
|
|
751
|
+
} else if (subindex != 0) {
|
|
764
752
|
let value = td.getAttribute('data-numeric');
|
|
765
|
-
|
|
753
|
+
const hide = display == 'none' ? 'display: none;' : '';
|
|
766
754
|
|
|
767
|
-
value = value.replace('£','');
|
|
768
|
-
value = value.replace('%','');
|
|
769
|
-
value = value.replace(',','');
|
|
755
|
+
value = value.replace('£', '');
|
|
756
|
+
value = value.replace('%', '');
|
|
757
|
+
value = value.replace(',', '');
|
|
770
758
|
value = Number.parseInt(value);
|
|
771
759
|
|
|
772
|
-
|
|
773
|
-
const [startX, startY] = getCoordinatesForPercent(cumulativePercent,pieCount);
|
|
774
|
-
const [endX, endY] = getCoordinatesForPercent(cumulativePercent+percent,pieCount);
|
|
775
|
-
const largeArcFlag = percent > .5 ? 1 : 0; // if the slice is more than 50%, take the large arc (the long way around)
|
|
760
|
+
const percent = value / total;
|
|
761
|
+
const [startX, startY] = getCoordinatesForPercent(cumulativePercent, pieCount);
|
|
762
|
+
const [endX, endY] = getCoordinatesForPercent(cumulativePercent + percent, pieCount);
|
|
763
|
+
const largeArcFlag = percent > 0.5 ? 1 : 0; // if the slice is more than 50%, take the large arc (the long way around)
|
|
776
764
|
const pathData = [
|
|
777
765
|
`M 0 0`,
|
|
778
|
-
`L ${
|
|
779
|
-
`A 100 100 0 ${largeArcFlag} 1 ${
|
|
766
|
+
`L ${startX ? startX.toFixed(0) : 0} ${startY ? startY.toFixed(0) : 0}`, // Move
|
|
767
|
+
`A 100 100 0 ${largeArcFlag} 1 ${endX ? endX.toFixed(0) : 0} ${endY ? endY.toFixed(0) : 0}`, // Arc
|
|
780
768
|
`L 0 0`, // Line
|
|
781
769
|
].join(' ');
|
|
782
770
|
|
|
783
771
|
paths += `<path d="${pathData}" style="${td.getAttribute('style')} --path-index: ${subindex};${hide}"></path>`;
|
|
784
772
|
tooltips += `<foreignObject x="-70" y="-70" width="140" height="140" ><div><span class="h5 mb-0"><span class="total d-block">${ucfirst(unsnake(title))}</span> ${ucfirst(unsnake(td.getAttribute('data-label')))}<br/> ${td.innerHTML}${td.hasAttribute('data-second') ? `${td.getAttribute('data-second-label')}: ${td.getAttribute('data-second')}` : ''}</span></div></foreignObject>`;
|
|
785
|
-
|
|
773
|
+
|
|
786
774
|
// each slice starts where the last slice ended, so keep a cumulative percent
|
|
787
|
-
if(display != 'none')
|
|
788
|
-
cumulativePercent += percent;
|
|
775
|
+
if (display != 'none') cumulativePercent += percent;
|
|
789
776
|
}
|
|
790
777
|
});
|
|
791
|
-
|
|
792
|
-
returnString += `<div class="pie"><svg viewBox="-105 -105 210 210" preserveAspectRatio="none" style="--row-index: ${index+1};">${paths}${tooltips}</svg><div><span class="h5 mb-0">${title}</span></div></div
|
|
778
|
+
|
|
779
|
+
returnString += `<div class="pie"><svg viewBox="-105 -105 210 210" preserveAspectRatio="none" style="--row-index: ${index + 1};">${paths}${tooltips}</svg><div><span class="h5 mb-0">${title}</span></div></div>`;
|
|
793
780
|
});
|
|
794
781
|
|
|
795
782
|
pieWrapper.innerHTML = returnString;
|
|
796
|
-
}
|
|
783
|
+
};
|
|
797
784
|
|
|
798
|
-
export const createSlope = function(chartElement:any,chartOuter:any){
|
|
799
|
-
let n:number = 0;
|
|
800
|
-
let totalX:number = 0;
|
|
801
|
-
let totalY:number = 0;
|
|
802
|
-
let totalXY:number = 0;
|
|
803
|
-
let totalXsquared:number = 0;
|
|
785
|
+
export const createSlope = function (chartElement: any, chartOuter: any) {
|
|
786
|
+
let n: number = 0;
|
|
787
|
+
let totalX: number = 0;
|
|
788
|
+
let totalY: number = 0;
|
|
789
|
+
let totalXY: number = 0;
|
|
790
|
+
let totalXsquared: number = 0;
|
|
804
791
|
|
|
805
|
-
|
|
792
|
+
const { min, max, start, end, slope, yInt } = getChartData(chartElement, chartOuter);
|
|
806
793
|
|
|
807
|
-
|
|
794
|
+
const chart = chartOuter.querySelector('.chart');
|
|
808
795
|
let slopeWrapper = chartOuter.querySelector('.slope');
|
|
809
796
|
|
|
810
|
-
if(!slopeWrapper){
|
|
811
|
-
|
|
812
|
-
slopeWrapper
|
|
813
|
-
slopeWrapper.setAttribute('class','slope');
|
|
797
|
+
if (!slopeWrapper) {
|
|
798
|
+
slopeWrapper = document.createElement('div');
|
|
799
|
+
slopeWrapper.setAttribute('class', 'slope');
|
|
814
800
|
chart.prepend(slopeWrapper);
|
|
815
801
|
}
|
|
816
802
|
|
|
817
|
-
Array.from(chart.querySelectorAll('tbody tr')).forEach((tr:any) => {
|
|
818
|
-
|
|
803
|
+
Array.from(chart.querySelectorAll('tbody tr')).forEach((tr: any) => {
|
|
819
804
|
const display = getComputedStyle(tr).display;
|
|
820
|
-
if(display !=
|
|
821
|
-
|
|
822
|
-
let x = parseFloat(tr.querySelector('td:first-child').textContent);
|
|
805
|
+
if (display != 'none') {
|
|
806
|
+
const x = parseFloat(tr.querySelector('td:first-child').textContent);
|
|
823
807
|
let y = 0;
|
|
824
808
|
|
|
825
|
-
Array.from(tr.querySelectorAll('td:not(:first-child)')).forEach((td:any) => {
|
|
809
|
+
Array.from(tr.querySelectorAll('td:not(:first-child)')).forEach((td: any) => {
|
|
826
810
|
y += parseFloat(td.getAttribute('data-numeric'));
|
|
827
811
|
});
|
|
828
812
|
|
|
829
|
-
|
|
830
|
-
|
|
813
|
+
const xy = x * y;
|
|
814
|
+
const xSquared = x * x;
|
|
831
815
|
|
|
832
816
|
totalX += x;
|
|
833
817
|
totalY += y;
|
|
@@ -838,65 +822,63 @@ export const createSlope = function(chartElement:any,chartOuter:any){
|
|
|
838
822
|
}
|
|
839
823
|
});
|
|
840
824
|
|
|
841
|
-
|
|
842
825
|
// Least squares method (https://www.youtube.com/watch?v=P8hT5nDai6A)
|
|
843
|
-
|
|
844
|
-
|
|
826
|
+
const m = slope ? parseFloat(slope) : (n * totalXY - totalX * totalY) / (n * totalXsquared - totalX * totalX); // Slope
|
|
827
|
+
const b = yInt ? parseFloat(yInt) : (totalY - m * totalX) / n; // Y intercept
|
|
845
828
|
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
let { percent: firstYPercent } = getValues(firstY,min,max);
|
|
850
|
-
let { percent: lastYPercent } = getValues(lastY,min,max);
|
|
829
|
+
const firstY = m * parseFloat(start) + b;
|
|
830
|
+
const lastY = m * parseFloat(end) + b;
|
|
851
831
|
|
|
852
|
-
|
|
853
|
-
}
|
|
832
|
+
const { percent: firstYPercent } = getValues(firstY, min, max);
|
|
833
|
+
const { percent: lastYPercent } = getValues(lastY, min, max);
|
|
854
834
|
|
|
855
|
-
|
|
835
|
+
slopeWrapper.innerHTML = `<svg viewBox="0 0 200 100" class="line" preserveAspectRatio="none"><path fill="none" d="M 0 ${100 - firstYPercent} L 200 ${100 - lastYPercent}" style="--path: path('M 0 100 L 200 100');"></path></svg>`;
|
|
836
|
+
};
|
|
856
837
|
|
|
838
|
+
function createKeyTotals(chartElement: any, chartOuter: any) {
|
|
857
839
|
let chartTotal = 0;
|
|
858
840
|
|
|
859
|
-
Array.from(
|
|
860
|
-
|
|
841
|
+
Array.from(
|
|
842
|
+
chartOuter.querySelectorAll(
|
|
843
|
+
'tbody tr:not([data-total]) td[data-numeric]:not([data-label="Min"]):not([data-label="Max"]):not(:first-child)'
|
|
844
|
+
)
|
|
845
|
+
).forEach((td: any) => {
|
|
861
846
|
const value = Number.parseFloat(td.getAttribute('data-numeric'));
|
|
862
847
|
chartTotal += value;
|
|
863
848
|
});
|
|
864
849
|
// Get row totals already worked out
|
|
865
|
-
Array.from(chartOuter.querySelectorAll('tbody tr[data-total]')).forEach((tr:any) => {
|
|
866
|
-
|
|
850
|
+
Array.from(chartOuter.querySelectorAll('tbody tr[data-total]')).forEach((tr: any) => {
|
|
867
851
|
const value = Number.parseFloat(tr.getAttribute('data-total'));
|
|
868
852
|
chartTotal += value;
|
|
869
853
|
});
|
|
870
854
|
|
|
871
|
-
chartElement.setAttribute('data-total',chartTotal);
|
|
872
|
-
|
|
873
|
-
Array.from(chartOuter.querySelectorAll('.chart__key .key[data-label]')).forEach((key:any) => {
|
|
855
|
+
chartElement.setAttribute('data-total', chartTotal);
|
|
874
856
|
|
|
875
|
-
|
|
876
|
-
|
|
857
|
+
Array.from(chartOuter.querySelectorAll('.chart__key .key[data-label]')).forEach((key: any) => {
|
|
858
|
+
if (key.querySelector('.chart__total')) key.querySelector('.chart__total').remove();
|
|
877
859
|
|
|
878
|
-
|
|
879
|
-
let keyTotal:any = 0;
|
|
880
|
-
|
|
881
|
-
Array.from(chartOuter.querySelectorAll(`tbody td[data-label="${label}"]`)).forEach((td:any) => {
|
|
860
|
+
const label = key.getAttribute('data-label');
|
|
861
|
+
let keyTotal: any = 0;
|
|
882
862
|
|
|
863
|
+
Array.from(chartOuter.querySelectorAll(`tbody td[data-label="${label}"]`)).forEach((td: any) => {
|
|
883
864
|
const value = Number.parseFloat(td.getAttribute('data-numeric'));
|
|
884
865
|
keyTotal += value;
|
|
885
866
|
});
|
|
886
867
|
|
|
887
|
-
|
|
868
|
+
const keyPercent = Math.round((keyTotal / chartTotal) * 100);
|
|
888
869
|
|
|
889
|
-
if(chartElement.hasAttribute('data-currency')){
|
|
890
|
-
|
|
891
|
-
if (chartElement.getAttribute('data-currency') == "GBP") {
|
|
870
|
+
if (chartElement.hasAttribute('data-currency')) {
|
|
871
|
+
if (chartElement.getAttribute('data-currency') == 'GBP') {
|
|
892
872
|
// @ts-ignore
|
|
893
|
-
keyTotal = new Intl.NumberFormat('en-GB', {
|
|
873
|
+
keyTotal = new Intl.NumberFormat('en-GB', {
|
|
874
|
+
style: 'currency',
|
|
875
|
+
currency: 'GBP',
|
|
876
|
+
trailingZeroDisplay: 'stripIfInteger',
|
|
877
|
+
}).format(keyTotal);
|
|
894
878
|
}
|
|
895
|
-
}
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
}
|
|
899
|
-
else {
|
|
879
|
+
} else if (chartElement.hasAttribute('data-total-format')) {
|
|
880
|
+
keyTotal = chartElement.getAttribute('data-total-format').replace('{i}', keyTotal);
|
|
881
|
+
} else {
|
|
900
882
|
keyTotal = new Intl.NumberFormat('en-GB').format(keyTotal);
|
|
901
883
|
}
|
|
902
884
|
|
|
@@ -905,4 +887,4 @@ function createKeyTotals(chartElement:any,chartOuter:any){
|
|
|
905
887
|
}
|
|
906
888
|
// #endregion
|
|
907
889
|
|
|
908
|
-
export default setupChart;
|
|
890
|
+
export default setupChart;
|