@geotab/zenith 3.1.1-beta.6 → 3.2.0-beta.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.
- package/README.md +20 -0
- package/dist/advancedGroupsFilter/advancedGroupsFilter.js +136 -30
- package/dist/advancedGroupsFilter/advancedGroupsFilterForm.js +139 -34
- package/dist/advancedGroupsFilter/advancedGroupsFilterFormSection.js +352 -87
- package/dist/advancedGroupsFilter/advancedGroupsFilterSectionTooltip.d.ts +0 -1
- package/dist/advancedGroupsFilter/advancedGroupsFilterSectionTooltip.js +83 -9
- package/dist/alertRaw/alertRaw.js +175 -54
- package/dist/banner/bannerMultipLine.js +131 -23
- package/dist/banner/bannerSingleLine.js +110 -16
- package/dist/betaPill/betaPill.js +111 -20
- package/dist/bookmark/bookmark.js +95 -28
- package/dist/bulkEditControl/bulkEditControl.js +167 -34
- package/dist/calendar/calendar.js +943 -273
- package/dist/calendar/calendarUtils.js +157 -85
- package/dist/card/card.js +268 -123
- package/dist/chart/accessibleChart/accessibleChartNarrative.js +648 -555
- package/dist/chart/accessibleChart/accessibleChartTable.js +245 -86
- package/dist/chart/chart.js +36 -21
- package/dist/chart/chartAxis/chartAxis.js +85 -7
- package/dist/checkboxListWithAction/checkboxListWithAction.js +224 -69
- package/dist/chip/chip.js +195 -91
- package/dist/columnsSelector/columnsSelector.js +97 -12
- package/dist/columnsSelector/columnsTab/columnsTab.js +59 -15
- package/dist/columnsSelector/columnsTabGroup/columnsTabGroup.js +81 -34
- package/dist/comboboxSelected/comboboxSelected.js +1 -3
- package/dist/dataFeed/feedExpandControl/feedExpandControl.js +25 -10
- package/dist/dataGrid/columns/checkboxColumn/checkboxHeaderCell.js +92 -11
- package/dist/dataGrid/dataGrid.js +227 -117
- package/dist/dataGrid/emptySearchList/emptySearchList.js +56 -9
- package/dist/dataGrid/entitiesListActions/actions/columnsListButton.js +51 -7
- package/dist/dataGrid/entitiesListActions/actions/fullscreenButton.js +64 -18
- package/dist/dataGrid/withFlexibleColumns/components/columnSettings.js +84 -10
- package/dist/dataGrid/withFlexibleColumns/components/columnSettingsSidePanel.js +48 -16
- package/dist/dataGrid/withSelectableRows/components/bulkActions/bulkActions.js +223 -32
- package/dist/dataGrid/withSelectableRows/withSelectableRows.js +286 -213
- package/dist/dataGrid/withSortableColumns/columns/sortableColumnWrapper.js +178 -95
- package/dist/dateInputInner/dateInputInner.js +791 -476
- package/dist/dateInputInner/dateInputInnerControlBlock.js +125 -22
- package/dist/dateInputRaw/dateInputRaw.js +315 -104
- package/dist/dateInputRaw/utils/getLabel.js +38 -7
- package/dist/dateRangeInner/dateRangeInner.js +172 -58
- package/dist/dateRangeRaw/dateRangeRaw.js +601 -239
- package/dist/dateRangeRaw/utils/dateRangeUtils.js +629 -241
- package/dist/dateSelectionWrapper/dateSelectionWrapper.js +152 -14
- package/dist/dialog/dialogContent.js +123 -40
- package/dist/dropdownRaw/dropdownHelper.d.ts +2 -2
- package/dist/dropdownRaw/dropdownHelper.js +9 -9
- package/dist/dropdownRaw/dropdownList.js +447 -78
- package/dist/dropdownRaw/dropdownPopup.js +218 -20
- package/dist/dropdownRaw/dropdownRaw.js +866 -506
- package/dist/dropdownRaw/dropdownSearchableTrigger.js +223 -46
- package/dist/dropdownRaw/stateReducer/stateAction.d.ts +5 -1
- package/dist/dropdownRaw/stateReducer/stateActionType.d.ts +2 -1
- package/dist/dropdownRaw/stateReducer/stateActionType.js +1 -0
- package/dist/dropdownRaw/stateReducer/stateReducer.d.ts +6 -1
- package/dist/dropdownRaw/stateReducer/stateReducer.js +24 -12
- package/dist/dropdownRaw/stateReducer/stateReducerHelper.d.ts +2 -0
- package/dist/dropdownRaw/stateReducer/stateReducerHelper.js +20 -1
- package/dist/dropdownRaw/stateReducer/stateReducerTestData.d.ts +39 -0
- package/dist/dropdownRaw/stateReducer/stateReducerTestData.js +74 -0
- package/dist/dropdownRaw/types.d.ts +1 -0
- package/dist/favoriteButton/favoriteButton.js +59 -10
- package/dist/filters/components/filtersContainer.js +151 -64
- package/dist/filters/components/filtersEmptySelectedList.js +30 -4
- package/dist/filters/components/filtersSaveModal.js +140 -42
- package/dist/filters/components/filtersSavedChipComponent.js +318 -108
- package/dist/filters/components/filtersSearchItemData.js +127 -47
- package/dist/filters/components/filtersSearchList.js +381 -179
- package/dist/filters/components/filtersSelect.js +128 -61
- package/dist/filters/components/filtersSelectListItem.js +125 -13
- package/dist/filters/components/filtersSidePanel.js +510 -178
- package/dist/filters/filters.js +445 -268
- package/dist/filtersBar/components/filtersBarPeriodPicker/getRangeOption.js +729 -272
- package/dist/filtersBar/components/resetComponentButton.js +45 -5
- package/dist/filtersBar/filtersBarActions/filtersBarActions.js +126 -15
- package/dist/filtersBar/filtersBarSidePanel/components/filtersBarSidePanelRange/filtersBarSidePanelRange.js +155 -49
- package/dist/filtersBar/filtersBarSidePanel/filtersBarSidePanel.js +360 -104
- package/dist/filtersBar/filtersContainer/filtersContainer.js +204 -134
- package/dist/formField/components/formFieldWithLabel.d.ts +2 -1
- package/dist/formField/components/formFieldWithLabel.js +3 -2
- package/dist/formField/components/formFieldWithoutLabel.d.ts +2 -1
- package/dist/formField/components/formFieldWithoutLabel.js +3 -3
- package/dist/formField/components/trailingComponent.d.ts +8 -0
- package/dist/formField/components/trailingComponent.js +11 -0
- package/dist/formField/formField.js +12 -11
- package/dist/formField/hooks/useError.js +100 -36
- package/dist/formGroup/components/reviewListToggle/reviewListToggle.js +72 -7
- package/dist/formGroup/hooks/useToggle.js +37 -11
- package/dist/formGroup/utils/getControls.js +8 -7
- package/dist/formLayout/hooks/useError.js +55 -15
- package/dist/formLayout/hooks/useFormButtons.js +128 -27
- package/dist/formSection/components/formSectionModal.js +1 -1
- package/dist/formSection/formSection.js +1 -1
- package/dist/formSection/hooks/useError.js +70 -22
- package/dist/formStepper/components/formStep.js +65 -10
- package/dist/formStepper/formStepper.js +129 -33
- package/dist/formStepperButtons/formStepperButtons.js +184 -38
- package/dist/groupsFilter/groupsHelper.d.ts +1 -1
- package/dist/groupsFilterRaw/groupsFilterAdjustmentState.js +162 -17
- package/dist/groupsFilterRaw/groupsFilterBox.js +137 -32
- package/dist/groupsFilterRaw/groupsFilterCommon.js +75 -8
- package/dist/groupsFilterRaw/groupsFilterCurrentlySelectedState.js +184 -25
- package/dist/groupsFilterRaw/groupsFilterHelper.d.ts +2 -1
- package/dist/groupsFilterRaw/groupsFilterHelper.js +284 -168
- package/dist/groupsFilterRaw/groupsFilterInitialState.js +266 -18
- package/dist/groupsFilterRaw/groupsFilterMenu.js +124 -9
- package/dist/groupsFilterRaw/groupsFilterRaw.d.ts +1 -0
- package/dist/groupsFilterRaw/groupsFilterRaw.js +816 -308
- package/dist/groupsFilterRaw/groupsFilterTestData.d.ts +155 -2
- package/dist/groupsFilterRaw/groupsFilterTestData.js +153 -58
- package/dist/groupsFilterRaw/groupsFilterTrigger.js +139 -35
- package/dist/groupsFilterRaw/groupsHelper.js +739 -208
- package/dist/groupsFilterRaw/stateReducer/stateReducerHelper.js +3 -1
- package/dist/groupsFilterRaw/types.d.ts +1 -0
- package/dist/header/components/collapsedItemsControl/collapsedItemsControl.js +107 -52
- package/dist/header/components/mobileFilterControl/mobileFilterControl.js +62 -9
- package/dist/header/components/mobileSearchControl/mobileSearchControl.js +119 -14
- package/dist/header/headerBack.js +64 -20
- package/dist/index.css +110 -71
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -1
- package/dist/list/itemData/itemDataInternal.js +216 -51
- package/dist/list/listItem/listItem.js +168 -55
- package/dist/menu/components/menuErrorItem.js +33 -5
- package/dist/mobileSheet/mobileSheet.js +195 -69
- package/dist/modal/modal.js +300 -142
- package/dist/nav/nav.js +1 -1
- package/dist/nav/navFooter/navFooter.js +82 -39
- package/dist/nav/navFooter/navFooterAction/navFooterAction.js +52 -13
- package/dist/nav/navHeader/navHeader.js +86 -36
- package/dist/nav/navHeader/navHeaderSearch/navHeaderSearch.js +88 -29
- package/dist/nav/navItem/navItem.d.ts +3 -3
- package/dist/nav/navItem/navItem.js +35 -33
- package/dist/nav/navMobileBar/navMobileBar.js +67 -21
- package/dist/notification/notification.js +124 -21
- package/dist/pagination/paginationArrow.js +81 -11
- package/dist/pagination/paginationText/paginationText.js +45 -11
- package/dist/pill/components/pillNonActionable/pillNonActionable.js +93 -24
- package/dist/pillBox/components/pillBoxItem.js +52 -9
- package/dist/pillBox/pillBox.js +121 -20
- package/dist/pillExpandable/pillExpandable.js +333 -139
- package/dist/rangeRaw/rangeRaw.js +486 -141
- package/dist/rangeRaw/utils/rangeHelper.js +209 -39
- package/dist/searchInputRaw/searchInputRaw.js +180 -65
- package/dist/skeleton/skeleton.js +51 -6
- package/dist/sortControl/sortControl.js +152 -42
- package/dist/stepperRaw/stepperRaw.js +116 -42
- package/dist/summary/summary.js +94 -8
- package/dist/table/actions/actionsMenu.js +171 -78
- package/dist/table/flexible/columnSettings.js +80 -10
- package/dist/table/flexible/columnsList.js +110 -43
- package/dist/table/flexible/columnsPopup.js +77 -20
- package/dist/table/nested/useNestedRows.js +167 -77
- package/dist/table/selectable/selectableHeader.js +180 -41
- package/dist/table/selectable/useSelectableRows.js +270 -191
- package/dist/table/sortable/sortableHeader.js +153 -75
- package/dist/tabs/tabs.js +227 -118
- package/dist/timePickerRaw/timePickerRaw.js +278 -58
- package/dist/toastRaw/toastRaw.js +138 -32
- package/dist/toggleButton/toggleButton.d.ts +0 -1
- package/dist/toggleButtonRaw/toggleButtonRaw.d.ts +1 -0
- package/dist/toggleButtonRaw/toggleButtonRaw.js +146 -40
- package/dist/utils/formatDate.js +1001 -117
- package/{esm/utils/localization/translations/cs-json.js → dist/utils/localization/translations/cs.json} +11 -12
- package/{esm/utils/localization/translations/da-DK-json.js → dist/utils/localization/translations/da-DK.json} +31 -23
- package/{esm/utils/localization/translations/de-json.js → dist/utils/localization/translations/de.json} +12 -13
- package/dist/utils/localization/translations/en.json +308 -0
- package/{esm/utils/localization/translations/es-json.js → dist/utils/localization/translations/es.json} +11 -12
- package/{esm/utils/localization/translations/fi-FI-json.js → dist/utils/localization/translations/fi-FI.json} +31 -23
- package/{esm/utils/localization/translations/fr-FR-json.js → dist/utils/localization/translations/fr-FR.json} +12 -12
- package/{esm/utils/localization/translations/fr-json.js → dist/utils/localization/translations/fr.json} +11 -12
- package/{esm/utils/localization/translations/hu-HU-json.js → dist/utils/localization/translations/hu-HU.json} +31 -23
- package/{esm/utils/localization/translations/id-json.js → dist/utils/localization/translations/id.json} +11 -13
- package/{esm/utils/localization/translations/it-json.js → dist/utils/localization/translations/it.json} +11 -12
- package/{esm/utils/localization/translations/ja-json.js → dist/utils/localization/translations/ja.json} +11 -12
- package/{esm/utils/localization/translations/ko-KR-json.js → dist/utils/localization/translations/ko-KR.json} +24 -23
- package/{esm/utils/localization/translations/ms-json.js → dist/utils/localization/translations/ms.json} +11 -12
- package/{esm/utils/localization/translations/nb-NO-json.js → dist/utils/localization/translations/nb-NO.json} +31 -23
- package/{esm/utils/localization/translations/nl-json.js → dist/utils/localization/translations/nl.json} +11 -12
- package/{esm/utils/localization/translations/pl-json.js → dist/utils/localization/translations/pl.json} +11 -12
- package/{esm/utils/localization/translations/pt-BR-json.js → dist/utils/localization/translations/pt-BR.json} +11 -12
- package/{esm/utils/localization/translations/sk-SK-json.js → dist/utils/localization/translations/sk-SK.json} +31 -23
- package/{esm/utils/localization/translations/sv-json.js → dist/utils/localization/translations/sv.json} +11 -12
- package/{esm/utils/localization/translations/th-json.js → dist/utils/localization/translations/th.json} +11 -12
- package/{esm/utils/localization/translations/tr-json.js → dist/utils/localization/translations/tr.json} +11 -12
- package/{esm/utils/localization/translations/zh-Hans-json.js → dist/utils/localization/translations/zh-Hans.json} +11 -12
- package/{esm/utils/localization/translations/zh-TW-json.js → dist/utils/localization/translations/zh-TW.json} +11 -23
- package/dist/utils/localization/translationsDictionary.d.ts +2 -0
- package/dist/utils/localization/translationsDictionary.js +63 -0
- package/dist/utils/localization/useLanguage.js +2 -74
- package/esm/advancedGroupsFilter/advancedGroupsFilter.js +130 -29
- package/esm/advancedGroupsFilter/advancedGroupsFilterForm.js +133 -33
- package/esm/advancedGroupsFilter/advancedGroupsFilterFormSection.js +317 -65
- package/esm/advancedGroupsFilter/advancedGroupsFilterSectionTooltip.d.ts +0 -1
- package/esm/advancedGroupsFilter/advancedGroupsFilterSectionTooltip.js +77 -8
- package/esm/alertRaw/alertRaw.js +165 -51
- package/esm/banner/bannerMultipLine.js +121 -20
- package/esm/banner/bannerSingleLine.js +100 -13
- package/esm/betaPill/betaPill.js +105 -19
- package/esm/bookmark/bookmark.js +89 -27
- package/esm/bulkEditControl/bulkEditControl.js +161 -33
- package/esm/calendar/calendar.js +937 -272
- package/esm/calendar/calendarUtils.js +151 -84
- package/esm/card/card.js +233 -101
- package/esm/chart/accessibleChart/accessibleChartNarrative.js +642 -554
- package/esm/chart/accessibleChart/accessibleChartTable.js +239 -85
- package/esm/chart/chart.js +30 -20
- package/esm/chart/chartAxis/chartAxis.js +79 -6
- package/esm/checkboxListWithAction/checkboxListWithAction.js +218 -68
- package/esm/chip/chip.js +189 -90
- package/esm/columnsSelector/columnsSelector.js +91 -11
- package/esm/columnsSelector/columnsTab/columnsTab.js +53 -14
- package/esm/columnsSelector/columnsTabGroup/columnsTabGroup.js +75 -33
- package/esm/comboboxSelected/comboboxSelected.js +1 -3
- package/esm/dataFeed/feedExpandControl/feedExpandControl.js +21 -9
- package/esm/dataGrid/columns/checkboxColumn/checkboxHeaderCell.js +86 -10
- package/esm/dataGrid/dataGrid.js +221 -116
- package/esm/dataGrid/emptySearchList/emptySearchList.js +50 -8
- package/esm/dataGrid/entitiesListActions/actions/columnsListButton.js +45 -6
- package/esm/dataGrid/entitiesListActions/actions/fullscreenButton.js +58 -17
- package/esm/dataGrid/withFlexibleColumns/components/columnSettings.js +78 -9
- package/esm/dataGrid/withFlexibleColumns/components/columnSettingsSidePanel.js +44 -15
- package/esm/dataGrid/withSelectableRows/components/bulkActions/bulkActions.js +217 -31
- package/esm/dataGrid/withSelectableRows/withSelectableRows.js +280 -212
- package/esm/dataGrid/withSortableColumns/columns/sortableColumnWrapper.js +172 -94
- package/esm/dateInputInner/dateInputInner.js +785 -475
- package/esm/dateInputInner/dateInputInnerControlBlock.js +119 -21
- package/esm/dateInputRaw/dateInputRaw.js +309 -103
- package/esm/dateInputRaw/utils/getLabel.js +32 -6
- package/esm/dateRangeInner/dateRangeInner.js +166 -57
- package/esm/dateRangeRaw/dateRangeRaw.js +595 -238
- package/esm/dateRangeRaw/utils/dateRangeUtils.js +622 -239
- package/esm/dateSelectionWrapper/dateSelectionWrapper.js +146 -13
- package/esm/dialog/dialogContent.js +117 -39
- package/esm/dropdownRaw/dropdownHelper.d.ts +2 -2
- package/esm/dropdownRaw/dropdownHelper.js +10 -10
- package/esm/dropdownRaw/dropdownList.js +412 -56
- package/esm/dropdownRaw/dropdownPopup.js +212 -19
- package/esm/dropdownRaw/dropdownRaw.js +862 -507
- package/esm/dropdownRaw/dropdownSearchableTrigger.js +217 -45
- package/esm/dropdownRaw/stateReducer/stateAction.d.ts +5 -1
- package/esm/dropdownRaw/stateReducer/stateActionType.d.ts +2 -1
- package/esm/dropdownRaw/stateReducer/stateActionType.js +1 -0
- package/esm/dropdownRaw/stateReducer/stateReducer.d.ts +6 -1
- package/esm/dropdownRaw/stateReducer/stateReducer.js +24 -12
- package/esm/dropdownRaw/stateReducer/stateReducerHelper.d.ts +2 -0
- package/esm/dropdownRaw/stateReducer/stateReducerHelper.js +18 -0
- package/esm/dropdownRaw/stateReducer/stateReducerTestData.d.ts +39 -0
- package/esm/dropdownRaw/stateReducer/stateReducerTestData.js +71 -0
- package/esm/dropdownRaw/types.d.ts +1 -0
- package/esm/favoriteButton/favoriteButton.js +53 -9
- package/esm/filters/components/filtersContainer.js +141 -61
- package/esm/filters/components/filtersEmptySelectedList.js +24 -3
- package/esm/filters/components/filtersSaveModal.js +134 -41
- package/esm/filters/components/filtersSavedChipComponent.js +312 -107
- package/esm/filters/components/filtersSearchItemData.js +121 -46
- package/esm/filters/components/filtersSearchList.js +375 -178
- package/esm/filters/components/filtersSelect.js +122 -60
- package/esm/filters/components/filtersSelectListItem.js +119 -12
- package/esm/filters/components/filtersSidePanel.js +504 -177
- package/esm/filters/filters.js +435 -265
- package/esm/filtersBar/components/filtersBarPeriodPicker/getRangeOption.js +722 -270
- package/esm/filtersBar/components/resetComponentButton.js +39 -4
- package/esm/filtersBar/filtersBarActions/filtersBarActions.js +120 -14
- package/esm/filtersBar/filtersBarSidePanel/components/filtersBarSidePanelRange/filtersBarSidePanelRange.js +149 -48
- package/esm/filtersBar/filtersBarSidePanel/filtersBarSidePanel.js +354 -103
- package/esm/filtersBar/filtersContainer/filtersContainer.js +198 -133
- package/esm/formField/components/formFieldWithLabel.d.ts +2 -1
- package/esm/formField/components/formFieldWithLabel.js +3 -2
- package/esm/formField/components/formFieldWithoutLabel.d.ts +2 -1
- package/esm/formField/components/formFieldWithoutLabel.js +3 -3
- package/esm/formField/components/trailingComponent.d.ts +8 -0
- package/esm/formField/components/trailingComponent.js +7 -0
- package/esm/formField/formField.js +12 -11
- package/esm/formField/hooks/useError.js +94 -35
- package/esm/formGroup/components/reviewListToggle/reviewListToggle.js +66 -6
- package/esm/formGroup/hooks/useToggle.js +31 -10
- package/esm/formGroup/utils/getControls.js +8 -7
- package/esm/formLayout/hooks/useError.js +49 -14
- package/esm/formLayout/hooks/useFormButtons.js +122 -26
- package/esm/formSection/components/formSectionModal.js +1 -1
- package/esm/formSection/formSection.js +1 -1
- package/esm/formSection/hooks/useError.js +64 -21
- package/esm/formStepper/components/formStep.js +59 -9
- package/esm/formStepper/formStepper.js +123 -32
- package/esm/formStepperButtons/formStepperButtons.js +178 -37
- package/esm/groupsFilter/groupsHelper.d.ts +1 -1
- package/esm/groupsFilterRaw/groupsFilterAdjustmentState.js +152 -14
- package/esm/groupsFilterRaw/groupsFilterBox.js +131 -31
- package/esm/groupsFilterRaw/groupsFilterCommon.js +69 -7
- package/esm/groupsFilterRaw/groupsFilterCurrentlySelectedState.js +178 -24
- package/esm/groupsFilterRaw/groupsFilterHelper.d.ts +2 -1
- package/esm/groupsFilterRaw/groupsFilterHelper.js +279 -168
- package/esm/groupsFilterRaw/groupsFilterInitialState.js +260 -17
- package/esm/groupsFilterRaw/groupsFilterMenu.js +118 -8
- package/esm/groupsFilterRaw/groupsFilterRaw.d.ts +1 -0
- package/esm/groupsFilterRaw/groupsFilterRaw.js +811 -308
- package/esm/groupsFilterRaw/groupsFilterTestData.d.ts +155 -2
- package/esm/groupsFilterRaw/groupsFilterTestData.js +152 -57
- package/esm/groupsFilterRaw/groupsFilterTrigger.js +133 -34
- package/esm/groupsFilterRaw/groupsHelper.js +733 -207
- package/esm/groupsFilterRaw/stateReducer/stateReducerHelper.js +3 -1
- package/esm/groupsFilterRaw/types.d.ts +1 -0
- package/esm/header/components/collapsedItemsControl/collapsedItemsControl.js +101 -51
- package/esm/header/components/mobileFilterControl/mobileFilterControl.js +56 -8
- package/esm/header/components/mobileSearchControl/mobileSearchControl.js +113 -13
- package/esm/header/headerBack.js +58 -19
- package/esm/index.d.ts +1 -0
- package/esm/index.js +1 -0
- package/esm/list/itemData/itemDataInternal.js +210 -50
- package/esm/list/listItem/listItem.js +162 -54
- package/esm/menu/components/menuErrorItem.js +27 -4
- package/esm/mobileSheet/mobileSheet.js +189 -68
- package/esm/modal/modal.js +265 -120
- package/esm/nav/nav.js +1 -1
- package/esm/nav/navFooter/navFooter.js +76 -38
- package/esm/nav/navFooter/navFooterAction/navFooterAction.js +46 -12
- package/esm/nav/navHeader/navHeader.js +80 -35
- package/esm/nav/navHeader/navHeaderSearch/navHeaderSearch.js +82 -28
- package/esm/nav/navItem/navItem.d.ts +3 -3
- package/esm/nav/navItem/navItem.js +35 -33
- package/esm/nav/navMobileBar/navMobileBar.js +61 -20
- package/esm/notification/notification.js +114 -18
- package/esm/pagination/paginationArrow.js +75 -10
- package/esm/pagination/paginationText/paginationText.js +39 -10
- package/esm/pill/components/pillNonActionable/pillNonActionable.js +87 -23
- package/esm/pillBox/components/pillBoxItem.js +46 -8
- package/esm/pillBox/pillBox.js +115 -19
- package/esm/pillExpandable/pillExpandable.js +327 -138
- package/esm/rangeRaw/rangeRaw.js +480 -140
- package/esm/rangeRaw/utils/rangeHelper.js +203 -38
- package/esm/searchInputRaw/searchInputRaw.js +145 -43
- package/esm/skeleton/skeleton.js +45 -5
- package/esm/sortControl/sortControl.js +146 -41
- package/esm/stepperRaw/stepperRaw.js +112 -41
- package/esm/storybookHelpers/dataGridWithDifferentCellOptions/components/EntitiesListAction.js +178 -19
- package/esm/summary/summary.js +88 -7
- package/esm/table/actions/actionsMenu.js +165 -77
- package/esm/table/flexible/columnSettings.js +74 -9
- package/esm/table/flexible/columnsList.js +104 -42
- package/esm/table/flexible/columnsPopup.js +71 -19
- package/esm/table/nested/useNestedRows.js +161 -76
- package/esm/table/selectable/selectableHeader.js +174 -40
- package/esm/table/selectable/useSelectableRows.js +264 -190
- package/esm/table/sortable/sortableHeader.js +147 -74
- package/esm/tabs/tabs.js +221 -117
- package/esm/timePickerRaw/timePickerRaw.js +272 -57
- package/esm/toastRaw/toastRaw.js +132 -31
- package/esm/toggleButton/toggleButton.d.ts +0 -1
- package/esm/toggleButtonRaw/toggleButtonRaw.d.ts +1 -0
- package/esm/toggleButtonRaw/toggleButtonRaw.js +111 -18
- package/esm/utils/formatDate.js +995 -116
- package/{dist/utils/localization/translations/cs-json.js → esm/utils/localization/translations/cs.json} +11 -15
- package/{dist/utils/localization/translations/da-DK-json.js → esm/utils/localization/translations/da-DK.json} +31 -26
- package/{dist/utils/localization/translations/de-json.js → esm/utils/localization/translations/de.json} +12 -16
- package/esm/utils/localization/translations/en.json +308 -0
- package/{dist/utils/localization/translations/es-json.js → esm/utils/localization/translations/es.json} +11 -15
- package/{dist/utils/localization/translations/fi-FI-json.js → esm/utils/localization/translations/fi-FI.json} +31 -26
- package/{dist/utils/localization/translations/fr-FR-json.js → esm/utils/localization/translations/fr-FR.json} +12 -15
- package/{dist/utils/localization/translations/fr-json.js → esm/utils/localization/translations/fr.json} +11 -15
- package/{dist/utils/localization/translations/hu-HU-json.js → esm/utils/localization/translations/hu-HU.json} +31 -26
- package/{dist/utils/localization/translations/id-json.js → esm/utils/localization/translations/id.json} +11 -16
- package/{dist/utils/localization/translations/it-json.js → esm/utils/localization/translations/it.json} +11 -15
- package/{dist/utils/localization/translations/ja-json.js → esm/utils/localization/translations/ja.json} +11 -15
- package/{dist/utils/localization/translations/ko-KR-json.js → esm/utils/localization/translations/ko-KR.json} +24 -26
- package/{dist/utils/localization/translations/ms-json.js → esm/utils/localization/translations/ms.json} +11 -15
- package/{dist/utils/localization/translations/nb-NO-json.js → esm/utils/localization/translations/nb-NO.json} +31 -26
- package/{dist/utils/localization/translations/nl-json.js → esm/utils/localization/translations/nl.json} +11 -15
- package/{dist/utils/localization/translations/pl-json.js → esm/utils/localization/translations/pl.json} +11 -15
- package/{dist/utils/localization/translations/pt-BR-json.js → esm/utils/localization/translations/pt-BR.json} +11 -15
- package/{dist/utils/localization/translations/sk-SK-json.js → esm/utils/localization/translations/sk-SK.json} +31 -26
- package/{dist/utils/localization/translations/sv-json.js → esm/utils/localization/translations/sv.json} +11 -15
- package/{dist/utils/localization/translations/th-json.js → esm/utils/localization/translations/th.json} +11 -15
- package/{dist/utils/localization/translations/tr-json.js → esm/utils/localization/translations/tr.json} +11 -15
- package/{dist/utils/localization/translations/zh-Hans-json.js → esm/utils/localization/translations/zh-Hans.json} +11 -15
- package/{dist/utils/localization/translations/zh-TW-json.js → esm/utils/localization/translations/zh-TW.json} +11 -26
- package/esm/utils/localization/translationsDictionary.d.ts +2 -0
- package/esm/utils/localization/translationsDictionary.js +59 -0
- package/esm/utils/localization/useLanguage.js +1 -50
- package/package.json +17 -10
- package/dist/utils/localization/translations/cs-json.d.ts +0 -251
- package/dist/utils/localization/translations/da-DK-json.d.ts +0 -252
- package/dist/utils/localization/translations/de-json.d.ts +0 -251
- package/dist/utils/localization/translations/en-json.d.ts +0 -314
- package/dist/utils/localization/translations/en-json.js +0 -317
- package/dist/utils/localization/translations/es-json.d.ts +0 -251
- package/dist/utils/localization/translations/fi-FI-json.d.ts +0 -252
- package/dist/utils/localization/translations/fr-FR-json.d.ts +0 -250
- package/dist/utils/localization/translations/fr-json.d.ts +0 -251
- package/dist/utils/localization/translations/hu-HU-json.d.ts +0 -252
- package/dist/utils/localization/translations/id-json.d.ts +0 -252
- package/dist/utils/localization/translations/it-json.d.ts +0 -251
- package/dist/utils/localization/translations/ja-json.d.ts +0 -251
- package/dist/utils/localization/translations/ko-KR-json.d.ts +0 -258
- package/dist/utils/localization/translations/ms-json.d.ts +0 -251
- package/dist/utils/localization/translations/nb-NO-json.d.ts +0 -252
- package/dist/utils/localization/translations/nl-json.d.ts +0 -251
- package/dist/utils/localization/translations/pl-json.d.ts +0 -251
- package/dist/utils/localization/translations/pt-BR-json.d.ts +0 -251
- package/dist/utils/localization/translations/sk-SK-json.d.ts +0 -251
- package/dist/utils/localization/translations/sv-json.d.ts +0 -251
- package/dist/utils/localization/translations/th-json.d.ts +0 -251
- package/dist/utils/localization/translations/tr-json.d.ts +0 -251
- package/dist/utils/localization/translations/zh-Hans-json.d.ts +0 -251
- package/dist/utils/localization/translations/zh-TW-json.d.ts +0 -271
- package/esm/utils/localization/translations/cs-json.d.ts +0 -251
- package/esm/utils/localization/translations/da-DK-json.d.ts +0 -252
- package/esm/utils/localization/translations/de-json.d.ts +0 -251
- package/esm/utils/localization/translations/en-json.d.ts +0 -314
- package/esm/utils/localization/translations/en-json.js +0 -314
- package/esm/utils/localization/translations/es-json.d.ts +0 -251
- package/esm/utils/localization/translations/fi-FI-json.d.ts +0 -252
- package/esm/utils/localization/translations/fr-FR-json.d.ts +0 -250
- package/esm/utils/localization/translations/fr-json.d.ts +0 -251
- package/esm/utils/localization/translations/hu-HU-json.d.ts +0 -252
- package/esm/utils/localization/translations/id-json.d.ts +0 -252
- package/esm/utils/localization/translations/it-json.d.ts +0 -251
- package/esm/utils/localization/translations/ja-json.d.ts +0 -251
- package/esm/utils/localization/translations/ko-KR-json.d.ts +0 -258
- package/esm/utils/localization/translations/ms-json.d.ts +0 -251
- package/esm/utils/localization/translations/nb-NO-json.d.ts +0 -252
- package/esm/utils/localization/translations/nl-json.d.ts +0 -251
- package/esm/utils/localization/translations/pl-json.d.ts +0 -251
- package/esm/utils/localization/translations/pt-BR-json.d.ts +0 -251
- package/esm/utils/localization/translations/sk-SK-json.d.ts +0 -251
- package/esm/utils/localization/translations/sv-json.d.ts +0 -251
- package/esm/utils/localization/translations/th-json.d.ts +0 -251
- package/esm/utils/localization/translations/tr-json.d.ts +0 -251
- package/esm/utils/localization/translations/zh-Hans-json.d.ts +0 -251
- package/esm/utils/localization/translations/zh-TW-json.d.ts +0 -271
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { injectString } from "../../utils/localization/translationsDictionary";
|
|
1
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
3
|
import { useLanguage } from "../../utils/localization/useLanguage";
|
|
3
4
|
import { useCallback, useContext, useMemo } from "react";
|
|
@@ -8,592 +9,679 @@ import { getFormattedLabel } from "../utils/getFormattedLabel";
|
|
|
8
9
|
import { truncateDecimals } from "../../utils/truncateDecimals";
|
|
9
10
|
import { calculateMinTruncationPrecision } from "../utils/calculateMinTruncationPrecision";
|
|
10
11
|
import { removeTrendDataFromDatasets } from "../utils/removeTrendDataFromDatasets";
|
|
12
|
+
injectString("cs", "Data", "Data");
|
|
13
|
+
injectString("da-DK", "Data", "Data");
|
|
14
|
+
injectString("de", "Data", "Daten");
|
|
15
|
+
injectString("en", "Data", "Data");
|
|
16
|
+
injectString("es", "Data", "Datos");
|
|
17
|
+
injectString("fi-FI", "Data", "Data");
|
|
18
|
+
injectString("fr", "Data", "Donn\xE9es");
|
|
19
|
+
injectString("fr-FR", "Data", "Donn\xE9es");
|
|
20
|
+
injectString("hu-HU", "Data", "Adatok");
|
|
21
|
+
injectString("id", "Data", "Data");
|
|
22
|
+
injectString("it", "Data", "Dati");
|
|
23
|
+
injectString("ja", "Data", "\u30C7\u30FC\u30BF");
|
|
24
|
+
injectString("ko-KR", "Data", "\uB370\uC774\uD130");
|
|
25
|
+
injectString("ms", "Data", "Data");
|
|
26
|
+
injectString("nb-NO", "Data", "Data");
|
|
27
|
+
injectString("nl", "Data", "Gegevens");
|
|
28
|
+
injectString("pl", "Data", "Dane");
|
|
29
|
+
injectString("pt-BR", "Data", "Dados");
|
|
30
|
+
injectString("sk-SK", "Data", "D\xE1ta");
|
|
31
|
+
injectString("sv", "Data", "Data");
|
|
32
|
+
injectString("th", "Data", "\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25");
|
|
33
|
+
injectString("tr", "Data", "Veri");
|
|
34
|
+
injectString("zh-Hans", "Data", "\u6570\u636E");
|
|
35
|
+
injectString("zh-TW", "Data", "\u8CC7\u6599");
|
|
36
|
+
injectString("en", "switched {TRANSITIONS} times between two states: {STATE1} and {STATE2}.", "switched {TRANSITIONS} times between two states: {STATE1} and {STATE2}.");
|
|
37
|
+
injectString("en", "Highest point(s):", "Highest point(s):");
|
|
38
|
+
injectString("en", "Lowest point(s):", "Lowest point(s):");
|
|
39
|
+
injectString("en", "Segment {INDEX} {DIRECTION} from {FROM} at {X0} to {TO} at {X}.", "Segment {INDEX} {DIRECTION} from {FROM} at {X0} to {TO} at {X}.");
|
|
40
|
+
injectString("en", "shows a complex trend with multiple segments:", "shows a complex trend with multiple segments:");
|
|
41
|
+
injectString("cs", "No data available", "Nejsou k\xA0dispozici \u017E\xE1dn\xE1 data");
|
|
42
|
+
injectString("da-DK", "No data available", "Ingen data tilg\xE6ngelige");
|
|
43
|
+
injectString("de", "No data available", "Keine Daten verf\xFCgbar");
|
|
44
|
+
injectString("en", "No data available", "No data available");
|
|
45
|
+
injectString("es", "No data available", "No hay datos disponibles");
|
|
46
|
+
injectString("fi-FI", "No data available", "Tietoja ei saatavilla");
|
|
47
|
+
injectString("fr", "No data available", "Aucune donn\xE9e disponible");
|
|
48
|
+
injectString("fr-FR", "No data available", "Aucune donn\xE9e disponible");
|
|
49
|
+
injectString("hu-HU", "No data available", "Nincsenek rendelkez\xE9sre \xE1ll\xF3 adatok");
|
|
50
|
+
injectString("id", "No data available", "Tidak ada data tersedia");
|
|
51
|
+
injectString("it", "No data available", "Nessun dato disponibile");
|
|
52
|
+
injectString("ja", "No data available", "\u30C7\u30FC\u30BF\u304C\u3042\u308A\u307E\u305B\u3093");
|
|
53
|
+
injectString("ko-KR", "No data available", "\uC0AC\uC6A9 \uAC00\uB2A5\uD55C \uB370\uC774\uD130\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
54
|
+
injectString("ms", "No data available", "Tiada data tersedia");
|
|
55
|
+
injectString("nb-NO", "No data available", "Ingen data tilgjengelig");
|
|
56
|
+
injectString("nl", "No data available", "Geen gegevens beschikbaar");
|
|
57
|
+
injectString("pl", "No data available", "Brak dost\u0119pnych danych");
|
|
58
|
+
injectString("pt-BR", "No data available", "Nenhum dado dispon\xEDvel");
|
|
59
|
+
injectString("sk-SK", "No data available", "Nie s\xFA k dispoz\xEDcii \u017Eiadne \xFAdaje");
|
|
60
|
+
injectString("sv", "No data available", "Det finns inga tillg\xE4ngliga data");
|
|
61
|
+
injectString("th", "No data available", "\u0E44\u0E21\u0E48\u0E21\u0E35\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25");
|
|
62
|
+
injectString("tr", "No data available", "Mevcut veri yok");
|
|
63
|
+
injectString("zh-Hans", "No data available", "\u65E0\u53EF\u7528\u6570\u636E");
|
|
64
|
+
injectString("zh-TW", "No data available", "\u6C92\u6709\u53EF\u7528\u8CC7\u6599");
|
|
65
|
+
injectString("en", "Only one data point: value is {VALUE}.", "Only one data point: value is {VALUE}.");
|
|
66
|
+
injectString("en", "Average value is:", "Average value is:");
|
|
67
|
+
injectString("en", "shows a relatively flat or stable trend.", "shows a relatively flat or stable trend.");
|
|
68
|
+
injectString("en", "value changes in the range from {MIN} to {MAX}.", "value changes in the range from {MIN} to {MAX}.");
|
|
69
|
+
injectString("en", "from {FROM} at {X0} to {TO} at {X}.", "from {FROM} at {X0} to {TO} at {X}.");
|
|
70
|
+
injectString("en", "Error generating chart narrative for dataset", "Error generating chart narrative for dataset");
|
|
11
71
|
export function collectAllPoints(dataset, dateFormatter, miniChartLabels, options) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
72
|
+
if (dataset.data.length === 0) {
|
|
73
|
+
return [];
|
|
74
|
+
}
|
|
75
|
+
// Minichart data processing
|
|
76
|
+
if (miniChartLabels) {
|
|
77
|
+
return dataset.data.map((value, index) => ({
|
|
78
|
+
x: index,
|
|
79
|
+
y: typeof value === "number" ? value : 0,
|
|
80
|
+
originX: index === 0 ? miniChartLabels[0] : index === dataset.data.length - 1 ? miniChartLabels[miniChartLabels.length - 1] : index
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
83
|
+
// Standard chart data processing
|
|
84
|
+
const allPoints = [];
|
|
85
|
+
for (const [index, point] of dataset.data.entries()) {
|
|
86
|
+
if (typeof point !== "object" || point === null || !("y" in point)) {
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
let xNumeric;
|
|
90
|
+
let originX;
|
|
91
|
+
const rawXValue = point.x;
|
|
92
|
+
if (rawXValue instanceof Date || typeof rawXValue === "string" && isDateString(rawXValue)) {
|
|
93
|
+
xNumeric = new Date(rawXValue).getTime();
|
|
94
|
+
originX = getFormattedLabel(rawXValue, dateFormatter, options);
|
|
95
|
+
} else if (typeof rawXValue === "number") {
|
|
96
|
+
xNumeric = rawXValue;
|
|
97
|
+
originX = rawXValue;
|
|
98
|
+
} else {
|
|
99
|
+
xNumeric = index;
|
|
100
|
+
originX = rawXValue;
|
|
101
|
+
}
|
|
102
|
+
allPoints.push({
|
|
103
|
+
x: xNumeric,
|
|
104
|
+
y: point.y || 0,
|
|
105
|
+
originX
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
return allPoints;
|
|
47
109
|
}
|
|
48
110
|
export function simplifyData(data) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
// Filter points by trend change and relative height
|
|
124
|
-
const significantExtremums = [];
|
|
125
|
-
const strengthThreshold = 0.50;
|
|
126
|
-
const yValues = data.filter(p => p.y !== null).map(p => p.y);
|
|
127
|
-
const minY = yValues.reduce((min, current) => Math.min(min, current));
|
|
128
|
-
const maxY = yValues.reduce((max, current) => Math.max(max, current));
|
|
129
|
-
const datasetRange = maxY - minY;
|
|
130
|
-
// Proceed only if there is a range to avoid division by zero
|
|
131
|
-
if (datasetRange > 0) {
|
|
132
|
-
for (let i = 1; i < scoredData.length - 1; i++) {
|
|
133
|
-
const prev = scoredData[i - 1];
|
|
134
|
-
const current = scoredData[i];
|
|
135
|
-
const next = scoredData[i + 1];
|
|
136
|
-
// Check for a peak in the 'peakHeight' values
|
|
137
|
-
const isPeak = current.peakHeight > prev.peakHeight && current.peakHeight > next.peakHeight;
|
|
138
|
-
// Check for a peak in the 'valleyHeight' values
|
|
139
|
-
const isValley = current.valleyHeight > prev.valleyHeight && current.valleyHeight > next.valleyHeight;
|
|
140
|
-
if (isPeak) {
|
|
141
|
-
const relHeight = current.peakHeight / datasetRange;
|
|
142
|
-
if (relHeight >= strengthThreshold && current.peakDominance > 2) {
|
|
143
|
-
significantExtremums.push(current.point);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
else if (isValley) {
|
|
147
|
-
const relHeight = current.valleyHeight / datasetRange;
|
|
148
|
-
if (relHeight >= strengthThreshold && current.valleyDominance > 2) {
|
|
149
|
-
significantExtremums.push(current.point);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
const uniquePointsSet = new Set();
|
|
155
|
-
const finalResult = [];
|
|
156
|
-
const addPointIfUnique = (point) => {
|
|
157
|
-
// using a composite key for uniqueness
|
|
158
|
-
const key = `${point.x.toString()}-${point.y || ""}`;
|
|
159
|
-
if (!uniquePointsSet.has(key)) {
|
|
160
|
-
uniquePointsSet.add(key);
|
|
161
|
-
finalResult.push(point);
|
|
162
|
-
}
|
|
111
|
+
// Need at least 3 points to find a peak or valley
|
|
112
|
+
if (data.length < 3) {
|
|
113
|
+
return data;
|
|
114
|
+
}
|
|
115
|
+
// Calculate Potential Peak/Valley Height and Dominance for Every Point
|
|
116
|
+
const scoredData = data.map((currentPoint, i) => {
|
|
117
|
+
if (currentPoint.y === null) {
|
|
118
|
+
return {
|
|
119
|
+
point: currentPoint,
|
|
120
|
+
peakHeight: 0,
|
|
121
|
+
valleyHeight: 0,
|
|
122
|
+
peakDominance: 0,
|
|
123
|
+
valleyDominance: 0
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
let peakHeight = 0;
|
|
127
|
+
let valleyHeight = 0;
|
|
128
|
+
let peakDominance = 0;
|
|
129
|
+
let valleyDominance = 0;
|
|
130
|
+
let localMinForPeak = currentPoint.y;
|
|
131
|
+
// Scan left
|
|
132
|
+
for (let j = i - 1; j >= 0; j--) {
|
|
133
|
+
const point = data[j];
|
|
134
|
+
if (point.y !== null && point.y < currentPoint.y) {
|
|
135
|
+
localMinForPeak = Math.min(localMinForPeak, point.y);
|
|
136
|
+
peakDominance++;
|
|
137
|
+
} else {
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
// Scan right
|
|
142
|
+
for (let j = i + 1; j < data.length; j++) {
|
|
143
|
+
const point = data[j];
|
|
144
|
+
if (point.y !== null && point.y < currentPoint.y) {
|
|
145
|
+
localMinForPeak = Math.min(localMinForPeak, point.y);
|
|
146
|
+
peakDominance++;
|
|
147
|
+
} else {
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (peakDominance > 0) {
|
|
152
|
+
peakHeight = currentPoint.y - localMinForPeak;
|
|
153
|
+
}
|
|
154
|
+
// Calculate Valley Height & Dominance
|
|
155
|
+
let localMaxForValley = currentPoint.y;
|
|
156
|
+
// Scan left
|
|
157
|
+
for (let j = i - 1; j >= 0; j--) {
|
|
158
|
+
const point = data[j];
|
|
159
|
+
if (point.y !== null && point.y > currentPoint.y) {
|
|
160
|
+
localMaxForValley = Math.max(localMaxForValley, point.y);
|
|
161
|
+
valleyDominance++;
|
|
162
|
+
} else {
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
// Scan right
|
|
167
|
+
for (let j = i + 1; j < data.length; j++) {
|
|
168
|
+
const point = data[j];
|
|
169
|
+
if (point.y !== null && point.y > currentPoint.y) {
|
|
170
|
+
localMaxForValley = Math.max(localMaxForValley, point.y);
|
|
171
|
+
valleyDominance++;
|
|
172
|
+
} else {
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (valleyDominance > 0) {
|
|
177
|
+
valleyHeight = localMaxForValley - currentPoint.y;
|
|
178
|
+
}
|
|
179
|
+
return {
|
|
180
|
+
point: currentPoint,
|
|
181
|
+
peakHeight,
|
|
182
|
+
valleyHeight,
|
|
183
|
+
peakDominance,
|
|
184
|
+
valleyDominance
|
|
163
185
|
};
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
};
|
|
187
|
-
const immutablePoints = [data[0], data[data.length - 1], globalMinPoint, globalMaxPoint].filter(Boolean);
|
|
188
|
-
for (let i = 1; i < finalResult.length - 1; i++) {
|
|
189
|
-
const current = finalResult[i];
|
|
190
|
-
// Skip removal if the current point is one of the designated immutable points
|
|
191
|
-
if (immutablePoints.some(p => p && p.x === current.x && p.y === current.y)) {
|
|
192
|
-
continue;
|
|
186
|
+
});
|
|
187
|
+
// Filter points by trend change and relative height
|
|
188
|
+
const significantExtremums = [];
|
|
189
|
+
const strengthThreshold = 0.50;
|
|
190
|
+
const yValues = data.filter(p => p.y !== null).map(p => p.y);
|
|
191
|
+
const minY = yValues.reduce((min, current) => Math.min(min, current));
|
|
192
|
+
const maxY = yValues.reduce((max, current) => Math.max(max, current));
|
|
193
|
+
const datasetRange = maxY - minY;
|
|
194
|
+
// Proceed only if there is a range to avoid division by zero
|
|
195
|
+
if (datasetRange > 0) {
|
|
196
|
+
for (let i = 1; i < scoredData.length - 1; i++) {
|
|
197
|
+
const prev = scoredData[i - 1];
|
|
198
|
+
const current = scoredData[i];
|
|
199
|
+
const next = scoredData[i + 1];
|
|
200
|
+
// Check for a peak in the 'peakHeight' values
|
|
201
|
+
const isPeak = current.peakHeight > prev.peakHeight && current.peakHeight > next.peakHeight;
|
|
202
|
+
// Check for a peak in the 'valleyHeight' values
|
|
203
|
+
const isValley = current.valleyHeight > prev.valleyHeight && current.valleyHeight > next.valleyHeight;
|
|
204
|
+
if (isPeak) {
|
|
205
|
+
const relHeight = current.peakHeight / datasetRange;
|
|
206
|
+
if (relHeight >= strengthThreshold && current.peakDominance > 2) {
|
|
207
|
+
significantExtremums.push(current.point);
|
|
193
208
|
}
|
|
194
|
-
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
const squares = [squareWithPoint, squareWithoutPoint].sort((a, b) => a - b);
|
|
199
|
-
const squareRatio = squares[0] / squares[1];
|
|
200
|
-
if (squareRatio > 0.9) {
|
|
201
|
-
// remove insignificant point
|
|
202
|
-
finalResult.splice(i, 1);
|
|
203
|
-
i--;
|
|
209
|
+
} else if (isValley) {
|
|
210
|
+
const relHeight = current.valleyHeight / datasetRange;
|
|
211
|
+
if (relHeight >= strengthThreshold && current.valleyDominance > 2) {
|
|
212
|
+
significantExtremums.push(current.point);
|
|
204
213
|
}
|
|
205
|
-
|
|
206
|
-
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
const uniquePointsSet = new Set();
|
|
218
|
+
const finalResult = [];
|
|
219
|
+
const addPointIfUnique = point => {
|
|
220
|
+
// using a composite key for uniqueness
|
|
221
|
+
const key = `${point.x.toString()}-${point.y || ""}`;
|
|
222
|
+
if (!uniquePointsSet.has(key)) {
|
|
223
|
+
uniquePointsSet.add(key);
|
|
224
|
+
finalResult.push(point);
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
// Add key points to the array
|
|
228
|
+
addPointIfUnique(data[0]);
|
|
229
|
+
addPointIfUnique(data[data.length - 1]);
|
|
230
|
+
const globalMinPoint = data.find(p => p.y === minY);
|
|
231
|
+
if (globalMinPoint) {
|
|
232
|
+
addPointIfUnique(globalMinPoint);
|
|
233
|
+
}
|
|
234
|
+
const globalMaxPoint = data.find(p => p.y === maxY);
|
|
235
|
+
if (globalMaxPoint) {
|
|
236
|
+
addPointIfUnique(globalMaxPoint);
|
|
237
|
+
}
|
|
238
|
+
// Add other significant extremums
|
|
239
|
+
significantExtremums.forEach(addPointIfUnique);
|
|
240
|
+
// Sort the final result array chronologically
|
|
241
|
+
finalResult.sort((a, b) => new Date(a.x).getTime() - new Date(b.x).getTime());
|
|
242
|
+
// Filter out non-significant points based on area under the curve
|
|
243
|
+
const getSquare = (p1, p2) => {
|
|
244
|
+
const x1 = new Date(p1.x).getTime();
|
|
245
|
+
const x2 = new Date(p2.x).getTime();
|
|
246
|
+
const y1 = p1.y;
|
|
247
|
+
const y2 = p2.y;
|
|
248
|
+
return (x2 - x1) * (y1 + (y2 - y1) / 2);
|
|
249
|
+
};
|
|
250
|
+
const immutablePoints = [data[0], data[data.length - 1], globalMinPoint, globalMaxPoint].filter(Boolean);
|
|
251
|
+
for (let i = 1; i < finalResult.length - 1; i++) {
|
|
252
|
+
const current = finalResult[i];
|
|
253
|
+
// Skip removal if the current point is one of the designated immutable points
|
|
254
|
+
if (immutablePoints.some(p => p && p.x === current.x && p.y === current.y)) {
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
const prev = finalResult[i - 1];
|
|
258
|
+
const next = finalResult[i + 1];
|
|
259
|
+
const squareWithPoint = getSquare(prev, current) + getSquare(current, next);
|
|
260
|
+
const squareWithoutPoint = getSquare(prev, next);
|
|
261
|
+
const squares = [squareWithPoint, squareWithoutPoint].sort((a, b) => a - b);
|
|
262
|
+
const squareRatio = squares[0] / squares[1];
|
|
263
|
+
if (squareRatio > 0.9) {
|
|
264
|
+
// remove insignificant point
|
|
265
|
+
finalResult.splice(i, 1);
|
|
266
|
+
i--;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return finalResult;
|
|
207
270
|
}
|
|
208
271
|
function getTrendDirectionBySlope(slope) {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
272
|
+
const slopeThreshold = 1e-10;
|
|
273
|
+
if (slope > slopeThreshold) {
|
|
274
|
+
return "increases";
|
|
275
|
+
}
|
|
276
|
+
if (slope < -slopeThreshold) {
|
|
277
|
+
return "decreases";
|
|
278
|
+
}
|
|
279
|
+
return "flat";
|
|
217
280
|
}
|
|
218
281
|
function calculateLinearRegression(points) {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
282
|
+
if (points.length < 2) {
|
|
283
|
+
return {
|
|
284
|
+
slope: NaN,
|
|
285
|
+
yIntercept: NaN
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
const sumX = points.reduce((sum, p) => sum + p.x, 0);
|
|
289
|
+
const sumY = points.reduce((sum, p) => sum + p.y, 0);
|
|
290
|
+
const meanX = sumX / points.length;
|
|
291
|
+
const meanY = sumY / points.length;
|
|
292
|
+
let numerator = 0;
|
|
293
|
+
let denominator = 0;
|
|
294
|
+
for (const p of points) {
|
|
295
|
+
numerator += (p.x - meanX) * (p.y - meanY);
|
|
296
|
+
denominator += (p.x - meanX) * (p.x - meanX);
|
|
297
|
+
}
|
|
298
|
+
const slope = denominator === 0 ? 0 : numerator / denominator;
|
|
299
|
+
const yIntercept = meanY - slope * meanX;
|
|
300
|
+
return {
|
|
301
|
+
slope,
|
|
302
|
+
yIntercept
|
|
303
|
+
};
|
|
235
304
|
}
|
|
236
305
|
function detectTwoStateChart(dataset, translate, dateFormatter, miniChartLabels, options) {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
.replace("{STATE2}", truncateDecimals(val2, decimalLength).toString())
|
|
268
|
-
.replace("{TRANSITIONS}", transitions.toString())}`;
|
|
269
|
-
return summary;
|
|
306
|
+
const allPoints = collectAllPoints(dataset, dateFormatter, miniChartLabels, options);
|
|
307
|
+
if (allPoints.length <= 2) {
|
|
308
|
+
return false;
|
|
309
|
+
}
|
|
310
|
+
const datasetName = dataset.label || translate("Data");
|
|
311
|
+
const uniqueYValues = new Set();
|
|
312
|
+
const tolerance = 1e-6;
|
|
313
|
+
for (const point of allPoints) {
|
|
314
|
+
uniqueYValues.add(point.y);
|
|
315
|
+
if (uniqueYValues.size > 2) {
|
|
316
|
+
return false;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
const isTwoState = uniqueYValues.size === 2;
|
|
320
|
+
if (!isTwoState) {
|
|
321
|
+
return false;
|
|
322
|
+
}
|
|
323
|
+
// Count state transitions
|
|
324
|
+
let transitions = 0;
|
|
325
|
+
for (let i = 1; i < allPoints.length; i++) {
|
|
326
|
+
const prevValue = allPoints[i - 1].y;
|
|
327
|
+
const currentValue = allPoints[i].y;
|
|
328
|
+
if (Math.abs(prevValue - currentValue) > tolerance) {
|
|
329
|
+
transitions++;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
const [val1, val2] = uniqueYValues;
|
|
333
|
+
const decimalLength = calculateMinTruncationPrecision([val1, val2]);
|
|
334
|
+
const summary = `${datasetName} ${translate("switched {TRANSITIONS} times between two states: {STATE1} and {STATE2}.").replace("{STATE1}", truncateDecimals(val1, decimalLength).toString()).replace("{STATE2}", truncateDecimals(val2, decimalLength).toString()).replace("{TRANSITIONS}", transitions.toString())}`;
|
|
335
|
+
return summary;
|
|
270
336
|
}
|
|
271
337
|
// Calculates the Median Absolute Deviation (MAD) for a given array of numbers.
|
|
272
338
|
function calculateMAD(data, scaleFactor = 1.4826) {
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
}
|
|
296
|
-
return mad * scaleFactor;
|
|
339
|
+
if (data.length === 0) {
|
|
340
|
+
return 0;
|
|
341
|
+
}
|
|
342
|
+
// Sort the data to find the median
|
|
343
|
+
const sortedData = [...data].sort((a, b) => a - b);
|
|
344
|
+
const mid = Math.floor(sortedData.length / 2);
|
|
345
|
+
let median;
|
|
346
|
+
if (sortedData.length % 2 === 0) {
|
|
347
|
+
median = (sortedData[mid - 1] + sortedData[mid]) / 2;
|
|
348
|
+
} else {
|
|
349
|
+
median = sortedData[mid];
|
|
350
|
+
}
|
|
351
|
+
// Calculate absolute deviations from the median
|
|
352
|
+
const deviations = sortedData.map(d => Math.abs(d - median));
|
|
353
|
+
let mad;
|
|
354
|
+
const madMid = Math.floor(deviations.length / 2);
|
|
355
|
+
if (deviations.length % 2 === 0) {
|
|
356
|
+
mad = (deviations[madMid - 1] + deviations[madMid]) / 2;
|
|
357
|
+
} else {
|
|
358
|
+
mad = deviations[madMid];
|
|
359
|
+
}
|
|
360
|
+
return mad * scaleFactor;
|
|
297
361
|
}
|
|
298
362
|
function getInliersForSmallSet(allPoints) {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
363
|
+
// Only proceed if there are enough points to perform exclusion
|
|
364
|
+
if (allPoints.length < 3) {
|
|
365
|
+
return allPoints;
|
|
366
|
+
}
|
|
367
|
+
const initialLr = calculateLinearRegression(allPoints);
|
|
368
|
+
const initialResiduals = allPoints.map(point => ({
|
|
369
|
+
point,
|
|
370
|
+
residual: Math.abs(point.y - (initialLr.slope * point.x + initialLr.yIntercept))
|
|
371
|
+
}));
|
|
372
|
+
// Sort to put the worst-fitting point (largest residual) first
|
|
373
|
+
initialResiduals.sort((a, b) => b.residual - a.residual);
|
|
374
|
+
// Exclude the top residual (the potential outlier) and return the rest as inliers.
|
|
375
|
+
return initialResiduals.slice(1).map(r => r.point);
|
|
312
376
|
}
|
|
313
377
|
function getInliersForLargeSet(allPoints, initialLr) {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
return pointsForRobustLr;
|
|
378
|
+
const initialResiduals = allPoints.map(point => {
|
|
379
|
+
const predictedY = initialLr.slope * point.x + initialLr.yIntercept;
|
|
380
|
+
return point.y - predictedY;
|
|
381
|
+
});
|
|
382
|
+
const madOfInitialResiduals = calculateMAD(initialResiduals);
|
|
383
|
+
const strictInlierFilter = 1.5;
|
|
384
|
+
const pointsForRobustLr = [];
|
|
385
|
+
if (madOfInitialResiduals > 1e-9) {
|
|
386
|
+
for (let i = 0; i < allPoints.length; i++) {
|
|
387
|
+
if (Math.abs(initialResiduals[i]) <= strictInlierFilter * madOfInitialResiduals) {
|
|
388
|
+
pointsForRobustLr.push(allPoints[i]);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
} else {
|
|
392
|
+
// If no spread, use all points.
|
|
393
|
+
pointsForRobustLr.push(...allPoints);
|
|
394
|
+
}
|
|
395
|
+
return pointsForRobustLr;
|
|
333
396
|
}
|
|
334
397
|
function detectSignificantDeviations(allPoints, translate, decimalLength, deviationThreshold = 2) {
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
const
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
398
|
+
if (allPoints.length < 3) {
|
|
399
|
+
return null;
|
|
400
|
+
}
|
|
401
|
+
let pointsForRobustLr = [];
|
|
402
|
+
let initialLr = null;
|
|
403
|
+
// If the dataset is tiny (where MAD-based filtering is most fragile)
|
|
404
|
+
if (allPoints.length <= 5) {
|
|
405
|
+
pointsForRobustLr = getInliersForSmallSet(allPoints);
|
|
406
|
+
} else {
|
|
407
|
+
initialLr = calculateLinearRegression(allPoints);
|
|
408
|
+
pointsForRobustLr = getInliersForLargeSet(allPoints, initialLr);
|
|
409
|
+
}
|
|
410
|
+
let finalSlope;
|
|
411
|
+
let finalYIntercept;
|
|
412
|
+
// Use the determined pointsForRobustLr for the final regression
|
|
413
|
+
if (pointsForRobustLr.length < 2) {
|
|
414
|
+
console.warn("Not enough points for robust regression, falling back to all points.");
|
|
415
|
+
if (!initialLr) {
|
|
416
|
+
initialLr = calculateLinearRegression(allPoints);
|
|
417
|
+
}
|
|
418
|
+
finalSlope = initialLr.slope;
|
|
419
|
+
finalYIntercept = initialLr.yIntercept;
|
|
420
|
+
} else {
|
|
421
|
+
const robustLr = calculateLinearRegression(pointsForRobustLr);
|
|
422
|
+
finalSlope = robustLr.slope;
|
|
423
|
+
finalYIntercept = robustLr.yIntercept;
|
|
424
|
+
}
|
|
425
|
+
// Calculate Final Residuals for ALL Original Points against the Robust Line
|
|
426
|
+
const pointsWithFinalResiduals = allPoints.map(point => {
|
|
427
|
+
const predictedYRobust = finalSlope * point.x + finalYIntercept;
|
|
428
|
+
const residual = point.y - predictedYRobust;
|
|
429
|
+
return Object.assign(Object.assign({}, point), {
|
|
430
|
+
residual: residual,
|
|
431
|
+
isSignificantlyHigh: false,
|
|
432
|
+
isSignificantlyLow: false
|
|
369
433
|
});
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
434
|
+
});
|
|
435
|
+
const finalResidualsForDetection = pointsWithFinalResiduals.map(p => p.residual);
|
|
436
|
+
const robustResidualSpread = calculateMAD(finalResidualsForDetection);
|
|
437
|
+
const SMALL_TOLERANCE = 1e-9;
|
|
438
|
+
let effectiveDeviationMeasure = robustResidualSpread;
|
|
439
|
+
const isSmallSet = allPoints.length <= 5;
|
|
440
|
+
// Calculate the Y-range of the final data set for absolute thresholding
|
|
441
|
+
const yValues = allPoints.map(p => p.y);
|
|
442
|
+
const yMin = yValues.reduce((min, current) => Math.min(min, current), Infinity);
|
|
443
|
+
const yMax = yValues.reduce((max, current) => Math.max(max, current), -Infinity);
|
|
444
|
+
const yRange = yMax - yMin;
|
|
445
|
+
// Set a very low absolute residual floor (e.g., 5% of the total range)
|
|
446
|
+
const ABS_RESIDUAL_FLOOR = yRange * 0.05; // 5% of range
|
|
447
|
+
if (effectiveDeviationMeasure < SMALL_TOLERANCE) {
|
|
448
|
+
const maxResidual = finalResidualsForDetection.reduce((max, current) => Math.max(max, Math.abs(current)), 0);
|
|
449
|
+
effectiveDeviationMeasure = maxResidual > SMALL_TOLERANCE ? maxResidual / (deviationThreshold + SMALL_TOLERANCE) : 0;
|
|
450
|
+
} else if (isSmallSet) {
|
|
451
|
+
// Aggressively reduce the spread measure for small sets with non-zero MAD
|
|
452
|
+
effectiveDeviationMeasure = effectiveDeviationMeasure / 1.5;
|
|
453
|
+
}
|
|
454
|
+
const significantDeviations = [];
|
|
455
|
+
// Detect Significant Deviations using the robust spread
|
|
456
|
+
if (effectiveDeviationMeasure > SMALL_TOLERANCE) {
|
|
457
|
+
for (const pointWithRes of pointsWithFinalResiduals) {
|
|
458
|
+
const isSignificantByMAD = Math.abs(pointWithRes.residual) > deviationThreshold * effectiveDeviationMeasure;
|
|
459
|
+
const isSignificantByFloor = Math.abs(pointWithRes.residual) > ABS_RESIDUAL_FLOOR;
|
|
460
|
+
if (isSignificantByMAD || isSignificantByFloor) {
|
|
461
|
+
significantDeviations.push(Object.assign(Object.assign({}, pointWithRes), {
|
|
462
|
+
isSignificantlyHigh: pointWithRes.residual > 0,
|
|
463
|
+
isSignificantlyLow: pointWithRes.residual < 0
|
|
464
|
+
}));
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
// Check for Absolute Maximum Inclusion
|
|
469
|
+
const maxIsIncluded = significantDeviations.some(sd => sd.y === yMax);
|
|
470
|
+
if (!maxIsIncluded) {
|
|
471
|
+
const maxPoint = allPoints.find(p => p.y === yMax);
|
|
472
|
+
if (maxPoint) {
|
|
473
|
+
// Flag the absolute max as a significant deviation if it was missed
|
|
474
|
+
significantDeviations.push(Object.assign(Object.assign({}, maxPoint), {
|
|
475
|
+
residual: maxPoint.y - (finalSlope * maxPoint.x + finalYIntercept),
|
|
476
|
+
isSignificantlyHigh: true,
|
|
477
|
+
isSignificantlyLow: false
|
|
478
|
+
}));
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
// Check for Absolute Minimum Inclusion
|
|
482
|
+
const minIsIncluded = significantDeviations.some(sd => sd.y === yMin);
|
|
483
|
+
if (!minIsIncluded) {
|
|
484
|
+
const minPoint = allPoints.find(p => p.y === yMin);
|
|
485
|
+
if (minPoint) {
|
|
486
|
+
// Flag the absolute min as a significant deviation if it was missed
|
|
487
|
+
significantDeviations.push(Object.assign(Object.assign({}, minPoint), {
|
|
488
|
+
residual: minPoint.y - (finalSlope * minPoint.x + finalYIntercept),
|
|
489
|
+
isSignificantlyHigh: false,
|
|
490
|
+
isSignificantlyLow: true // It's the lowest point
|
|
491
|
+
}));
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
if (significantDeviations.length === 0) {
|
|
495
|
+
return null;
|
|
496
|
+
}
|
|
497
|
+
let summary = "";
|
|
498
|
+
const highestPoints = significantDeviations.filter(sd => sd.isSignificantlyHigh);
|
|
499
|
+
const lowestPoints = significantDeviations.filter(sd => sd.isSignificantlyLow);
|
|
500
|
+
const MAX_POINTS_TO_REPORT = 5;
|
|
501
|
+
if (highestPoints.length > 0) {
|
|
502
|
+
const uniqueHighestY = [...new Set(highestPoints.map(hp => hp.y))];
|
|
503
|
+
uniqueHighestY.sort((a, b) => b - a);
|
|
504
|
+
const limitedHighestY = uniqueHighestY.slice(0, MAX_POINTS_TO_REPORT);
|
|
505
|
+
const formattedHighestY = limitedHighestY.map(y => truncateDecimals(y, decimalLength)).join(", ");
|
|
506
|
+
summary += `${translate("Highest point(s):")} ${formattedHighestY}. `;
|
|
507
|
+
}
|
|
508
|
+
if (lowestPoints.length > 0) {
|
|
509
|
+
const uniqueLowestY = [...new Set(lowestPoints.map(lp => lp.y))];
|
|
510
|
+
uniqueLowestY.sort((a, b) => a - b);
|
|
511
|
+
const limitedLowestY = uniqueLowestY.slice(0, MAX_POINTS_TO_REPORT);
|
|
512
|
+
const formattedLowestY = limitedLowestY.map(y => truncateDecimals(y, decimalLength)).join(", ");
|
|
513
|
+
summary += `${translate("Lowest point(s):")} ${formattedLowestY}. `;
|
|
514
|
+
}
|
|
515
|
+
return summary.trim();
|
|
442
516
|
}
|
|
443
517
|
function calculateNumberOfSegments(points) {
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
518
|
+
const minPointsForSegmentation = 50;
|
|
519
|
+
const maxSegments = 8;
|
|
520
|
+
const base = 5;
|
|
521
|
+
if (points.length <= minPointsForSegmentation) {
|
|
522
|
+
return 1;
|
|
523
|
+
}
|
|
524
|
+
const calculatedSegments = Math.floor(base * Math.log(points.length));
|
|
525
|
+
return Math.min(calculatedSegments, maxSegments);
|
|
452
526
|
}
|
|
453
527
|
function splitIntoSegments(points) {
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
528
|
+
const numSegments = calculateNumberOfSegments(points);
|
|
529
|
+
if (numSegments === 1) {
|
|
530
|
+
return [points];
|
|
531
|
+
}
|
|
532
|
+
const segments = [];
|
|
533
|
+
const segmentSize = Math.floor(points.length / numSegments);
|
|
534
|
+
const remainder = points.length % numSegments;
|
|
535
|
+
let startIndex = 0;
|
|
536
|
+
for (let i = 0; i < numSegments; i++) {
|
|
537
|
+
const currentSegmentSize = segmentSize + (i < remainder ? 1 : 0);
|
|
538
|
+
const endIndex = startIndex + currentSegmentSize;
|
|
539
|
+
segments.push(points.slice(startIndex, endIndex));
|
|
540
|
+
startIndex = endIndex;
|
|
541
|
+
}
|
|
542
|
+
return segments;
|
|
469
543
|
}
|
|
470
544
|
function detectComplexTrend(allPoints, datasetName, decimalLength, translate) {
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
.replace("{X}", endPoint.originX.toString());
|
|
486
|
-
});
|
|
487
|
-
const complexSummary = `${datasetName} ${translate("shows a complex trend with multiple segments:")} ${summaryParts.join(" ")}`;
|
|
488
|
-
return complexSummary;
|
|
489
|
-
}
|
|
490
|
-
return false;
|
|
545
|
+
const segments = splitIntoSegments(allPoints);
|
|
546
|
+
const segmentTrends = segments.map(segment => calculateLinearRegression(segment));
|
|
547
|
+
const trendDirections = segmentTrends.map(trend => getTrendDirectionBySlope(trend.slope));
|
|
548
|
+
const isComplex = new Set(trendDirections).size > 1;
|
|
549
|
+
if (isComplex) {
|
|
550
|
+
const summaryParts = trendDirections.map((direction, index) => {
|
|
551
|
+
const startPoint = segments[index][0];
|
|
552
|
+
const endPoint = segments[index][segments[index].length - 1];
|
|
553
|
+
return translate("Segment {INDEX} {DIRECTION} from {FROM} at {X0} to {TO} at {X}.").replace("{INDEX}", (index + 1).toString()).replace("{DIRECTION}", direction).replace("{FROM}", truncateDecimals(startPoint.y, decimalLength).toString()).replace("{TO}", truncateDecimals(endPoint.y, decimalLength).toString()).replace("{X0}", startPoint.originX.toString()).replace("{X}", endPoint.originX.toString());
|
|
554
|
+
});
|
|
555
|
+
const complexSummary = `${datasetName} ${translate("shows a complex trend with multiple segments:")} ${summaryParts.join(" ")}`;
|
|
556
|
+
return complexSummary;
|
|
557
|
+
}
|
|
558
|
+
return false;
|
|
491
559
|
}
|
|
492
560
|
function calculateAverageValue(points) {
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
561
|
+
const yValues = points.map(point => point.y);
|
|
562
|
+
const validNumbers = yValues.filter(n => typeof n === "number");
|
|
563
|
+
if (validNumbers.length === 0) {
|
|
564
|
+
return null;
|
|
565
|
+
}
|
|
566
|
+
const sum = validNumbers.reduce((total, current) => total + current, 0);
|
|
567
|
+
return sum / validNumbers.length;
|
|
500
568
|
}
|
|
501
569
|
function detectDatasetTrend(dataset, translate, dateFormatter, miniChartLabels, options) {
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
570
|
+
const datasetName = dataset.label || translate("Data");
|
|
571
|
+
const twoState = detectTwoStateChart(dataset, translate, dateFormatter, miniChartLabels, options);
|
|
572
|
+
if (twoState) {
|
|
573
|
+
return {
|
|
574
|
+
trendDirection: "flat",
|
|
575
|
+
summary: twoState
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
const datasetObj = Object.assign({}, dataset);
|
|
579
|
+
if (!miniChartLabels) {
|
|
580
|
+
// simplify the data before trend detection
|
|
581
|
+
datasetObj.data = simplifyData(datasetObj.data);
|
|
582
|
+
}
|
|
583
|
+
const allPoints = collectAllPoints(datasetObj, dateFormatter, miniChartLabels, options);
|
|
584
|
+
if (allPoints.length === 0) {
|
|
585
|
+
return {
|
|
586
|
+
trendDirection: "undefined",
|
|
587
|
+
summary: translate("No data available")
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
const allUniqueYValues = [...new Set(allPoints.map(p => p.y))];
|
|
591
|
+
const decimalLength = calculateMinTruncationPrecision(allUniqueYValues);
|
|
592
|
+
if (allPoints.length === 1) {
|
|
593
|
+
return {
|
|
594
|
+
trendDirection: "flat",
|
|
595
|
+
summary: translate("Only one data point: value is {VALUE}.").replace("{VALUE}", truncateDecimals(allPoints[0].y, decimalLength).toString())
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
const complexTrend = detectComplexTrend(allPoints, datasetName, decimalLength, translate);
|
|
599
|
+
if (complexTrend) {
|
|
600
|
+
return {
|
|
601
|
+
trendDirection: "complex",
|
|
602
|
+
summary: complexTrend
|
|
603
|
+
};
|
|
604
|
+
}
|
|
605
|
+
const {
|
|
606
|
+
slope
|
|
607
|
+
} = calculateLinearRegression(allPoints);
|
|
608
|
+
let trendDirection = getTrendDirectionBySlope(slope);
|
|
609
|
+
const firstPoint = allPoints[0];
|
|
610
|
+
const lastPoint = allPoints[allPoints.length - 1];
|
|
611
|
+
const yValues = allPoints.map(p => p.y);
|
|
612
|
+
const yMin = yValues.reduce((min, current) => Math.min(min, current));
|
|
613
|
+
const yMax = yValues.reduce((max, current) => Math.max(max, current));
|
|
614
|
+
const yRange = yMax - yMin;
|
|
615
|
+
const netChange = lastPoint.y - firstPoint.y;
|
|
616
|
+
// A tolerance to decide if the net change is significant enough
|
|
617
|
+
// to overrule a weak linear regression. (e.g., a 5% change of the total range).
|
|
618
|
+
const NARRATIVE_TREND_THRESHOLD = 0.05;
|
|
619
|
+
// If the linear regression detected a non-flat trend, check if it's strong enough.
|
|
620
|
+
if (trendDirection !== "flat" && yRange > 1e-9) {
|
|
621
|
+
const netChangeRatio = Math.abs(netChange / yRange);
|
|
622
|
+
if (netChangeRatio < NARRATIVE_TREND_THRESHOLD) {
|
|
623
|
+
trendDirection = "flat";
|
|
624
|
+
} else {
|
|
625
|
+
const netDirection = netChange > 1e-9 ? "increases" : "decreases";
|
|
626
|
+
if (trendDirection !== netDirection) {
|
|
627
|
+
trendDirection = netDirection;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
let summary;
|
|
632
|
+
if (trendDirection === "flat") {
|
|
633
|
+
const averageValue = calculateAverageValue(allPoints);
|
|
634
|
+
const averageString = averageValue ? ` ${translate("Average value is:")} ${truncateDecimals(averageValue, decimalLength)}` : "";
|
|
635
|
+
const FLAT_TREND_TOLERANCE = 0.25;
|
|
636
|
+
if (yMax - yMin < FLAT_TREND_TOLERANCE) {
|
|
637
|
+
summary = `${datasetName} ${translate("shows a relatively flat or stable trend.")} ${averageString}`;
|
|
638
|
+
} else {
|
|
639
|
+
const formattedYMin = truncateDecimals(yMin, decimalLength);
|
|
640
|
+
const formattedYMax = truncateDecimals(yMax, decimalLength);
|
|
641
|
+
summary = `${datasetName} ${translate("value changes in the range from {MIN} to {MAX}.").replace("{MIN}", formattedYMin.toString()).replace("{MAX}", formattedYMax.toString())}
|
|
564
642
|
${averageString}`;
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
else {
|
|
568
|
-
summary = `${datasetName} ${trendDirection} ${translate("from {FROM} at {X0} to {TO} at {X}.")
|
|
569
|
-
.replace("{FROM}", truncateDecimals(firstPoint.y, decimalLength).toString())
|
|
570
|
-
.replace("{TO}", truncateDecimals(lastPoint.y, decimalLength).toString())
|
|
571
|
-
.replace("{X0}", firstPoint.originX.toString())
|
|
572
|
-
.replace("{X}", lastPoint.originX.toString())}`;
|
|
573
|
-
const significantDeviations = detectSignificantDeviations(allPoints, translate, decimalLength);
|
|
574
|
-
if (significantDeviations && typeof significantDeviations === "string") {
|
|
575
|
-
summary += ` ${significantDeviations}`;
|
|
576
|
-
}
|
|
577
643
|
}
|
|
578
|
-
|
|
644
|
+
} else {
|
|
645
|
+
summary = `${datasetName} ${trendDirection} ${translate("from {FROM} at {X0} to {TO} at {X}.").replace("{FROM}", truncateDecimals(firstPoint.y, decimalLength).toString()).replace("{TO}", truncateDecimals(lastPoint.y, decimalLength).toString()).replace("{X0}", firstPoint.originX.toString()).replace("{X}", lastPoint.originX.toString())}`;
|
|
646
|
+
const significantDeviations = detectSignificantDeviations(allPoints, translate, decimalLength);
|
|
647
|
+
if (significantDeviations && typeof significantDeviations === "string") {
|
|
648
|
+
summary += ` ${significantDeviations}`;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
return {
|
|
652
|
+
trendDirection,
|
|
653
|
+
summary
|
|
654
|
+
};
|
|
579
655
|
}
|
|
580
|
-
export const AccessibleChartNarrative = ({
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
}
|
|
656
|
+
export const AccessibleChartNarrative = ({
|
|
657
|
+
data,
|
|
658
|
+
options
|
|
659
|
+
}) => {
|
|
660
|
+
const {
|
|
661
|
+
translate
|
|
662
|
+
} = useLanguage();
|
|
663
|
+
const miniChartLabels = useMemo(() => data.labels, [data]);
|
|
664
|
+
const {
|
|
665
|
+
dateFormat,
|
|
666
|
+
toLocalDateTime
|
|
667
|
+
} = useContext(userFormatContext);
|
|
668
|
+
const dateFormatter = useCallback((d, format = dateFormat) => formatDate(toLocalDateTime(d), format, translate), [toLocalDateTime, dateFormat, translate]);
|
|
669
|
+
const filteredDatasets = removeTrendDataFromDatasets(data.datasets);
|
|
670
|
+
const datasetsWithAnalysis = useMemo(() => filteredDatasets.map(dataset => {
|
|
671
|
+
const datasetObj = Object.assign({}, dataset);
|
|
672
|
+
try {
|
|
673
|
+
const trend = detectDatasetTrend(datasetObj, translate, dateFormatter, miniChartLabels, options);
|
|
674
|
+
return trend.summary;
|
|
675
|
+
} catch (error) {
|
|
676
|
+
const errMsg = `${translate("Error generating chart narrative for dataset")} ${dataset.label || ""}`;
|
|
677
|
+
console.error(errMsg, error);
|
|
678
|
+
return errMsg;
|
|
679
|
+
}
|
|
680
|
+
}), [filteredDatasets, translate, dateFormatter, miniChartLabels, options]);
|
|
681
|
+
return _jsx("div", {
|
|
682
|
+
className: "screen-reader-only",
|
|
683
|
+
children: datasetsWithAnalysis.map((analysis, index) => _jsx("div", {
|
|
684
|
+
children: analysis
|
|
685
|
+
}, index))
|
|
686
|
+
});
|
|
687
|
+
};
|