@hisptz/dhis2-analytics 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/README.md +45 -0
  2. package/d2.config.js +8 -0
  3. package/package.json +55 -0
  4. package/src/components/ChartAnalytics/ChartAnalytics.stories.tsx +250 -0
  5. package/src/components/ChartAnalytics/ChartAnalytics.test.tsx +51 -0
  6. package/src/components/ChartAnalytics/components/DownloadMenu/components/Menu.tsx +48 -0
  7. package/src/components/ChartAnalytics/components/DownloadMenu/constants/menu.ts +38 -0
  8. package/src/components/ChartAnalytics/components/DownloadMenu/index.tsx +67 -0
  9. package/src/components/ChartAnalytics/components/DownloadMenu/interfaces/menu.ts +1 -0
  10. package/src/components/ChartAnalytics/data/column-data.json +210 -0
  11. package/src/components/ChartAnalytics/data/complex-multi-series-data.json +124 -0
  12. package/src/components/ChartAnalytics/data/multi-series-data.json +536 -0
  13. package/src/components/ChartAnalytics/data/pie-data.json +115 -0
  14. package/src/components/ChartAnalytics/data/stacked-chart-data.json +415 -0
  15. package/src/components/ChartAnalytics/hooks/useChart.ts +35 -0
  16. package/src/components/ChartAnalytics/index.tsx +23 -0
  17. package/src/components/ChartAnalytics/models/column.ts +50 -0
  18. package/src/components/ChartAnalytics/models/index.ts +78 -0
  19. package/src/components/ChartAnalytics/models/line.ts +31 -0
  20. package/src/components/ChartAnalytics/models/multi-series.ts +115 -0
  21. package/src/components/ChartAnalytics/models/pie.ts +54 -0
  22. package/src/components/ChartAnalytics/services/export.ts +38 -0
  23. package/src/components/ChartAnalytics/styles/custom-highchart.css +48 -0
  24. package/src/components/ChartAnalytics/types/props.tsx +48 -0
  25. package/src/components/ChartAnalytics/utils/chart.ts +123 -0
  26. package/src/components/CircularProgressDashboard/CircularProgressIndicator.stories.tsx +41 -0
  27. package/src/components/CircularProgressDashboard/CircularProgressIndicator.test.tsx +9 -0
  28. package/src/components/CircularProgressDashboard/index.tsx +35 -0
  29. package/src/components/CircularProgressDashboard/types/props.tsx +17 -0
  30. package/src/components/Map/Map.stories.tsx +339 -0
  31. package/src/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfigModal.stories.tsx +28 -0
  32. package/src/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfiguration.stories.tsx +34 -0
  33. package/src/components/Map/components/EarthEngineLayerConfiguration/index.tsx +412 -0
  34. package/src/components/Map/components/MapArea/index.tsx +83 -0
  35. package/src/components/Map/components/MapArea/interfaces/index.ts +39 -0
  36. package/src/components/Map/components/MapControls/components/CustomControl/index.tsx +24 -0
  37. package/src/components/Map/components/MapControls/components/DownloadControl/index.tsx +10 -0
  38. package/src/components/Map/components/MapControls/components/FullscreenControl/index.tsx +7 -0
  39. package/src/components/Map/components/MapControls/index.tsx +24 -0
  40. package/src/components/Map/components/MapLayer/components/BoundaryLayer/hooks/useBoundaryData.ts +7 -0
  41. package/src/components/Map/components/MapLayer/components/BoundaryLayer/index.tsx +55 -0
  42. package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/components/EarthEngineLegend.tsx +76 -0
  43. package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/constants/index.ts +430 -0
  44. package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/hooks/index.ts +34 -0
  45. package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/index.tsx +185 -0
  46. package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/interfaces/index.ts +56 -0
  47. package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/services/api.js +34233 -0
  48. package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/services/engine.ts +423 -0
  49. package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/utils/index.ts +105 -0
  50. package/src/components/Map/components/MapLayer/components/LegendArea/LegendArea.module.css +12 -0
  51. package/src/components/Map/components/MapLayer/components/LegendArea/components/LegendCardHeader/index.tsx +17 -0
  52. package/src/components/Map/components/MapLayer/components/LegendArea/index.tsx +168 -0
  53. package/src/components/Map/components/MapLayer/components/PointLayer/components/PointLegend/index.tsx +44 -0
  54. package/src/components/Map/components/MapLayer/components/PointLayer/hooks/index.ts +8 -0
  55. package/src/components/Map/components/MapLayer/components/PointLayer/index.tsx +36 -0
  56. package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubble.tsx +48 -0
  57. package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubbles.tsx +150 -0
  58. package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/index.tsx +39 -0
  59. package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/index.tsx +57 -0
  60. package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/components/ChoroplethLegend.tsx +43 -0
  61. package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/index.tsx +38 -0
  62. package/src/components/Map/components/MapLayer/components/ThematicLayer/components/CustomTooltip/index.tsx +26 -0
  63. package/src/components/Map/components/MapLayer/components/ThematicLayer/hooks/config.ts +10 -0
  64. package/src/components/Map/components/MapLayer/components/ThematicLayer/index.tsx +46 -0
  65. package/src/components/Map/components/MapLayer/components/ThematicLayer/styles/legends.css +62 -0
  66. package/src/components/Map/components/MapLayer/index.tsx +32 -0
  67. package/src/components/Map/components/MapLayer/interfaces/index.ts +139 -0
  68. package/src/components/Map/components/MapProvider/components/MapLayerProvider/hooks/index.tsx +359 -0
  69. package/src/components/Map/components/MapProvider/components/MapLayerProvider/index.tsx +105 -0
  70. package/src/components/Map/components/MapProvider/hooks/index.ts +14 -0
  71. package/src/components/Map/components/MapProvider/index.tsx +93 -0
  72. package/src/components/Map/components/MapUpdater/index.tsx +8 -0
  73. package/src/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfigModal.stories.tsx +28 -0
  74. package/src/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfiguration.stories.tsx +34 -0
  75. package/src/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/components/ColorScale/index.tsx +24 -0
  76. package/src/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/constants/colors.ts +433 -0
  77. package/src/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/index.tsx +50 -0
  78. package/src/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/styles/ColorScale.module.css +15 -0
  79. package/src/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/styles/ColorScaleSelect.module.css +12 -0
  80. package/src/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/utils/colors.ts +91 -0
  81. package/src/components/Map/components/ThematicLayerConfiguration/components/CustomLegend/index.tsx +45 -0
  82. package/src/components/Map/components/ThematicLayerConfiguration/components/IndicatorSelectorModal/index.tsx +47 -0
  83. package/src/components/Map/components/ThematicLayerConfiguration/components/LegendSetSelector/index.tsx +57 -0
  84. package/src/components/Map/components/ThematicLayerConfiguration/index.tsx +248 -0
  85. package/src/components/Map/constants/colors.ts +433 -0
  86. package/src/components/Map/constants/legendSet.ts +19 -0
  87. package/src/components/Map/hooks/map.ts +47 -0
  88. package/src/components/Map/index.tsx +65 -0
  89. package/src/components/Map/interfaces/index.ts +57 -0
  90. package/src/components/Map/state/index.tsx +31 -0
  91. package/src/components/Map/utils/colors.ts +95 -0
  92. package/src/components/Map/utils/helpers.ts +15 -0
  93. package/src/components/Map/utils/map.ts +150 -0
  94. package/src/components/SingleValueContainer/SingleValueContainer.stories.tsx +146 -0
  95. package/src/components/SingleValueContainer/SingleValueContainer.test.tsx +24 -0
  96. package/src/components/SingleValueContainer/components/SingleValueItem/SingleValueItem.tsx +46 -0
  97. package/src/components/SingleValueContainer/components/SingleValueItem/SingleValuePercentage.tsx +12 -0
  98. package/src/components/SingleValueContainer/index.tsx +30 -0
  99. package/src/components/SingleValueContainer/styles/SingleValueContainer.module.css +39 -0
  100. package/src/components/SingleValueContainer/types/props.tsx +16 -0
  101. package/src/data/map.json +5984 -0
  102. package/src/dataProviders/map.tsx +24 -0
  103. package/src/index.test.ts +7 -0
  104. package/src/index.ts +4 -0
  105. package/tsconfig.json +45 -0
