@hisptz/dhis2-analytics 1.0.51 → 1.0.53

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 (119) hide show
  1. package/LICENSE +29 -0
  2. package/build/cjs/components/Visualization/components/AnalyticsDataProvider/index.js +8 -5
  3. package/build/es/components/Visualization/components/AnalyticsDataProvider/index.js +8 -5
  4. package/package.json +4 -4
  5. package/.gitignore +0 -5
  6. package/d2.config.js +0 -8
  7. package/i18n/en.pot +0 -439
  8. package/src/components/ChartAnalytics/ChartAnalytics.test.tsx +0 -51
  9. package/src/components/ChartAnalytics/components/DownloadMenu/components/Menu.tsx +0 -48
  10. package/src/components/ChartAnalytics/components/DownloadMenu/constants/menu.ts +0 -38
  11. package/src/components/ChartAnalytics/components/DownloadMenu/index.tsx +0 -65
  12. package/src/components/ChartAnalytics/components/DownloadMenu/interfaces/menu.ts +0 -1
  13. package/src/components/ChartAnalytics/hooks/useChart.ts +0 -35
  14. package/src/components/ChartAnalytics/index.tsx +0 -28
  15. package/src/components/ChartAnalytics/models/bar.ts +0 -20
  16. package/src/components/ChartAnalytics/models/column.ts +0 -52
  17. package/src/components/ChartAnalytics/models/index.ts +0 -111
  18. package/src/components/ChartAnalytics/models/line.ts +0 -31
  19. package/src/components/ChartAnalytics/models/multi-series.ts +0 -115
  20. package/src/components/ChartAnalytics/models/pie.ts +0 -54
  21. package/src/components/ChartAnalytics/services/export.ts +0 -38
  22. package/src/components/ChartAnalytics/styles/custom-highchart.css +0 -48
  23. package/src/components/ChartAnalytics/types/props.tsx +0 -48
  24. package/src/components/ChartAnalytics/utils/chart.ts +0 -128
  25. package/src/components/CircularProgressDashboard/CircularProgressIndicator.test.tsx +0 -9
  26. package/src/components/CircularProgressDashboard/index.tsx +0 -36
  27. package/src/components/CircularProgressDashboard/types/props.tsx +0 -17
  28. package/src/components/CustomPivotTable/components/Table/index.tsx +0 -23
  29. package/src/components/CustomPivotTable/components/TableBody/TableBody.module.css +0 -12
  30. package/src/components/CustomPivotTable/components/TableBody/index.tsx +0 -96
  31. package/src/components/CustomPivotTable/components/TableHeaders/TableHeaders.module.css +0 -10
  32. package/src/components/CustomPivotTable/components/TableHeaders/index.tsx +0 -94
  33. package/src/components/CustomPivotTable/index.tsx +0 -63
  34. package/src/components/CustomPivotTable/interfaces/index.ts +0 -1
  35. package/src/components/CustomPivotTable/services/engine.ts +0 -102
  36. package/src/components/CustomPivotTable/state/engine.tsx +0 -22
  37. package/src/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfigModal.stories.tsx +0 -28
  38. package/src/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfiguration.stories.tsx +0 -34
  39. package/src/components/Map/components/EarthEngineLayerConfiguration/index.tsx +0 -412
  40. package/src/components/Map/components/MapArea/index.tsx +0 -83
  41. package/src/components/Map/components/MapArea/interfaces/index.ts +0 -39
  42. package/src/components/Map/components/MapControls/components/CustomControl/index.tsx +0 -24
  43. package/src/components/Map/components/MapControls/components/DownloadControl/index.tsx +0 -11
  44. package/src/components/Map/components/MapControls/components/FullscreenControl/index.tsx +0 -7
  45. package/src/components/Map/components/MapControls/index.tsx +0 -24
  46. package/src/components/Map/components/MapLayer/components/BoundaryLayer/hooks/useBoundaryData.ts +0 -7
  47. package/src/components/Map/components/MapLayer/components/BoundaryLayer/index.tsx +0 -55
  48. package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/components/EarthEngineLegend.tsx +0 -74
  49. package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/constants/index.ts +0 -430
  50. package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/hooks/index.ts +0 -34
  51. package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/index.tsx +0 -185
  52. package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/interfaces/index.ts +0 -56
  53. package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/services/api.js +0 -34241
  54. package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/services/engine.ts +0 -431
  55. package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/utils/index.ts +0 -105
  56. package/src/components/Map/components/MapLayer/components/LegendArea/LegendArea.module.css +0 -12
  57. package/src/components/Map/components/MapLayer/components/LegendArea/components/LegendCardHeader/index.tsx +0 -17
  58. package/src/components/Map/components/MapLayer/components/LegendArea/index.tsx +0 -167
  59. package/src/components/Map/components/MapLayer/components/PointLayer/components/PointLegend/index.tsx +0 -44
  60. package/src/components/Map/components/MapLayer/components/PointLayer/hooks/index.ts +0 -8
  61. package/src/components/Map/components/MapLayer/components/PointLayer/index.tsx +0 -36
  62. package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubble.tsx +0 -48
  63. package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubbles.tsx +0 -150
  64. package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/index.tsx +0 -39
  65. package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/index.tsx +0 -57
  66. package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/components/ChoroplethLegend.tsx +0 -43
  67. package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/index.tsx +0 -38
  68. package/src/components/Map/components/MapLayer/components/ThematicLayer/components/CustomTooltip/index.tsx +0 -26
  69. package/src/components/Map/components/MapLayer/components/ThematicLayer/hooks/config.ts +0 -10
  70. package/src/components/Map/components/MapLayer/components/ThematicLayer/index.tsx +0 -46
  71. package/src/components/Map/components/MapLayer/components/ThematicLayer/styles/legends.css +0 -62
  72. package/src/components/Map/components/MapLayer/index.tsx +0 -32
  73. package/src/components/Map/components/MapLayer/interfaces/index.ts +0 -139
  74. package/src/components/Map/components/MapProvider/components/MapLayerProvider/hooks/index.tsx +0 -368
  75. package/src/components/Map/components/MapProvider/components/MapLayerProvider/index.tsx +0 -105
  76. package/src/components/Map/components/MapProvider/hooks/index.ts +0 -14
  77. package/src/components/Map/components/MapProvider/index.tsx +0 -93
  78. package/src/components/Map/components/MapUpdater/index.tsx +0 -8
  79. package/src/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfigModal.stories.tsx +0 -28
  80. package/src/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfiguration.stories.tsx +0 -34
  81. package/src/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/components/ColorScale/index.tsx +0 -24
  82. package/src/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/constants/colors.ts +0 -433
  83. package/src/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/index.tsx +0 -50
  84. package/src/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/styles/ColorScale.module.css +0 -15
  85. package/src/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/styles/ColorScaleSelect.module.css +0 -12
  86. package/src/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/utils/colors.ts +0 -91
  87. package/src/components/Map/components/ThematicLayerConfiguration/components/CustomLegend/index.tsx +0 -45
  88. package/src/components/Map/components/ThematicLayerConfiguration/components/IndicatorSelectorModal/index.tsx +0 -47
  89. package/src/components/Map/components/ThematicLayerConfiguration/components/LegendSetSelector/index.tsx +0 -57
  90. package/src/components/Map/components/ThematicLayerConfiguration/index.tsx +0 -248
  91. package/src/components/Map/constants/colors.ts +0 -434
  92. package/src/components/Map/constants/legendSet.ts +0 -19
  93. package/src/components/Map/hooks/map.ts +0 -47
  94. package/src/components/Map/index.tsx +0 -65
  95. package/src/components/Map/interfaces/index.ts +0 -57
  96. package/src/components/Map/state/index.tsx +0 -31
  97. package/src/components/Map/utils/colors.ts +0 -95
  98. package/src/components/Map/utils/helpers.ts +0 -15
  99. package/src/components/Map/utils/map.ts +0 -150
  100. package/src/components/SingleValueContainer/SingleValueContainer.test.tsx +0 -24
  101. package/src/components/SingleValueContainer/components/SingleValueItem/SingleValueItem.tsx +0 -46
  102. package/src/components/SingleValueContainer/components/SingleValueItem/SingleValuePercentage.tsx +0 -12
  103. package/src/components/SingleValueContainer/index.tsx +0 -37
  104. package/src/components/SingleValueContainer/styles/SingleValueContainer.module.css +0 -39
  105. package/src/components/SingleValueContainer/types/props.tsx +0 -16
  106. package/src/components/Visualization/components/AnalyticsDataProvider/index.tsx +0 -76
  107. package/src/components/Visualization/components/DimensionsProvider/index.tsx +0 -51
  108. package/src/components/Visualization/components/LayoutProvider/index.tsx +0 -34
  109. package/src/components/Visualization/components/VisualizationDimensionSelector/index.tsx +0 -59
  110. package/src/components/Visualization/components/VisualizationProvider/index.tsx +0 -31
  111. package/src/components/Visualization/components/VisualizationSelector/index.tsx +0 -157
  112. package/src/components/Visualization/components/VisualizationTypeProvider/index.tsx +0 -40
  113. package/src/components/Visualization/components/VisualizationTypeSelector/index.tsx +0 -46
  114. package/src/components/Visualization/index.tsx +0 -103
  115. package/src/index.ts +0 -6
  116. package/src/locales/en/translations.json +0 -138
  117. package/src/locales/index.js +0 -16
  118. package/tsconfig.build.json +0 -46
  119. package/tsconfig.json +0 -51
