@hisptz/dhis2-analytics 1.0.51 → 1.0.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/LICENSE +29 -0
  2. package/package.json +4 -4
  3. package/.gitignore +0 -5
  4. package/d2.config.js +0 -8
  5. package/i18n/en.pot +0 -439
  6. package/src/components/ChartAnalytics/ChartAnalytics.test.tsx +0 -51
  7. package/src/components/ChartAnalytics/components/DownloadMenu/components/Menu.tsx +0 -48
  8. package/src/components/ChartAnalytics/components/DownloadMenu/constants/menu.ts +0 -38
  9. package/src/components/ChartAnalytics/components/DownloadMenu/index.tsx +0 -65
  10. package/src/components/ChartAnalytics/components/DownloadMenu/interfaces/menu.ts +0 -1
  11. package/src/components/ChartAnalytics/hooks/useChart.ts +0 -35
  12. package/src/components/ChartAnalytics/index.tsx +0 -28
  13. package/src/components/ChartAnalytics/models/bar.ts +0 -20
  14. package/src/components/ChartAnalytics/models/column.ts +0 -52
  15. package/src/components/ChartAnalytics/models/index.ts +0 -111
  16. package/src/components/ChartAnalytics/models/line.ts +0 -31
  17. package/src/components/ChartAnalytics/models/multi-series.ts +0 -115
  18. package/src/components/ChartAnalytics/models/pie.ts +0 -54
  19. package/src/components/ChartAnalytics/services/export.ts +0 -38
  20. package/src/components/ChartAnalytics/styles/custom-highchart.css +0 -48
  21. package/src/components/ChartAnalytics/types/props.tsx +0 -48
  22. package/src/components/ChartAnalytics/utils/chart.ts +0 -128
  23. package/src/components/CircularProgressDashboard/CircularProgressIndicator.test.tsx +0 -9
  24. package/src/components/CircularProgressDashboard/index.tsx +0 -36
  25. package/src/components/CircularProgressDashboard/types/props.tsx +0 -17
  26. package/src/components/CustomPivotTable/components/Table/index.tsx +0 -23
  27. package/src/components/CustomPivotTable/components/TableBody/TableBody.module.css +0 -12
  28. package/src/components/CustomPivotTable/components/TableBody/index.tsx +0 -96
  29. package/src/components/CustomPivotTable/components/TableHeaders/TableHeaders.module.css +0 -10
  30. package/src/components/CustomPivotTable/components/TableHeaders/index.tsx +0 -94
  31. package/src/components/CustomPivotTable/index.tsx +0 -63
  32. package/src/components/CustomPivotTable/interfaces/index.ts +0 -1
  33. package/src/components/CustomPivotTable/services/engine.ts +0 -102
  34. package/src/components/CustomPivotTable/state/engine.tsx +0 -22
  35. package/src/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfigModal.stories.tsx +0 -28
  36. package/src/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfiguration.stories.tsx +0 -34
  37. package/src/components/Map/components/EarthEngineLayerConfiguration/index.tsx +0 -412
  38. package/src/components/Map/components/MapArea/index.tsx +0 -83
  39. package/src/components/Map/components/MapArea/interfaces/index.ts +0 -39
  40. package/src/components/Map/components/MapControls/components/CustomControl/index.tsx +0 -24
  41. package/src/components/Map/components/MapControls/components/DownloadControl/index.tsx +0 -11
  42. package/src/components/Map/components/MapControls/components/FullscreenControl/index.tsx +0 -7
  43. package/src/components/Map/components/MapControls/index.tsx +0 -24
  44. package/src/components/Map/components/MapLayer/components/BoundaryLayer/hooks/useBoundaryData.ts +0 -7
  45. package/src/components/Map/components/MapLayer/components/BoundaryLayer/index.tsx +0 -55
  46. package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/components/EarthEngineLegend.tsx +0 -74
  47. package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/constants/index.ts +0 -430
  48. package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/hooks/index.ts +0 -34
  49. package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/index.tsx +0 -185
  50. package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/interfaces/index.ts +0 -56
  51. package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/services/api.js +0 -34241
  52. package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/services/engine.ts +0 -431
  53. package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/utils/index.ts +0 -105
  54. package/src/components/Map/components/MapLayer/components/LegendArea/LegendArea.module.css +0 -12
  55. package/src/components/Map/components/MapLayer/components/LegendArea/components/LegendCardHeader/index.tsx +0 -17
  56. package/src/components/Map/components/MapLayer/components/LegendArea/index.tsx +0 -167
  57. package/src/components/Map/components/MapLayer/components/PointLayer/components/PointLegend/index.tsx +0 -44
  58. package/src/components/Map/components/MapLayer/components/PointLayer/hooks/index.ts +0 -8
  59. package/src/components/Map/components/MapLayer/components/PointLayer/index.tsx +0 -36
  60. package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubble.tsx +0 -48
  61. package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubbles.tsx +0 -150
  62. package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/index.tsx +0 -39
  63. package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/index.tsx +0 -57
  64. package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/components/ChoroplethLegend.tsx +0 -43
  65. package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/index.tsx +0 -38
  66. package/src/components/Map/components/MapLayer/components/ThematicLayer/components/CustomTooltip/index.tsx +0 -26
  67. package/src/components/Map/components/MapLayer/components/ThematicLayer/hooks/config.ts +0 -10
  68. package/src/components/Map/components/MapLayer/components/ThematicLayer/index.tsx +0 -46
  69. package/src/components/Map/components/MapLayer/components/ThematicLayer/styles/legends.css +0 -62
  70. package/src/components/Map/components/MapLayer/index.tsx +0 -32
  71. package/src/components/Map/components/MapLayer/interfaces/index.ts +0 -139
  72. package/src/components/Map/components/MapProvider/components/MapLayerProvider/hooks/index.tsx +0 -368
  73. package/src/components/Map/components/MapProvider/components/MapLayerProvider/index.tsx +0 -105
  74. package/src/components/Map/components/MapProvider/hooks/index.ts +0 -14
  75. package/src/components/Map/components/MapProvider/index.tsx +0 -93
  76. package/src/components/Map/components/MapUpdater/index.tsx +0 -8
  77. package/src/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfigModal.stories.tsx +0 -28
  78. package/src/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfiguration.stories.tsx +0 -34
  79. package/src/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/components/ColorScale/index.tsx +0 -24
  80. package/src/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/constants/colors.ts +0 -433
  81. package/src/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/index.tsx +0 -50
  82. package/src/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/styles/ColorScale.module.css +0 -15
  83. package/src/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/styles/ColorScaleSelect.module.css +0 -12
  84. package/src/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/utils/colors.ts +0 -91
  85. package/src/components/Map/components/ThematicLayerConfiguration/components/CustomLegend/index.tsx +0 -45
  86. package/src/components/Map/components/ThematicLayerConfiguration/components/IndicatorSelectorModal/index.tsx +0 -47
  87. package/src/components/Map/components/ThematicLayerConfiguration/components/LegendSetSelector/index.tsx +0 -57
  88. package/src/components/Map/components/ThematicLayerConfiguration/index.tsx +0 -248
  89. package/src/components/Map/constants/colors.ts +0 -434
  90. package/src/components/Map/constants/legendSet.ts +0 -19
  91. package/src/components/Map/hooks/map.ts +0 -47
  92. package/src/components/Map/index.tsx +0 -65
  93. package/src/components/Map/interfaces/index.ts +0 -57
  94. package/src/components/Map/state/index.tsx +0 -31
  95. package/src/components/Map/utils/colors.ts +0 -95
  96. package/src/components/Map/utils/helpers.ts +0 -15
  97. package/src/components/Map/utils/map.ts +0 -150
  98. package/src/components/SingleValueContainer/SingleValueContainer.test.tsx +0 -24
  99. package/src/components/SingleValueContainer/components/SingleValueItem/SingleValueItem.tsx +0 -46
  100. package/src/components/SingleValueContainer/components/SingleValueItem/SingleValuePercentage.tsx +0 -12
  101. package/src/components/SingleValueContainer/index.tsx +0 -37
  102. package/src/components/SingleValueContainer/styles/SingleValueContainer.module.css +0 -39
  103. package/src/components/SingleValueContainer/types/props.tsx +0 -16
  104. package/src/components/Visualization/components/AnalyticsDataProvider/index.tsx +0 -76
  105. package/src/components/Visualization/components/DimensionsProvider/index.tsx +0 -51
  106. package/src/components/Visualization/components/LayoutProvider/index.tsx +0 -34
  107. package/src/components/Visualization/components/VisualizationDimensionSelector/index.tsx +0 -59
  108. package/src/components/Visualization/components/VisualizationProvider/index.tsx +0 -31
  109. package/src/components/Visualization/components/VisualizationSelector/index.tsx +0 -157
  110. package/src/components/Visualization/components/VisualizationTypeProvider/index.tsx +0 -40
  111. package/src/components/Visualization/components/VisualizationTypeSelector/index.tsx +0 -46
  112. package/src/components/Visualization/index.tsx +0 -103
  113. package/src/index.ts +0 -6
  114. package/src/locales/en/translations.json +0 -138
  115. package/src/locales/index.js +0 -16
  116. package/tsconfig.build.json +0 -46
  117. package/tsconfig.json +0 -51