@@ -0,0 +1,339 @@
1
+ import type {Story} from "@storybook/react";
2
+ import React from "react";
3
+ import {MapProps} from "./interfaces";
4
+ import Map from "./index";
5
+
6
+ const Template: Story<MapProps> = (args) => <Map {...args} />;
7
+
8
+ export const BaseMap = Template.bind({});
9
+ BaseMap.args = {
10
+ orgUnitSelection: { orgUnits: [], userOrgUnit: true, userSubUnit: true, userSubX2Unit: true },
11
+ };
12
+
13
+ export const Controls = Template.bind({});
14
+ Controls.args = {
15
+ orgUnitSelection: { orgUnits: [], userOrgUnit: true, userSubUnit: true, userSubX2Unit: true },
16
+ controls: [
17
+ {
18
+ type: "print",
19
+ position: "topleft",
20
+ options: {
21
+ hidden: false,
22
+ hideControlContainer: true,
23
+ sizeModes: ["A4Landscape", "A4Portrait", "Current"],
24
+ },
25
+ },
26
+ ],
27
+ };
28
+
29
+ export const BoundaryLayer = Template.bind({});
30
+ BoundaryLayer.args = {
31
+ orgUnitSelection: { orgUnits: [], userOrgUnit: true, userSubUnit: true, userSubX2Unit: true },
32
+ boundaryLayer: {
33
+ enabled: true,
34
+ },
35
+ };
36
+
37
+ export const BoundaryLayerWithLevels = Template.bind({});
38
+ BoundaryLayerWithLevels.args = {
39
+ orgUnitSelection: {
40
+ orgUnits: [
41
+ {
42
+ id: "ImspTQPwCqd",
43
+ displayName: "Sierra Leone",
44
+ name: "Sierra Leone",
45
+ path: "/ImspTQPwCqd",
46
+ children: [],
47
+ },
48
+ ],
49
+ levels: ["2"],
50
+ },
51
+ boundaryLayer: {
52
+ enabled: true,
53
+ },
54
+ };
55
+
56
+ export const ChoroplethThematicLayer = Template.bind({});
57
+ ChoroplethThematicLayer.args = {
58
+ orgUnitSelection: { orgUnits: [], userOrgUnit: true, userSubUnit: true, userSubX2Unit: false },
59
+ boundaryLayer: {
60
+ enabled: true,
61
+ },
62
+ thematicLayers: [
63
+ {
64
+ type: "choropleth",
65
+ id: "choropleth",
66
+ enabled: true,
67
+ dataItem: {
68
+ id: "Uvn6LCg7dVU",
69
+ displayName: "ANC 1 Coverage",
70
+ type: "indicator",
71
+ },
72
+ control: {
73
+ enabled: true,
74
+ position: "topright",
75
+ },
76
+ },
77
+ ],
78
+ periodSelection: {
79
+ periods: ["2022"],
80
+ },
81
+ legends: {
82
+ enabled: true,
83
+ position: "topright",
84
+ collapsible: true,
85
+ },
86
+ };
87
+
88
+ export const BubbleThematicLayer = Template.bind({});
89
+ BubbleThematicLayer.args = {
90
+ orgUnitSelection: { orgUnits: [], userOrgUnit: true, userSubUnit: true, userSubX2Unit: true },
91
+ boundaryLayer: {
92
+ enabled: true,
93
+ },
94
+ thematicLayers: [
95
+ {
96
+ type: "bubble",
97
+ id: "bubble",
98
+ enabled: true,
99
+ dataItem: {
100
+ id: "Uvn6LCg7dVU",
101
+ displayName: "ANC 1 Coverage",
102
+ type: "indicator",
103
+ },
104
+ control: {
105
+ enabled: true,
106
+ position: "topright",
107
+ },
108
+ radius: {
109
+ min: 0,
110
+ max: 40,
111
+ },
112
+ },
113
+ ],
114
+ legends: {
115
+ enabled: true,
116
+ position: "topright",
117
+ collapsible: true,
118
+ },
119
+ periodSelection: {
120
+ periods: ["2022"],
121
+ },
122
+ controls: [
123
+ {
124
+ type: "fullscreen",
125
+ position: "topleft",
126
+ },
127
+ ],
128
+ };
129
+
130
+ export const AllThematicLayers = Template.bind({});
131
+ AllThematicLayers.args = {
132
+ orgUnitSelection: { orgUnits: [], userOrgUnit: true, userSubUnit: true, userSubX2Unit: true },
133
+ boundaryLayer: {
134
+ enabled: true,
135
+ },
136
+ thematicLayers: [
137
+ {
138
+ type: "choropleth",
139
+ id: "ReUHfIn0pTQ",
140
+ enabled: true,
141
+ dataItem: {
142
+ id: "ReUHfIn0pTQ",
143
+ displayName: "ANC 1-3 Dropout Rate",
144
+ type: "indicator",
145
+ legendSet: "fqs276KXCXi",
146
+ },
147
+ control: {
148
+ enabled: true,
149
+ position: "topright",
150
+ },
151
+ },
152
+ {
153
+ type: "choropleth",
154
+ id: "Uvn6LCg7dVU",
155
+ enabled: true,
156
+ dataItem: {
157
+ id: "Uvn6LCg7dVU",
158
+ displayName: "ANC 1 Coverage",
159
+ type: "indicator",
160
+ },
161
+ control: {
162
+ enabled: true,
163
+ position: "topright",
164
+ },
165
+ },
166
+ ],
167
+ legends: {
168
+ enabled: true,
169
+ position: "topright",
170
+ collapsible: true,
171
+ },
172
+ periodSelection: {
173
+ periods: ["2022"],
174
+ },
175
+ controls: [
176
+ {
177
+ type: "scale",
178
+ position: "bottomleft",
179
+ options: {
180
+ imperial: false,
181
+ metric: true,
182
+ },
183
+ },
184
+ {
185
+ type: "fullscreen",
186
+ position: "bottomleft",
187
+ },
188
+ ],
189
+ };
190
+
191
+ export const ChoroplethThematicLayerWithLevels = Template.bind({});
192
+ ChoroplethThematicLayerWithLevels.args = {
193
+ orgUnitSelection: {
194
+ orgUnits: [
195
+ {
196
+ id: "ImspTQPwCqd",
197
+ displayName: "Sierra Leone",
198
+ name: "Sierra Leone",
199
+ path: "/ImspTQPwCqd",
200
+ children: [],
201
+ },
202
+ ],
203
+ levels: ["3"],
204
+ },
205
+ boundaryLayer: {
206
+ enabled: true,
207
+ },
208
+ thematicLayers: [
209
+ {
210
+ type: "choropleth",
211
+ id: "choropleth",
212
+ enabled: true,
213
+ dataItem: {
214
+ id: "Uvn6LCg7dVU",
215
+ displayName: "ANC 1 Coverage",
216
+ type: "indicator",
217
+ },
218
+ control: {
219
+ enabled: true,
220
+ position: "topright",
221
+ },
222
+ },
223
+ ],
224
+ legends: {
225
+ enabled: true,
226
+ position: "topright",
227
+ collapsible: true,
228
+ },
229
+ periodSelection: {
230
+ periods: ["2022"],
231
+ },
232
+ controls: [
233
+ {
234
+ type: "print",
235
+ position: "topleft",
236
+ options: {
237
+ hidden: false,
238
+ hideControlContainer: true,
239
+ sizeModes: ["A4Landscape", "A4Portrait", "Current"],
240
+ },
241
+ },
242
+ ],
243
+ };
244
+
245
+ export const PointLayer = Template.bind({});
246
+ PointLayer.args = {
247
+ orgUnitSelection: { orgUnits: [], userOrgUnit: true, userSubUnit: true, userSubX2Unit: false },
248
+ thematicLayers: [
249
+ {
250
+ type: "choropleth",
251
+ id: "choropleth",
252
+ enabled: true,
253
+ dataItem: {
254
+ id: "Uvn6LCg7dVU",
255
+ displayName: "ANC 1 Coverage",
256
+ type: "indicator",
257
+ },
258
+ control: {
259
+ enabled: true,
260
+ position: "topright",
261
+ },
262
+ },
263
+ ],
264
+ periodSelection: {
265
+ periods: ["2022"],
266
+ },
267
+ pointLayer: {
268
+ enabled: true,
269
+ label: "Facilities",
270
+ level: "m9lBJogzE95",
271
+ style: {
272
+ groupSet: "J5jldMd8OHv",
273
+ },
274
+ },
275
+ };
276
+
277
+ export const GoogleEarthEngineLayers = Template.bind({});
278
+ GoogleEarthEngineLayers.args = {
279
+ orgUnitSelection: { orgUnits: [], userOrgUnit: true, userSubUnit: true, userSubX2Unit: false },
280
+ thematicLayers: [],
281
+ periodSelection: {
282
+ periods: ["2022"],
283
+ },
284
+ earthEngineLayers: [
285
+ {
286
+ name: "Population",
287
+ type: "population",
288
+ id: "population",
289
+ enabled: false,
290
+ params: {
291
+ min: 0,
292
+ max: 10,
293
+ palette: "#f7fbff,#deebf7,#c6dbef,#9ecae1,#6baed6,#4292c6,#2171b5,#08519c,#08306b",
294
+ },
295
+ aggregations: ["sum", "mean"],
296
+ filters: {
297
+ period: "2020",
298
+ },
299
+ },
300
+ {
301
+ name: "Footprints",
302
+ type: "footprints",
303
+ id: "footprints",
304
+ aggregations: ["count"],
305
+ enabled: false,
306
+ },
307
+ {
308
+ name: "Land Cover",
309
+ type: "landCover",
310
+ id: "landCover",
311
+ enabled: true,
312
+ aggregations: ["percentage"],
313
+ },
314
+ ],
315
+ pointLayer: {
316
+ enabled: false,
317
+ label: "Facilities",
318
+ level: "m9lBJogzE95",
319
+ style: {
320
+ groupSet: "J5jldMd8OHv",
321
+ },
322
+ },
323
+ };
324
+
325
+ export default {
326
+ title: "Components/Map",
327
+ component: Map,
328
+ decorators: [
329
+ (MapStory: any) => {
330
+ return (
331
+ <div style={{ width: "100%", height: "100%" }}>
332
+ {/*<MapDataProvider>*/}
333
+ <MapStory />
334
+ {/*</MapDataProvider>*/}
335
+ </div>
336
+ );
337
+ },
338
+ ],
339
+ };
@@ -0,0 +1,28 @@
1
+ import {Story} from "@storybook/react";
2
+ import {EarthEngineLayerConfigModal, EarthEngineLayerConfigModalProps, EarthEngineLayerConfiguration} from "./index";
3
+ import React from "react";
4
+
5
+ const Template: Story<EarthEngineLayerConfigModalProps> = (args) => {
6
+ return <EarthEngineLayerConfigModal {...args} />;
7
+ };
8
+
9
+ export const Basic = Template.bind({});
10
+ Basic.args = {
11
+ onClose: () => {},
12
+ onChange: console.info,
13
+ open: true,
14
+ };
15
+
16
+ export default {
17
+ title: "Components/Map/Earth Engine Config Modal",
18
+ component: EarthEngineLayerConfiguration,
19
+ decorators: [
20
+ (MapStory: any) => {
21
+ return (
22
+ <div style={{ width: "50%", height: "50%" }}>
23
+ <MapStory />
24
+ </div>
25
+ );
26
+ },
27
+ ],
28
+ };
@@ -0,0 +1,34 @@
1
+ import {Story} from "@storybook/react";
2
+ import {EarthEngineLayerConfiguration, EarthEngineLayerConfigurationProps} from "./index";
3
+ import React from "react";
4
+ import {useForm} from "react-hook-form";
5
+ import {EarthEngineLayerConfig} from "../MapLayer/interfaces";
6
+ import i18n from "@dhis2/d2-i18n";
7
+ import {Button} from "@dhis2/ui";
8
+
9
+ const Template: Story<EarthEngineLayerConfigurationProps> = (args) => {
10
+ const form = useForm<EarthEngineLayerConfig>();
11
+ return (
12
+ <form className="column gap-16" onSubmit={form.handleSubmit(console.log)}>
13
+ <EarthEngineLayerConfiguration {...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: "Components/Map/Earth Engine Configuration",
24
+ component: EarthEngineLayerConfiguration,
25
+ decorators: [
26
+ (MapStory: any) => {
27
+ return (
28
+ <div style={{ width: "50%", height: "50%" }}>
29
+ <MapStory />
30
+ </div>
31
+ );
32
+ },
33
+ ],
34
+ };