@@ -1,105 +0,0 @@
1
- import i18n from "@dhis2/d2-i18n";
2
- import {CenteredContent, CircularLoader} from "@dhis2/ui";
3
- import {LayersControlEvent} from "leaflet";
4
- import {compact, find, head, set} from "lodash";
5
- import React, {useCallback, useEffect, useState} from "react";
6
- import {useMapEvents} from "react-leaflet";
7
- import {MapLayersContext} from "../../../../state";
8
- import {MapLayerConfig} from "../../../MapArea/interfaces";
9
- import {
10
- CustomBoundaryLayer,
11
- CustomGoogleEngineLayer,
12
- CustomMapLayer,
13
- CustomPointLayer,
14
- CustomThematicLayer,
15
- ThematicLayerConfig,
16
- } from "../../../MapLayer/interfaces";
17
- import {useMapOrganisationUnit, useMapPeriods} from "../../hooks";
18
- import {useGoogleEngineLayers, usePointLayer, useThematicLayers} from "./hooks";
19
-
20
- export function MapLayersProvider({ layers, children }: { layers: MapLayerConfig; children: React.ReactNode }) {
21
- const period = useMapPeriods();
22
- const orgUnit = useMapOrganisationUnit();
23
- const [updatedLayers, setUpdatedLayers] = useState<Array<CustomThematicLayer | CustomBoundaryLayer | CustomPointLayer | CustomGoogleEngineLayer>>([]);
24
- const { sanitizeLayers: sanitizeThematicLayers, error } = useThematicLayers();
25
- const { sanitizeLayer: sanitizePointLayer } = usePointLayer();
26
- const { sanitizeLayers: sanitizeEarthEngineLayers } = useGoogleEngineLayers();
27
- const [loading, setLoading] = useState(false);
28
-
29
- useMapEvents({
30
- overlayremove: (event) => {
31
- setupLayerListeners("remove", event);
32
- },
33
- overlayadd: (event) => {
34
- setupLayerListeners("add", event);
35
- },
36
- });
37
-
38
- const sanitizeLayers = async () => {
39
- setLoading(true);
40
- try {
41
- const { boundaryLayers, thematicLayers, pointLayers, earthEngineLayers } = layers;
42
- const sanitizedThematicLayers = await sanitizeThematicLayers([...(thematicLayers ?? [])] as ThematicLayerConfig[]);
43
- const sanitizedBoundaryLayers = (boundaryLayers ?? []) as CustomBoundaryLayer[];
44
- const sanitizedPointLayer = head(pointLayers ?? []) ? await sanitizePointLayer(head(pointLayers) as CustomPointLayer) : undefined;
45
- const sanitizedEarthEngineLayers = await sanitizeEarthEngineLayers([...(earthEngineLayers ?? [])] as unknown as CustomGoogleEngineLayer[]);
46
- setUpdatedLayers(
47
- compact([...(sanitizedBoundaryLayers ?? []), ...(sanitizedThematicLayers ?? []), sanitizedPointLayer, ...(sanitizedEarthEngineLayers ?? [])])
48
- );
49
- } catch (e: any) {
50
- console.error(`Error sanitizing layers`, e.toString());
51
- }
52
- setLoading(false);
53
- };
54
-
55
- const updateLayer = useCallback((id: string, updatedLayer: CustomMapLayer) => {
56
- setUpdatedLayers((prevLayers) => {
57
- const updatedLayers = [...prevLayers];
58
- const layerIndex = updatedLayers.findIndex((layer) => layer.id === updatedLayer.id);
59
- if (layerIndex < 0) {
60
- return prevLayers;
61
- }
62
- set(updatedLayers, layerIndex, updatedLayer);
63
- return updatedLayers;
64
- });
65
- }, []);
66
-
67
- useEffect(() => {
68
- sanitizeLayers().catch(console.error);
69
- }, [period, orgUnit]);
70
-
71
- const setupLayerListeners = (type: "add" | "remove", event: LayersControlEvent) => {
72
- const name = event.name;
73
-
74
- const layerConfig = find(updatedLayers, (layer: any) => {
75
- const nameFromConfig = layer?.name ?? layer?.dataItem?.displayname ?? layer?.label;
76
- return nameFromConfig === name;
77
- });
78
-
79
- if (layerConfig) {
80
- updateLayer(layerConfig.id, { ...layerConfig, enabled: type === "add" });
81
- }
82
- };
83
-
84
- if (loading) {
85
- return (
86
- <div style={{ height: "100%", width: "100%" }}>
87
- <CenteredContent>
88
- <CircularLoader small />
89
- </CenteredContent>
90
- </div>
91
- );
92
- }
93
- if (error) {
94
- return (
95
- <div style={{ height: "100%", width: "100%" }}>
96
- <CenteredContent>
97
- <h4>
98
- {i18n.t("Error")}: {error.message}
99
- </h4>
100
- </CenteredContent>
101
- </div>
102
- );
103
- }
104
- return <MapLayersContext.Provider value={{ layers: updatedLayers, updateLayer }}>{children}</MapLayersContext.Provider>;
105
- }
@@ -1,14 +0,0 @@
1
- import {useContext} from "react";
2
- import {MapLayersContext, MapOrgUnitContext, MapPeriodContext} from "../../../state";
3
-
4
- export function useMapOrganisationUnit() {
5
- return useContext(MapOrgUnitContext);
6
- }
7
-
8
- export function useMapPeriods() {
9
- return useContext(MapPeriodContext);
10
- }
11
-
12
- export function useMapLayers() {
13
- return useContext(MapLayersContext);
14
- }
@@ -1,93 +0,0 @@
1
- import {useDataQuery} from "@dhis2/app-runtime";
2
- import i18n from "@dhis2/d2-i18n";
3
- import {CenteredContent, CircularLoader} from "@dhis2/ui";
4
- import {compact, isEmpty} from "lodash";
5
- import React, {useEffect, useState} from "react";
6
- import {MapOrgUnit, MapProviderProps} from "../../interfaces";
7
- import {MapOrgUnitContext, MapPeriodContext} from "../../state";
8
- import {getOrgUnitsSelection, sanitizeOrgUnits, toGeoJson} from "../../utils/map";
9
- import {BasePeriod, PeriodUtility} from "@hisptz/dhis2-utils";
10
-
11
- const boundaryQuery = {
12
- boundaries: {
13
- resource: "geoFeatures",
14
- params: ({ orgUnitIds }: any) => ({
15
- ou: `ou:${orgUnitIds?.join(";")}`,
16
- }),
17
- },
18
- analytics: {
19
- resource: "analytics",
20
- params: ({ orgUnitIds }: any) => ({
21
- dimension: [`ou:${orgUnitIds.join(";")}`, `pe:${new Date().getFullYear()}`],
22
- skipData: true,
23
- hierarchyMeta: true,
24
- }),
25
- },
26
- };
27
-
28
- export function MapProvider({ children, orgUnitSelection, periodSelection }: MapProviderProps) {
29
- const [orgUnits, setOrgUnits] = useState<MapOrgUnit[]>([]);
30
- const { refetch, loading, error } = useDataQuery(boundaryQuery, { lazy: true });
31
-
32
- useEffect(() => {
33
- async function getOrgUnits() {
34
- const rawOrgUnitIds = getOrgUnitsSelection(orgUnitSelection);
35
- const data = await refetch({ orgUnitIds: rawOrgUnitIds });
36
- const { analytics, boundaries } = (data as any) ?? {};
37
- const rawOrgUnits = sanitizeOrgUnits(analytics?.metaData);
38
- const geoJSONObjects = toGeoJson(boundaries.filter((bound: any) => bound.co));
39
- const orgUnits: MapOrgUnit[] = compact(
40
- rawOrgUnits.map((orgUnit: any) => {
41
- const geoJSONObject: any = geoJSONObjects?.find((geoJSON: any) => geoJSON.properties.id === orgUnit.id);
42
-
43
- if (!geoJSONObject) {
44
- return;
45
- }
46
- return {
47
- ...orgUnit,
48
- geoJSON: geoJSONObject,
49
- bounds: [],
50
- level: geoJSONObject.properties.level,
51
- };
52
- })
53
- );
54
- setOrgUnits(orgUnits);
55
- }
56
-
57
- getOrgUnits().catch((error) => console.log(error));
58
- }, [orgUnitSelection, refetch]);
59
-
60
- if (loading) {
61
- return (
62
- <div style={{ height: "100%", width: "100%" }}>
63
- <CenteredContent>
64
- <CircularLoader small />
65
- </CenteredContent>
66
- </div>
67
- );
68
- }
69
-
70
- if (error) {
71
- return (
72
- <div style={{ height: "100%", width: "100%" }}>
73
- <CenteredContent>
74
- <h4>
75
- {i18n.t("Error")}: {error.message}
76
- </h4>
77
- </CenteredContent>
78
- </div>
79
- );
80
- }
81
-
82
- const periods: BasePeriod[] = compact(periodSelection?.periods?.map((pe) => PeriodUtility.getPeriodById(pe)));
83
-
84
- if (!isEmpty(orgUnits)) {
85
- return (
86
- <MapOrgUnitContext.Provider value={{ orgUnitSelection, orgUnits }}>
87
- <MapPeriodContext.Provider value={{ ...periodSelection, periods }}>{children}</MapPeriodContext.Provider>
88
- </MapOrgUnitContext.Provider>
89
- );
90
- }
91
-
92
- return null;
93
- }
@@ -1,8 +0,0 @@
1
- import {useCenterMap} from "../../hooks/map";
2
- import React from "react";
3
- import {LatLngTuple} from "leaflet";
4
-
5
- export default function MapUpdater({ bounds }: { bounds: LatLngTuple[] }) {
6
- const ref = useCenterMap({ bounds });
7
- return <div style={{ width: "100%", height: "100%" }} ref={ref}></div>;
8
- }
@@ -1,28 +0,0 @@
1
- import {Story} from "@storybook/react";
2
- import {ThematicLayerConfigModal, ThematicLayerConfigModalProps} from "./index";
3
- import React from "react";
4
-
5
- const Template: Story<ThematicLayerConfigModalProps> = (args) => {
6
- return <ThematicLayerConfigModal {...args} />;
7
- };
8
-
9
- export const Basic = Template.bind({});
10
- Basic.args = {
11
- onChange: console.info,
12
- onClose: () => {},
13
- open: true,
14
- };
15
-
16
- export default {
17
- title: "Analytics/Map/Thematic Layer Config Modal",
18
- component: ThematicLayerConfigModal,
19
- decorators: [
20
- (MapStory: any) => {
21
- return (
22
- <div style={{ width: "50%", height: "50%" }}>
23
- <MapStory />
24
- </div>
25
- );
26
- },
27
- ],
28
- };
@@ -1,34 +0,0 @@
1
- import {Story} from "@storybook/react";
2
- import {ThematicLayerConfiguration, ThematicLayerConfigurationProps} from "./index";
3
- import React from "react";
4
- import {useForm} from "react-hook-form";
5
- import {ThematicLayerConfig} from "../MapLayer/interfaces";
6
- import i18n from "@dhis2/d2-i18n";
7
- import {Button} from "@dhis2/ui";
8
-
9
- const Template: Story<ThematicLayerConfigurationProps> = (args) => {
10
- const form = useForm<ThematicLayerConfig>();
11
- return (
12
- <form className="column gap-16" onSubmit={form.handleSubmit(console.log)}>
13
- <ThematicLayerConfiguration {...args} form={form} />
14
- <Button type="submit">{i18n.t("Submit")}</Button>
15
- </form>
16
- );
17
- };
18
-
19
- export const Basic = Template.bind({});
20
- Basic.args = {};
21
-
22
- export default {
23
- title: "Analytics/Map/Thematic Layer Configuration",
24
- component: ThematicLayerConfiguration,
25
- decorators: [
26
- (MapStory: any) => {
27
- return (
28
- <div style={{ width: "50%", height: "50%" }}>
29
- <MapStory />
30
- </div>
31
- );
32
- },
33
- ],
34
- };
@@ -1,24 +0,0 @@
1
- import React from "react";
2
- import styles from "../../styles/ColorScale.module.css";
3
- import {COLOR_PALETTES} from "../../constants/colors";
4
-
5
- // Returns one color scale based on a code and number of classes
6
- const ColorScale = ({ scale, bins, width, onClick }: { scale: string; bins: number; width: number; onClick: (scale: string) => void }) => {
7
- const colors = (COLOR_PALETTES as any)?.[scale]?.[bins];
8
- const itemWidth = width ? width / bins : 36;
9
-
10
- return (
11
- <ul
12
- onClick={() => onClick(scale)}
13
- className={styles.colorScale}
14
- style={{
15
- ...(width && { width }),
16
- }}>
17
- {colors.map((color: string, index: number) => (
18
- <li key={index} className={styles.item} style={{ backgroundColor: color, width: itemWidth }} />
19
- ))}
20
- </ul>
21
- );
22
- };
23
-
24
- export default ColorScale;