@@ -1,59 +0,0 @@
1
- import React, {useCallback, useMemo, useState} from "react";
2
- import {Button, IconClock24, IconLocation24, Tooltip} from "@dhis2/ui"
3
- import i18n from '@dhis2/d2-i18n';
4
- import {useDimensions} from "../DimensionsProvider";
5
- import {OrgUnitSelectorModal, PeriodSelectorModal} from "@hisptz/dhis2-ui";
6
- import {OrgUnitSelection} from "@hisptz/dhis2-utils";
7
- import {getOrgUnitSelectionFromIds} from "../VisualizationSelector";
8
- import {getOrgUnitsSelection} from "../../../Map/utils/map";
9
-
10
- export function VisualizationDimensionSelector() {
11
- const [dimensions, setDimensions] = useDimensions();
12
- const periods = useMemo(() => dimensions.pe, [dimensions.pe]);
13
- const orgUnitSelection = useMemo(() => getOrgUnitSelectionFromIds(dimensions.ou ?? []), [dimensions.ou]);
14
- const [openFilter, setOpenFilter] = useState<"pe" | "ou" | undefined>();
15
-
16
- const onFilterUpdate = useCallback((type: "ou" | "pe") => (data: OrgUnitSelection | any) => {
17
- setOpenFilter(undefined);
18
- if (type === "ou") {
19
- setDimensions({dimension: "ou", value: getOrgUnitsSelection(data)});
20
- return;
21
- }
22
- if (type === "pe") {
23
- setDimensions({dimension: "pe", value: data})
24
- return;
25
- }
26
-
27
- }, [setDimensions]);
28
-
29
- return (
30
- <>
31
- <PeriodSelectorModal
32
-
33
- position="middle"
34
- enablePeriodSelector
35
- selectedPeriods={periods}
36
- onClose={() => setOpenFilter(undefined)}
37
- hide={openFilter !== "pe"}
38
- onUpdate={onFilterUpdate("pe")}
39
- />
40
- <OrgUnitSelectorModal
41
- showUserOptions
42
- searchable
43
- title={i18n.t("Select location(s)")}
44
- value={orgUnitSelection}
45
- onClose={() => setOpenFilter(undefined)}
46
- hide={openFilter !== "ou"}
47
- onUpdate={onFilterUpdate("ou")}
48
- />
49
- <div style={{display: "flex", gap: 8}}>
50
- <Tooltip content={i18n.t("Period")}>
51
- <Button onClick={() => setOpenFilter("pe")} icon={<IconClock24/>}/>
52
- </Tooltip>
53
- <Tooltip content={i18n.t("Location")}>
54
- <Button onClick={() => setOpenFilter("ou")} icon={<IconLocation24/>}/>
55
- </Tooltip>
56
- </div>
57
- </>
58
- )
59
- }
@@ -1,31 +0,0 @@
1
- import React from "react";
2
- import {Layout, LayoutProvider} from "../LayoutProvider";
3
- import {AnalyticsDimension} from "@hisptz/dhis2-utils";
4
- import {DimensionsProvider} from "../DimensionsProvider";
5
- import {AnalyticsDataProvider} from "../AnalyticsDataProvider";
6
- import {VisualizationType, VisualizationTypeProvider} from "../VisualizationTypeProvider";
7
- import {VisualizationConfig} from "../../index";
8
-
9
-
10
- export interface VisualizationProviderProps {
11
- children: React.ReactNode,
12
- layout: Layout,
13
- dimensions: AnalyticsDimension;
14
- type: VisualizationType;
15
- config: VisualizationConfig
16
- }
17
-
18
- export function VisualizationProvider({layout, dimensions, children, type, config}: VisualizationProviderProps) {
19
-
20
- return (
21
- <DimensionsProvider dimensions={dimensions}>
22
- <VisualizationTypeProvider config={config} defaultType={type}>
23
- <LayoutProvider defaultLayout={layout}>
24
- <AnalyticsDataProvider>
25
- {children}
26
- </AnalyticsDataProvider>
27
- </LayoutProvider>
28
- </VisualizationTypeProvider>
29
- </DimensionsProvider>
30
- )
31
- }
@@ -1,157 +0,0 @@
1
- import React, {useMemo} from "react"
2
- import {useVisualizationType} from "../VisualizationTypeProvider";
3
- import {useAnalyticsData} from "../AnalyticsDataProvider";
4
- import {CircularLoader} from "@dhis2/ui"
5
- import {CustomPivotTable, CustomPivotTableOptions} from "../../../CustomPivotTable";
6
- import {useLayout} from "../LayoutProvider";
7
- import {filter, find, findIndex, forEach, mapValues, set} from "lodash";
8
- import {Dimension, useDimensions} from "../DimensionsProvider";
9
- import i18n from '@dhis2/d2-i18n';
10
- import {ChartAnalytics, ChartConfig} from "../../../ChartAnalytics";
11
- import {VisualizationConfig} from "../../index";
12
- import {Map, MapProps} from "../../../Map";
13
- import {OrgUnitSelection} from "@hisptz/dhis2-utils";
14
- import {ThematicLayerConfig, ThematicLayerRawData} from "../../../Map/components/MapLayer/interfaces";
15
- import {PivotTableLayoutProps} from "../../../CustomPivotTable/components/Table";
16
-
17
- export interface VisualizationSelectorProps {
18
- config: VisualizationConfig;
19
- }
20
-
21
-
22
- export function getDimensionLabel(dimension: Dimension) {
23
- switch (dimension) {
24
- case "pe":
25
- return i18n.t("Period");
26
- case "ou":
27
- return i18n.t("Organisation unit");
28
- case "dx":
29
- return i18n.t("Data");
30
- default:
31
- return ""
32
- }
33
- }
34
-
35
- export function getOrgUnitSelectionFromIds(ous: string[]) {
36
- const orgUnitSelection: OrgUnitSelection = {
37
- orgUnits: []
38
- };
39
- forEach(ous, (ou) => {
40
- if (ou === "USER_ORGUNIT") {
41
- set(orgUnitSelection, ["userOrgUnit"], true)
42
- } else if (ou === "USER_ORGUNIT_CHILDREN") {
43
- set(orgUnitSelection, ["userSubUnit"], true)
44
- } else if (ou === "USER_ORGUNIT_GRANDCHILDREN") {
45
- set(orgUnitSelection, ["userSubX2Unit"], true)
46
- } else {
47
- const orgUnits = [...(orgUnitSelection.orgUnits ?? [])];
48
- orgUnits.push({
49
- id: ou,
50
- children: []
51
- })
52
- set(orgUnitSelection, ['orgUnits'], orgUnits);
53
- }
54
- })
55
- return orgUnitSelection;
56
- }
57
-
58
- export function PivotTableRenderer({options}: { options: CustomPivotTableOptions & PivotTableLayoutProps }) {
59
- const [layout] = useLayout();
60
- const {analytics} = useAnalyticsData();
61
-
62
- const sanitizedLayout = useMemo(() => {
63
- return mapValues(layout, (dimension) => dimension.map(dimension => ({
64
- dimension,
65
- label: getDimensionLabel(dimension)
66
- })))
67
- }, [layout]);
68
-
69
- if (!analytics) {
70
- return null;
71
- }
72
-
73
- return <CustomPivotTable
74
- tableProps={{
75
- scrollHeight: options.scrollHeight ?? "100%",
76
- scrollWidth: options.scrollWidth ?? "100%",
77
- width: options.width ?? "100%",
78
- }}
79
- analytics={analytics}
80
- config={{layout: sanitizedLayout, options}}/>;
81
- }
82
-
83
- export function ChartRenderer({options}: { options: ChartConfig }) {
84
- const {analytics} = useAnalyticsData();
85
- if (!analytics) {
86
- return null;
87
- }
88
- return <ChartAnalytics analytics={analytics} config={{...options,}}/>
89
- }
90
-
91
- export function MapRenderer({options}: {
92
- options: Omit<MapProps, "orgUnitSelection" | "periodSelection">
93
- }) {
94
- const [dimensions] = useDimensions();
95
- const {analytics} = useAnalyticsData();
96
- const orgUnitSelection: OrgUnitSelection = useMemo(() => {
97
- return getOrgUnitSelectionFromIds(dimensions.ou ?? []);
98
- }, [dimensions.ou]);
99
-
100
- const thematicLayers: ThematicLayerConfig[] = useMemo(() => {
101
- const valueIndex = findIndex(analytics.headers, ['name', 'value']) ?? -1
102
- return analytics.metaData?.dimensions["dx"]?.map((dataId) => {
103
- const config = find(options.thematicLayers, ['id', dataId]);
104
- const data: ThematicLayerRawData[] = analytics.metaData?.dimensions?.ou?.map(ouId => {
105
- const values = filter(analytics.rows, (row) => row.includes(dataId) && row.includes(ouId)) as unknown as string[];
106
- const value = values.reduce((acc, value) => acc + parseFloat(value[valueIndex]), 0);
107
- return {
108
- data: value,
109
- dataItem: dataId,
110
- orgUnit: ouId
111
- }
112
- }) ?? []
113
- return {
114
- ...config,
115
- data,
116
- } as ThematicLayerConfig
117
- }) ?? []
118
- }, [analytics]);
119
-
120
- return (
121
- <Map
122
- orgUnitSelection={orgUnitSelection}
123
- thematicLayers={thematicLayers}
124
- />
125
- )
126
- }
127
-
128
- export function VisualizationSelector({config}: VisualizationSelectorProps) {
129
- const [type] = useVisualizationType();
130
- const {analytics, loading} = useAnalyticsData();
131
-
132
- if (loading) {
133
- return (
134
- <div style={{
135
- width: "100%",
136
- height: "100%",
137
- display: "flex",
138
- justifyContent: "center",
139
- alignItems: "center"
140
- }}>
141
- <CircularLoader small/>
142
- </div>
143
- )
144
- }
145
- if (!analytics) {
146
- return null;
147
- }
148
-
149
- return (
150
- <>
151
- {type === "pivotTable" && (<PivotTableRenderer options={config?.pivotTable as CustomPivotTableOptions}/>)}
152
- {type === "chart" && (<ChartRenderer options={config?.chart as ChartConfig}/>)}
153
- {type === "map" && (
154
- <MapRenderer options={config?.map as Omit<MapProps, "orgUnitSelection" | "periodSelection">}/>)}
155
- </>
156
- )
157
- }
@@ -1,40 +0,0 @@
1
- import React, {createContext, useContext, useState} from "react";
2
- import {VisualizationConfig} from "../../index";
3
-
4
- export type VisualizationType = "pivotTable" | "chart" | "map";
5
-
6
-
7
- export const VisualizationTypeContext = createContext<VisualizationType>('pivotTable')
8
- export const VisualizationConfigContext = createContext<VisualizationConfig | undefined>(undefined);
9
- export const VisualizationTypeSetter = createContext<React.Dispatch<React.SetStateAction<VisualizationType>> | undefined>(undefined)
10
-
11
- export interface VisualizationTypeProviderProps {
12
- children: React.ReactNode;
13
- defaultType: VisualizationType;
14
- config: VisualizationConfig
15
- }
16
-
17
- export function useVisualizationType() {
18
- return [
19
- useContext(VisualizationTypeContext),
20
- useContext(VisualizationTypeSetter)
21
- ] as [VisualizationType, React.Dispatch<React.SetStateAction<VisualizationType>>]
22
- }
23
-
24
- export function useVisualizationConfig() {
25
- return useContext(VisualizationConfigContext);
26
- }
27
-
28
- export function VisualizationTypeProvider({children, defaultType, config}: VisualizationTypeProviderProps) {
29
- const [type, setType] = useState<VisualizationType>(defaultType);
30
-
31
- return (
32
- <VisualizationTypeContext.Provider value={type}>
33
- <VisualizationConfigContext.Provider value={config}>
34
- <VisualizationTypeSetter.Provider value={setType}>
35
- {children}
36
- </VisualizationTypeSetter.Provider>
37
- </VisualizationConfigContext.Provider>
38
- </VisualizationTypeContext.Provider>
39
- )
40
- }
@@ -1,46 +0,0 @@
1
- import React, {useMemo} from "react";
2
- import {useVisualizationConfig, useVisualizationType, VisualizationType} from "../VisualizationTypeProvider";
3
- import {Button, IconTable24, IconVisualizationColumn24, IconWorld24, Tooltip} from "@dhis2/ui"
4
- import i18n from '@dhis2/d2-i18n';
5
-
6
- const supportedVisualizationTypes = [
7
- {
8
- id: "pivotTable",
9
- icon: <IconTable24/>,
10
- label: i18n.t("Pivot table")
11
- },
12
- {
13
- id: "chart",
14
- icon: <IconVisualizationColumn24/>,
15
- label: i18n.t("Chart")
16
- }, {
17
- id: "map",
18
- icon: <IconWorld24/>,
19
- label: i18n.t("Map")
20
- }
21
- ]
22
-
23
- export function VisualizationTypeSelector() {
24
- const [type, setType] = useVisualizationType();
25
- const config = useVisualizationConfig();
26
-
27
- const types = useMemo(() => supportedVisualizationTypes.filter((supportedType) => {
28
- return Object.keys(config ?? {}).includes(supportedType.id) && supportedType.id !== type
29
- }), [type, config]);
30
-
31
- return (
32
- <div style={{display: "flex", gap: 8}}>
33
- {
34
- types.map(({icon, label, id}) => {
35
- return (
36
- <Tooltip key={`${label}-tooltip`} content={i18n.t("View as {{type}}", {
37
- type: label.toLowerCase()
38
- })}>
39
- <Button onClick={() => setType(id as VisualizationType)} icon={icon}/>
40
- </Tooltip>
41
- )
42
- })
43
- }
44
- </div>
45
- )
46
- }
@@ -1,103 +0,0 @@
1
- import React from "react";
2
- import {AnalyticsDimension} from "@hisptz/dhis2-utils";
3
- import {VisualizationProvider} from "./components/VisualizationProvider";
4
- import {Layout} from "./components/LayoutProvider";
5
- import {VisualizationType} from "./components/VisualizationTypeProvider";
6
- import {VisualizationTypeSelector} from "./components/VisualizationTypeSelector";
7
- import {VisualizationDimensionSelector} from "./components/VisualizationDimensionSelector";
8
- import {VisualizationSelector} from "./components/VisualizationSelector";
9
- import {CustomPivotTableOptions} from "../CustomPivotTable";
10
- import {ChartConfig} from "../ChartAnalytics";
11
- import {MapProps} from "../Map";
12
- import {ErrorBoundary, FallbackProps} from "react-error-boundary";
13
- import i18n from '@dhis2/d2-i18n';
14
- import {Button, colors, IconError24} from "@dhis2/ui"
15
-
16
- export interface VisualizationConfig {
17
- pivotTable?: CustomPivotTableOptions;
18
- chart?: ChartConfig;
19
- map?: Omit<MapProps, "orgUnitSelection" | "periodSelection">
20
- }
21
-
22
- export interface VisualizationProps {
23
- layout: Layout,
24
- defaultVisualizationType: VisualizationType;
25
- dimensions: AnalyticsDimension;
26
- config: VisualizationConfig;
27
- height?: number;
28
- showToolbar?: boolean
29
- }
30
-
31
- /**
32
- * An analytics component that allows visualization of `chart`, `map`, and `pivot table` by passing analytics object and the default layout and type
33
- *
34
- * */
35
-
36
-
37
- function ErrorFallback({error, resetErrorBoundary, height}: FallbackProps & { height?: number }) {
38
- return <div style={{
39
- width: "100%",
40
- textAlign: "center",
41
- height: height ?? 500,
42
- display: "flex",
43
- flexDirection: "column",
44
- alignItems: "center",
45
- justifyContent: "center",
46
- gap: 16,
47
- padding: 16,
48
- }}>
49
- <IconError24/>
50
- <h3 style={{
51
- color: colors.grey800,
52
- margin: 0
53
- }}>{i18n.t("Could not load visualization")}</h3>
54
- <p style={{margin: 0}}>
55
- {error.message}
56
- </p>
57
- {
58
- resetErrorBoundary && <Button onClick={resetErrorBoundary} small>{i18n.t("Try again")}</Button>
59
- }
60
- </div>
61
- }
62
-
63
- export function Visualization({
64
- dimensions,
65
- layout,
66
- defaultVisualizationType,
67
- config,
68
- height,
69
- showToolbar
70
- }: VisualizationProps) {
71
- return (
72
- <ErrorBoundary
73
- onReset={() => {
74
- //TODO: reset the visualization
75
- }}
76
- resetKeys={[dimensions, layout, defaultVisualizationType, config]}
77
- fallbackRender={(props => (<ErrorFallback height={height} {...props}/>) as any)}>
78
- <VisualizationProvider config={config} type={defaultVisualizationType} layout={layout}
79
- dimensions={dimensions}>
80
- <div
81
- style={{
82
- display: "flex",
83
- flexDirection: "column",
84
- width: "100%",
85
- height: "100%",
86
- gap: 16
87
- }}>
88
- {
89
- showToolbar && (
90
- <div style={{display: "flex", flexDirection: "row", gap: 16, justifyContent: "space-between"}}>
91
- <VisualizationTypeSelector/>
92
- <VisualizationDimensionSelector/>
93
- </div>
94
- )
95
- }
96
- <>
97
- <VisualizationSelector config={config}/>
98
- </>
99
- </div>
100
- </VisualizationProvider>
101
- </ErrorBoundary>
102
- )
103
- }
package/src/index.ts DELETED
@@ -1,6 +0,0 @@
1
- export * from "./components/Map";
2
- export * from "./components/CircularProgressDashboard";
3
- export * from "./components/ChartAnalytics";
4
- export * from "./components/SingleValueContainer";
5
- export * from "./components/CustomPivotTable"
6
- export * from "./components/Visualization"
@@ -1,138 +0,0 @@
1
- {
2
- "Download PNG": "Download PNG",
3
- "Download JPEG": "Download JPEG",
4
- "Download SVG": "Download SVG",
5
- "Download PDF": "Download PDF",
6
- "View as table": "View as table",
7
- "View full screen": "View full screen",
8
- "Submit": "Submit",
9
- "Aggregation": "Aggregation",
10
- "Aggregations": "Aggregations",
11
- "Period is required": "Period is required",
12
- "Available periods are set by the source data": "Available periods are set by the source data",
13
- "Period": "Period",
14
- "Min": "Min",
15
- "Max": "Max",
16
- "Steps": "Steps",
17
- "Colors": "Colors",
18
- "Unit": "Unit",
19
- "Name is required": "Name is required",
20
- "Layer name": "Layer name",
21
- "Type is required": "Type is required",
22
- "Layer type": "Layer type",
23
- "Configure Earth Engine Layer": "Configure Earth Engine Layer",
24
- "Cancel": "Cancel",
25
- "Save": "Save",
26
- "Boundaries": "Boundaries",
27
- "Source": "Source",
28
- "Population": "Population",
29
- "people per hectare": "people per hectare",
30
- "Estimated number of people living in an area.": "Estimated number of people living in an area.",
31
- "Population age groups": "Population age groups",
32
- "Estimated number of people living in an area, grouped by age and gender.": "Estimated number of people living in an area, grouped by age and gender.",
33
- "Male 0 - 1 years": "Male 0 - 1 years",
34
- "Male 1 - 4 years": "Male 1 - 4 years",
35
- "Male 5 - 9 years": "Male 5 - 9 years",
36
- "Male 10 - 14 years": "Male 10 - 14 years",
37
- "Male 15 - 19 years": "Male 15 - 19 years",
38
- "Male 20 - 24 years": "Male 20 - 24 years",
39
- "Male 25 - 29 years": "Male 25 - 29 years",
40
- "Male 30 - 34 years": "Male 30 - 34 years",
41
- "Male 35 - 39 years": "Male 35 - 39 years",
42
- "Male 40 - 44 years": "Male 40 - 44 years",
43
- "Male 45 - 49 years": "Male 45 - 49 years",
44
- "Male 50 - 54 years": "Male 50 - 54 years",
45
- "Male 55 - 59 years": "Male 55 - 59 years",
46
- "Male 60 - 64 years": "Male 60 - 64 years",
47
- "Male 65 - 69 years": "Male 65 - 69 years",
48
- "Male 70 - 74 years": "Male 70 - 74 years",
49
- "Male 75 - 79 years": "Male 75 - 79 years",
50
- "Male 80 years and above": "Male 80 years and above",
51
- "Female 0 - 1 years": "Female 0 - 1 years",
52
- "Female 1 - 4 years": "Female 1 - 4 years",
53
- "Female 5 - 9 years": "Female 5 - 9 years",
54
- "Female 10 - 14 years": "Female 10 - 14 years",
55
- "Female 15 - 19 years": "Female 15 - 19 years",
56
- "Female 20 - 24 years": "Female 20 - 24 years",
57
- "Female 25 - 29 years": "Female 25 - 29 years",
58
- "Female 30 - 34 years": "Female 30 - 34 years",
59
- "Female 35 - 39 years": "Female 35 - 39 years",
60
- "Female 40 - 44 years": "Female 40 - 44 years",
61
- "Female 45 - 49 years": "Female 45 - 49 years",
62
- "Female 50 - 54 years": "Female 50 - 54 years",
63
- "Female 55 - 59 years": "Female 55 - 59 years",
64
- "Female 60 - 64 years": "Female 60 - 64 years",
65
- "Female 65 - 69 years": "Female 65 - 69 years",
66
- "Female 70 - 74 years": "Female 70 - 74 years",
67
- "Female 75 - 79 years": "Female 75 - 79 years",
68
- "Female 80 years and above": "Female 80 years and above",
69
- "Building footprints": "Building footprints",
70
- "Number of buildings": "Number of buildings",
71
- "The outlines of buildings derived from high-resolution satellite imagery. Only for the continent of Africa.": "The outlines of buildings derived from high-resolution satellite imagery. Only for the continent of Africa.",
72
- "Building counts are only available for smaller organisation unit areas.": "Building counts are only available for smaller organisation unit areas.",
73
- "Select a smaller area or single organization unit to see the count of buildings.": "Select a smaller area or single organization unit to see the count of buildings.",
74
- "Elevation": "Elevation",
75
- "meters": "meters",
76
- "Elevation above sea-level.": "Elevation above sea-level.",
77
- "Precipitation": "Precipitation",
78
- "millimeter": "millimeter",
79
- "Precipitation collected from satellite and weather stations on the ground. The values are in millimeters within 5 days periods. Updated monthly, during the 3rd week of the following month.": "Precipitation collected from satellite and weather stations on the ground. The values are in millimeters within 5 days periods. Updated monthly, during the 3rd week of the following month.",
80
- "Temperature": "Temperature",
81
- "°C during daytime": "°C during daytime",
82
- "Land surface temperatures collected from satellite. Blank spots will appear in areas with a persistent cloud cover.": "Land surface temperatures collected from satellite. Blank spots will appear in areas with a persistent cloud cover.",
83
- "Landcover": "Landcover",
84
- "Distinct landcover types collected from satellites.": "Distinct landcover types collected from satellites.",
85
- "Evergreen Needleleaf forest": "Evergreen Needleleaf forest",
86
- "Evergreen Broadleaf forest": "Evergreen Broadleaf forest",
87
- "Deciduous Needleleaf forest": "Deciduous Needleleaf forest",
88
- "Deciduous Broadleaf forest": "Deciduous Broadleaf forest",
89
- "Mixed forest": "Mixed forest",
90
- "Closed shrublands": "Closed shrublands",
91
- "Open shrublands": "Open shrublands",
92
- "Woody savannas": "Woody savannas",
93
- "Savannas": "Savannas",
94
- "Grasslands": "Grasslands",
95
- "Permanent wetlands": "Permanent wetlands",
96
- "Croplands": "Croplands",
97
- "Urban and built-up": "Urban and built-up",
98
- "Cropland/Natural vegetation mosaic": "Cropland/Natural vegetation mosaic",
99
- "Snow and ice": "Snow and ice",
100
- "Barren or sparsely vegetated": "Barren or sparsely vegetated",
101
- "Water": "Water",
102
- "Nighttime lights": "Nighttime lights",
103
- "light intensity": "light intensity",
104
- "Light intensity from cities, towns, and other sites with persistent lighting, including gas flares.": "Light intensity from cities, towns, and other sites with persistent lighting, including gas flares.",
105
- "Could not get aggregate data": "Could not get aggregate data",
106
- "Points": "Points",
107
- "Mid": "Mid",
108
- "Value": "Value",
109
- "Error": "Error",
110
- "Classes": "Classes",
111
- "Select Data Item": "Select Data Item",
112
- "Update": "Update",
113
- "Legend set": "Legend set",
114
- "Please wait...": "Please wait...",
115
- "Layer type is required": "Layer type is required",
116
- "Choropleth": "Choropleth",
117
- "Bubble": "Bubble",
118
- "A data item is required": "A data item is required",
119
- "Data Item": "Data Item",
120
- "Change": "Change",
121
- "Select": "Select",
122
- "Legend": "Legend",
123
- "Custom legend": "Custom legend",
124
- "Legend set is required": "Legend set is required",
125
- "Radius": "Radius",
126
- "Configure Thematic Layer": "Configure Thematic Layer",
127
- "Loading ...": "Loading ...",
128
- "Select location(s)": "Select location(s)",
129
- "Location": "Location",
130
- "Organisation unit": "Organisation unit",
131
- "Data": "Data",
132
- "Pivot table": "Pivot table",
133
- "Chart": "Chart",
134
- "Map": "Map",
135
- "View as {{type}}": "View as {{type}}",
136
- "Could not load visualization": "Could not load visualization",
137
- "Try again": "Try again"
138
- }
@@ -1,16 +0,0 @@
1
- //------------------------------------------------------------------------------
2
- // <auto-generated>
3
- // This code was generated by d2-i18n-generate.
4
- //
5
- // Changes to this file may cause incorrect behavior and will be lost if
6
- // the code is regenerated.
7
- // </auto-generated>
8
- //------------------------------------------------------------------------------
9
- import i18n from '@dhis2/d2-i18n'
10
-
11
- import enTranslations from './en/translations.json'
12
-
13
- const namespace = 'default'
14
- i18n.addResources('en', namespace, enTranslations)
15
-
16
- export default i18n
@@ -1,46 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "baseUrl": "src",
4
- "target": "es2017",
5
- "lib": [
6
- "dom",
7
- "dom.iterable",
8
- "esnext"
9
- ],
10
- "declaration": true,
11
- "emitDeclarationOnly": true,
12
- "outDir": "./build/types",
13
- "types": [
14
- "cypress",
15
- "node"
16
- ],
17
- "allowJs": false,
18
- "skipLibCheck": true,
19
- "downlevelIteration": true,
20
- "esModuleInterop": true,
21
- "allowSyntheticDefaultImports": true,
22
- "strict": true,
23
- "forceConsistentCasingInFileNames": true,
24
- "noFallthroughCasesInSwitch": true,
25
- "module": "esnext",
26
- "moduleResolution": "node",
27
- "resolveJsonModule": true,
28
- "isolatedModules": false,
29
- "jsx": "react",
30
- "checkJs": false
31
- },
32
- "include": [
33
- "src/**/*",
34
- "../../types"
35
- ],
36
- "exclude": [
37
- "node_modules",
38
- "../../node_modules",
39
- "src/dataProviders",
40
- "src/locales/*/**.js",
41
- "src/*/**.js",
42
- "**/*.test.tsx",
43
- "**/*.stories.tsx",
44
- "**/*.config.ts"
45
- ]
46
- }