@hisptz/dhis2-analytics 1.0.5 → 1.0.7
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/build/cjs/components/ChartAnalytics/ChartAnalytics.stories.js +253 -0
- package/build/cjs/components/ChartAnalytics/ChartAnalytics.test.js +51 -0
- package/build/cjs/components/ChartAnalytics/components/DownloadMenu/components/Menu.js +48 -0
- package/build/cjs/components/ChartAnalytics/components/DownloadMenu/constants/menu.js +34 -0
- package/build/cjs/components/ChartAnalytics/components/DownloadMenu/index.js +67 -0
- package/build/cjs/components/ChartAnalytics/components/DownloadMenu/interfaces/menu.js +1 -0
- package/{src → build/cjs}/components/ChartAnalytics/data/column-data.json +0 -0
- package/{src → build/cjs}/components/ChartAnalytics/data/complex-multi-series-data.json +0 -0
- package/{src → build/cjs}/components/ChartAnalytics/data/multi-series-data.json +0 -0
- package/{src → build/cjs}/components/ChartAnalytics/data/pie-data.json +0 -0
- package/{src → build/cjs}/components/ChartAnalytics/data/stacked-chart-data.json +0 -0
- package/build/cjs/components/ChartAnalytics/hooks/useChart.js +38 -0
- package/build/cjs/components/ChartAnalytics/index.js +69 -0
- package/build/cjs/components/ChartAnalytics/models/column.js +53 -0
- package/build/cjs/components/ChartAnalytics/models/index.js +102 -0
- package/build/cjs/components/ChartAnalytics/models/line.js +35 -0
- package/build/cjs/components/ChartAnalytics/models/multi-series.js +111 -0
- package/build/cjs/components/ChartAnalytics/models/pie.js +53 -0
- package/build/cjs/components/ChartAnalytics/services/export.js +50 -0
- package/{src → build/cjs}/components/ChartAnalytics/styles/custom-highchart.css +0 -0
- package/build/cjs/components/ChartAnalytics/types/props.js +1 -0
- package/build/cjs/components/ChartAnalytics/utils/chart.js +133 -0
- package/build/cjs/components/CircularProgressDashboard/CircularProgressIndicator.stories.js +45 -0
- package/build/cjs/components/CircularProgressDashboard/CircularProgressIndicator.test.js +13 -0
- package/build/cjs/components/CircularProgressDashboard/index.js +49 -0
- package/build/cjs/components/CircularProgressDashboard/types/props.js +1 -0
- package/build/cjs/components/Map/Map.stories.js +352 -0
- package/build/cjs/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfigModal.stories.js +32 -0
- package/build/cjs/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfiguration.stories.js +40 -0
- package/build/cjs/components/Map/components/EarthEngineLayerConfiguration/index.js +458 -0
- package/build/cjs/components/Map/components/MapArea/index.js +101 -0
- package/build/cjs/components/Map/components/MapArea/interfaces/index.js +1 -0
- package/build/cjs/components/Map/components/MapControls/components/CustomControl/index.js +32 -0
- package/build/cjs/components/Map/components/MapControls/components/DownloadControl/index.js +25 -0
- package/build/cjs/components/Map/components/MapControls/components/FullscreenControl/index.js +13 -0
- package/build/cjs/components/Map/components/MapControls/index.js +42 -0
- package/build/cjs/components/Map/components/MapLayer/components/BoundaryLayer/hooks/useBoundaryData.js +13 -0
- package/build/cjs/components/Map/components/MapLayer/components/BoundaryLayer/index.js +51 -0
- package/build/cjs/components/Map/components/MapLayer/components/GoogleEngineLayer/components/EarthEngineLegend.js +106 -0
- package/build/cjs/components/Map/components/MapLayer/components/GoogleEngineLayer/constants/index.js +379 -0
- package/build/cjs/components/Map/components/MapLayer/components/GoogleEngineLayer/hooks/index.js +36 -0
- package/build/cjs/components/Map/components/MapLayer/components/GoogleEngineLayer/index.js +200 -0
- package/build/cjs/components/Map/components/MapLayer/components/GoogleEngineLayer/interfaces/index.js +1 -0
- package/build/cjs/components/Map/components/MapLayer/components/GoogleEngineLayer/services/api.js +14 -0
- package/build/cjs/components/Map/components/MapLayer/components/GoogleEngineLayer/services/engine.js +412 -0
- package/build/cjs/components/Map/components/MapLayer/components/GoogleEngineLayer/utils/index.js +124 -0
- package/{src → build/cjs}/components/Map/components/MapLayer/components/LegendArea/LegendArea.module.css +0 -0
- package/build/cjs/components/Map/components/MapLayer/components/LegendArea/components/LegendCardHeader/index.js +26 -0
- package/build/cjs/components/Map/components/MapLayer/components/LegendArea/index.js +181 -0
- package/build/cjs/components/Map/components/MapLayer/components/PointLayer/components/PointLegend/index.js +86 -0
- package/build/cjs/components/Map/components/MapLayer/components/PointLayer/hooks/index.js +14 -0
- package/build/cjs/components/Map/components/MapLayer/components/PointLayer/index.js +46 -0
- package/build/cjs/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubble.js +57 -0
- package/build/cjs/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubbles.js +145 -0
- package/build/cjs/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/index.js +43 -0
- package/build/cjs/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/index.js +56 -0
- package/build/cjs/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/components/ChoroplethLegend.js +61 -0
- package/build/cjs/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/index.js +43 -0
- package/build/cjs/components/Map/components/MapLayer/components/ThematicLayer/components/CustomTooltip/index.js +35 -0
- package/build/cjs/components/Map/components/MapLayer/components/ThematicLayer/hooks/config.js +15 -0
- package/build/cjs/components/Map/components/MapLayer/components/ThematicLayer/index.js +57 -0
- package/{src → build/cjs}/components/Map/components/MapLayer/components/ThematicLayer/styles/legends.css +0 -0
- package/build/cjs/components/Map/components/MapLayer/index.js +40 -0
- package/build/cjs/components/Map/components/MapLayer/interfaces/index.js +8 -0
- package/build/cjs/components/Map/components/MapProvider/components/MapLayerProvider/hooks/index.js +389 -0
- package/build/cjs/components/Map/components/MapProvider/components/MapLayerProvider/index.js +116 -0
- package/build/cjs/components/Map/components/MapProvider/hooks/index.js +19 -0
- package/build/cjs/components/Map/components/MapProvider/index.js +121 -0
- package/build/cjs/components/Map/components/MapUpdater/index.js +24 -0
- package/build/cjs/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfigModal.stories.js +32 -0
- package/build/cjs/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfiguration.stories.js +40 -0
- package/build/cjs/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/components/ColorScale/index.js +40 -0
- package/build/cjs/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/constants/colors.js +428 -0
- package/build/cjs/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/index.js +63 -0
- package/{src → build/cjs}/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/styles/ColorScale.module.css +0 -0
- package/{src → build/cjs}/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/styles/ColorScaleSelect.module.css +0 -0
- package/build/cjs/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/utils/colors.js +72 -0
- package/build/cjs/components/Map/components/ThematicLayerConfiguration/components/CustomLegend/index.js +71 -0
- package/build/cjs/components/Map/components/ThematicLayerConfiguration/components/IndicatorSelectorModal/index.js +47 -0
- package/build/cjs/components/Map/components/ThematicLayerConfiguration/components/LegendSetSelector/index.js +79 -0
- package/build/cjs/components/Map/components/ThematicLayerConfiguration/index.js +265 -0
- package/build/cjs/components/Map/constants/colors.js +428 -0
- package/build/cjs/components/Map/constants/legendSet.js +22 -0
- package/build/cjs/components/Map/hooks/map.js +52 -0
- package/build/cjs/components/Map/index.js +108 -0
- package/build/cjs/components/Map/interfaces/index.js +1 -0
- package/build/cjs/components/Map/state/index.js +23 -0
- package/build/cjs/components/Map/utils/colors.js +78 -0
- package/build/cjs/components/Map/utils/helpers.js +25 -0
- package/build/cjs/components/Map/utils/map.js +161 -0
- package/build/cjs/components/SingleValueContainer/SingleValueContainer.stories.js +127 -0
- package/build/cjs/components/SingleValueContainer/SingleValueContainer.test.js +23 -0
- package/build/cjs/components/SingleValueContainer/components/SingleValueItem/SingleValueItem.js +54 -0
- package/build/cjs/components/SingleValueContainer/components/SingleValueItem/SingleValuePercentage.js +24 -0
- package/build/cjs/components/SingleValueContainer/index.js +43 -0
- package/{src → build/cjs}/components/SingleValueContainer/styles/SingleValueContainer.module.css +0 -0
- package/build/cjs/components/SingleValueContainer/types/props.js +1 -0
- package/{src → build/cjs}/data/map.json +0 -0
- package/build/cjs/dataProviders/map.js +31 -0
- package/build/cjs/index.js +49 -0
- package/build/cjs/locales/en/translations.json +128 -0
- package/build/cjs/locales/index.js +22 -0
- package/build/es/components/ChartAnalytics/ChartAnalytics.stories.js +235 -0
- package/build/es/components/ChartAnalytics/ChartAnalytics.test.js +46 -0
- package/build/es/components/ChartAnalytics/components/DownloadMenu/components/Menu.js +41 -0
- package/build/es/components/ChartAnalytics/components/DownloadMenu/constants/menu.js +26 -0
- package/build/es/components/ChartAnalytics/components/DownloadMenu/index.js +58 -0
- package/build/es/components/ChartAnalytics/components/DownloadMenu/interfaces/menu.js +1 -0
- package/build/es/components/ChartAnalytics/data/column-data.json +210 -0
- package/build/es/components/ChartAnalytics/data/complex-multi-series-data.json +124 -0
- package/build/es/components/ChartAnalytics/data/multi-series-data.json +536 -0
- package/build/es/components/ChartAnalytics/data/pie-data.json +115 -0
- package/build/es/components/ChartAnalytics/data/stacked-chart-data.json +415 -0
- package/build/es/components/ChartAnalytics/hooks/useChart.js +32 -0
- package/build/es/components/ChartAnalytics/index.js +40 -0
- package/build/es/components/ChartAnalytics/models/column.js +45 -0
- package/build/es/components/ChartAnalytics/models/index.js +95 -0
- package/build/es/components/ChartAnalytics/models/line.js +28 -0
- package/build/es/components/ChartAnalytics/models/multi-series.js +104 -0
- package/build/es/components/ChartAnalytics/models/pie.js +46 -0
- package/build/es/components/ChartAnalytics/services/export.js +36 -0
- package/build/es/components/ChartAnalytics/styles/custom-highchart.css +48 -0
- package/build/es/components/ChartAnalytics/types/props.js +1 -0
- package/build/es/components/ChartAnalytics/utils/chart.js +122 -0
- package/{src/components/CircularProgressDashboard/CircularProgressIndicator.stories.tsx → build/es/components/CircularProgressDashboard/CircularProgressIndicator.stories.js} +9 -16
- package/build/es/components/CircularProgressDashboard/CircularProgressIndicator.test.js +10 -0
- package/build/es/components/CircularProgressDashboard/index.js +41 -0
- package/build/es/components/CircularProgressDashboard/types/props.js +1 -0
- package/build/es/components/Map/Map.stories.js +334 -0
- package/build/es/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfigModal.stories.js +23 -0
- package/build/es/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfiguration.stories.js +31 -0
- package/build/es/components/Map/components/EarthEngineLayerConfiguration/index.js +448 -0
- package/build/es/components/Map/components/MapArea/index.js +91 -0
- package/build/es/components/Map/components/MapArea/interfaces/index.js +1 -0
- package/build/es/components/Map/components/MapControls/components/CustomControl/index.js +25 -0
- package/build/es/components/Map/components/MapControls/components/DownloadControl/index.js +18 -0
- package/build/es/components/Map/components/MapControls/components/FullscreenControl/index.js +6 -0
- package/build/es/components/Map/components/MapControls/index.js +35 -0
- package/build/es/components/Map/components/MapLayer/components/BoundaryLayer/hooks/useBoundaryData.js +7 -0
- package/build/es/components/Map/components/MapLayer/components/BoundaryLayer/index.js +41 -0
- package/build/es/components/Map/components/MapLayer/components/GoogleEngineLayer/components/EarthEngineLegend.js +95 -0
- package/build/es/components/Map/components/MapLayer/components/GoogleEngineLayer/constants/index.js +369 -0
- package/build/es/components/Map/components/MapLayer/components/GoogleEngineLayer/hooks/index.js +29 -0
- package/build/es/components/Map/components/MapLayer/components/GoogleEngineLayer/index.js +191 -0
- package/build/es/components/Map/components/MapLayer/components/GoogleEngineLayer/interfaces/index.js +1 -0
- package/build/es/components/Map/components/MapLayer/components/GoogleEngineLayer/services/api.js +14 -0
- package/build/es/components/Map/components/MapLayer/components/GoogleEngineLayer/services/engine.js +403 -0
- package/build/es/components/Map/components/MapLayer/components/GoogleEngineLayer/utils/index.js +111 -0
- package/build/es/components/Map/components/MapLayer/components/LegendArea/LegendArea.module.css +12 -0
- package/build/es/components/Map/components/MapLayer/components/LegendArea/components/LegendCardHeader/index.js +19 -0
- package/build/es/components/Map/components/MapLayer/components/LegendArea/index.js +172 -0
- package/build/es/components/Map/components/MapLayer/components/PointLayer/components/PointLegend/index.js +76 -0
- package/build/es/components/Map/components/MapLayer/components/PointLayer/hooks/index.js +8 -0
- package/build/es/components/Map/components/MapLayer/components/PointLayer/index.js +39 -0
- package/build/es/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubble.js +49 -0
- package/{src/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubbles.tsx → build/es/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubbles.js} +57 -74
- package/build/es/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/index.js +33 -0
- package/build/es/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/index.js +47 -0
- package/build/es/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/components/ChoroplethLegend.js +50 -0
- package/build/es/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/index.js +36 -0
- package/build/es/components/Map/components/MapLayer/components/ThematicLayer/components/CustomTooltip/index.js +28 -0
- package/build/es/components/Map/components/MapLayer/components/ThematicLayer/hooks/config.js +9 -0
- package/build/es/components/Map/components/MapLayer/components/ThematicLayer/index.js +50 -0
- package/build/es/components/Map/components/MapLayer/components/ThematicLayer/styles/legends.css +62 -0
- package/build/es/components/Map/components/MapLayer/index.js +33 -0
- package/build/es/components/Map/components/MapLayer/interfaces/index.js +1 -0
- package/build/es/components/Map/components/MapProvider/components/MapLayerProvider/hooks/index.js +381 -0
- package/build/es/components/Map/components/MapProvider/components/MapLayerProvider/index.js +107 -0
- package/{src/components/Map/components/MapProvider/hooks/index.ts → build/es/components/Map/components/MapProvider/hooks/index.js} +3 -6
- package/build/es/components/Map/components/MapProvider/index.js +112 -0
- package/build/es/components/Map/components/MapUpdater/index.js +17 -0
- package/build/es/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfigModal.stories.js +23 -0
- package/build/es/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfiguration.stories.js +31 -0
- package/build/es/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/components/ColorScale/index.js +33 -0
- package/{src/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/constants/colors.ts → build/es/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/constants/colors.js} +46 -59
- package/build/es/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/index.js +53 -0
- package/build/es/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/styles/ColorScale.module.css +15 -0
- package/build/es/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/styles/ColorScaleSelect.module.css +12 -0
- package/build/es/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/utils/colors.js +56 -0
- package/build/es/components/Map/components/ThematicLayerConfiguration/components/CustomLegend/index.js +64 -0
- package/build/es/components/Map/components/ThematicLayerConfiguration/components/IndicatorSelectorModal/index.js +38 -0
- package/build/es/components/Map/components/ThematicLayerConfiguration/components/LegendSetSelector/index.js +70 -0
- package/build/es/components/Map/components/ThematicLayerConfiguration/index.js +254 -0
- package/{src/components/Map/constants/colors.ts → build/es/components/Map/constants/colors.js} +46 -59
- package/build/es/components/Map/constants/legendSet.js +15 -0
- package/build/es/components/Map/hooks/map.js +44 -0
- package/build/es/components/Map/index.js +51 -0
- package/build/es/components/Map/interfaces/index.js +1 -0
- package/build/es/components/Map/state/index.js +14 -0
- package/build/es/components/Map/utils/colors.js +61 -0
- package/build/es/components/Map/utils/helpers.js +14 -0
- package/build/es/components/Map/utils/map.js +147 -0
- package/build/es/components/SingleValueContainer/SingleValueContainer.stories.js +115 -0
- package/build/es/components/SingleValueContainer/SingleValueContainer.test.js +20 -0
- package/build/es/components/SingleValueContainer/components/SingleValueItem/SingleValueItem.js +47 -0
- package/build/es/components/SingleValueContainer/components/SingleValueItem/SingleValuePercentage.js +17 -0
- package/build/es/components/SingleValueContainer/index.js +29 -0
- package/build/es/components/SingleValueContainer/styles/SingleValueContainer.module.css +39 -0
- package/build/es/components/SingleValueContainer/types/props.js +1 -0
- package/build/es/data/map.json +5984 -0
- package/build/es/dataProviders/map.js +24 -0
- package/build/es/index.js +5 -0
- package/build/es/locales/en/translations.json +128 -0
- package/build/es/locales/index.js +13 -0
- package/build/types/components/ChartAnalytics/components/DownloadMenu/components/Menu.d.ts +8 -0
- package/build/types/components/ChartAnalytics/components/DownloadMenu/constants/menu.d.ts +7 -0
- package/build/types/components/ChartAnalytics/components/DownloadMenu/index.d.ts +9 -0
- package/{src/components/ChartAnalytics/components/DownloadMenu/interfaces/menu.ts → build/types/components/ChartAnalytics/components/DownloadMenu/interfaces/menu.d.ts} +0 -0
- package/build/types/components/ChartAnalytics/hooks/useChart.d.ts +11 -0
- package/build/types/components/ChartAnalytics/index.d.ts +9 -0
- package/build/types/components/ChartAnalytics/models/column.d.ts +12 -0
- package/build/types/components/ChartAnalytics/models/index.d.ts +17 -0
- package/build/types/components/ChartAnalytics/models/line.d.ts +8 -0
- package/build/types/components/ChartAnalytics/models/multi-series.d.ts +9 -0
- package/build/types/components/ChartAnalytics/models/pie.d.ts +8 -0
- package/build/types/components/ChartAnalytics/services/export.d.ts +8 -0
- package/build/types/components/ChartAnalytics/types/props.d.ts +43 -0
- package/build/types/components/ChartAnalytics/utils/chart.d.ts +15 -0
- package/build/types/components/CircularProgressDashboard/index.d.ts +3 -0
- package/build/types/components/CircularProgressDashboard/types/props.d.ts +17 -0
- package/build/types/components/Map/components/EarthEngineLayerConfiguration/index.d.ts +17 -0
- package/build/types/components/Map/components/MapArea/index.d.ts +5 -0
- package/build/types/components/Map/components/MapArea/interfaces/index.d.ts +30 -0
- package/build/types/components/Map/components/MapControls/components/CustomControl/index.d.ts +7 -0
- package/build/types/components/Map/components/MapControls/components/DownloadControl/index.d.ts +8 -0
- package/build/types/components/Map/components/MapControls/components/FullscreenControl/index.d.ts +5 -0
- package/build/types/components/Map/components/MapControls/index.d.ts +6 -0
- package/build/types/components/Map/components/MapLayer/components/BoundaryLayer/hooks/useBoundaryData.d.ts +1 -0
- package/build/types/components/Map/components/MapLayer/components/BoundaryLayer/index.d.ts +15 -0
- package/build/types/components/Map/components/MapLayer/components/GoogleEngineLayer/components/EarthEngineLegend.d.ts +17 -0
- package/build/types/components/Map/components/MapLayer/components/GoogleEngineLayer/constants/index.d.ts +4 -0
- package/build/types/components/Map/components/MapLayer/components/GoogleEngineLayer/hooks/index.d.ts +9 -0
- package/build/types/components/Map/components/MapLayer/components/GoogleEngineLayer/index.d.ts +4 -0
- package/build/types/components/Map/components/MapLayer/components/GoogleEngineLayer/interfaces/index.d.ts +58 -0
- package/build/types/components/Map/components/MapLayer/components/GoogleEngineLayer/services/api.d.ts +1 -0
- package/build/types/components/Map/components/MapLayer/components/GoogleEngineLayer/services/engine.d.ts +55 -0
- package/build/types/components/Map/components/MapLayer/components/GoogleEngineLayer/utils/index.d.ts +20 -0
- package/build/types/components/Map/components/MapLayer/components/LegendArea/components/LegendCardHeader/index.d.ts +6 -0
- package/build/types/components/Map/components/MapLayer/components/LegendArea/index.d.ts +9 -0
- package/build/types/components/Map/components/MapLayer/components/PointLayer/components/PointLegend/index.d.ts +3 -0
- package/build/types/components/Map/components/MapLayer/components/PointLayer/hooks/index.d.ts +2 -0
- package/build/types/components/Map/components/MapLayer/components/PointLayer/index.d.ts +2 -0
- package/build/types/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubble.d.ts +13 -0
- package/build/types/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubbles.d.ts +10 -0
- package/build/types/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/index.d.ts +16 -0
- package/build/types/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/index.d.ts +12 -0
- package/build/types/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/components/ChoroplethLegend.d.ts +21 -0
- package/build/types/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/index.d.ts +12 -0
- package/build/types/components/Map/components/MapLayer/components/ThematicLayer/components/CustomTooltip/index.d.ts +5 -0
- package/build/types/components/Map/components/MapLayer/components/ThematicLayer/hooks/config.d.ts +2 -0
- package/build/types/components/Map/components/MapLayer/components/ThematicLayer/index.d.ts +5 -0
- package/build/types/components/Map/components/MapLayer/index.d.ts +6 -0
- package/build/types/components/Map/components/MapLayer/interfaces/index.d.ts +123 -0
- package/build/types/components/Map/components/MapProvider/components/MapLayerProvider/hooks/index.d.ts +9 -0
- package/build/types/components/Map/components/MapProvider/components/MapLayerProvider/index.d.ts +6 -0
- package/build/types/components/Map/components/MapProvider/hooks/index.d.ts +15 -0
- package/build/types/components/Map/components/MapProvider/index.d.ts +3 -0
- package/build/types/components/Map/components/MapUpdater/index.d.ts +5 -0
- package/build/types/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/components/ColorScale/index.d.ts +8 -0
- package/build/types/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/constants/colors.d.ts +419 -0
- package/build/types/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/index.d.ts +9 -0
- package/build/types/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/utils/colors.d.ts +11 -0
- package/build/types/components/Map/components/ThematicLayerConfiguration/components/CustomLegend/index.d.ts +2 -0
- package/build/types/components/Map/components/ThematicLayerConfiguration/components/IndicatorSelectorModal/index.d.ts +8 -0
- package/build/types/components/Map/components/ThematicLayerConfiguration/components/LegendSetSelector/index.d.ts +9 -0
- package/build/types/components/Map/components/ThematicLayerConfiguration/index.d.ts +18 -0
- package/build/types/components/Map/constants/colors.d.ts +419 -0
- package/build/types/components/Map/constants/legendSet.d.ts +7 -0
- package/build/types/components/Map/hooks/map.d.ts +9 -0
- package/build/types/components/Map/index.d.ts +8 -0
- package/build/types/components/Map/interfaces/index.d.ts +65 -0
- package/build/types/components/Map/state/index.d.ts +20 -0
- package/build/types/components/Map/utils/colors.d.ts +12 -0
- package/build/types/components/Map/utils/helpers.d.ts +6 -0
- package/build/types/components/Map/utils/map.d.ts +40 -0
- package/build/types/components/SingleValueContainer/components/SingleValueItem/SingleValueItem.d.ts +8 -0
- package/build/types/components/SingleValueContainer/components/SingleValueItem/SingleValuePercentage.d.ts +2 -0
- package/build/types/components/SingleValueContainer/index.d.ts +5 -0
- package/build/types/components/SingleValueContainer/types/props.d.ts +15 -0
- package/build/types/dataProviders/map.d.ts +4 -0
- package/{src/index.ts → build/types/index.d.ts} +0 -0
- package/package.json +26 -5
- package/d2.config.js +0 -8
- package/i18n/en.pot +0 -409
- package/src/components/ChartAnalytics/ChartAnalytics.stories.tsx +0 -250
- package/src/components/ChartAnalytics/ChartAnalytics.test.tsx +0 -51
- package/src/components/ChartAnalytics/components/DownloadMenu/components/Menu.tsx +0 -48
- package/src/components/ChartAnalytics/components/DownloadMenu/constants/menu.ts +0 -38
- package/src/components/ChartAnalytics/components/DownloadMenu/index.tsx +0 -67
- package/src/components/ChartAnalytics/hooks/useChart.ts +0 -35
- package/src/components/ChartAnalytics/index.tsx +0 -23
- package/src/components/ChartAnalytics/models/column.ts +0 -50
- package/src/components/ChartAnalytics/models/index.ts +0 -78
- package/src/components/ChartAnalytics/models/line.ts +0 -31
- package/src/components/ChartAnalytics/models/multi-series.ts +0 -115
- package/src/components/ChartAnalytics/models/pie.ts +0 -54
- package/src/components/ChartAnalytics/services/export.ts +0 -38
- package/src/components/ChartAnalytics/types/props.tsx +0 -48
- package/src/components/ChartAnalytics/utils/chart.ts +0 -123
- package/src/components/CircularProgressDashboard/CircularProgressIndicator.test.tsx +0 -9
- package/src/components/CircularProgressDashboard/index.tsx +0 -35
- package/src/components/CircularProgressDashboard/types/props.tsx +0 -17
- package/src/components/Map/Map.stories.tsx +0 -339
- package/src/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfigModal.stories.tsx +0 -28
- package/src/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfiguration.stories.tsx +0 -34
- package/src/components/Map/components/EarthEngineLayerConfiguration/index.tsx +0 -412
- package/src/components/Map/components/MapArea/index.tsx +0 -83
- package/src/components/Map/components/MapArea/interfaces/index.ts +0 -39
- package/src/components/Map/components/MapControls/components/CustomControl/index.tsx +0 -24
- package/src/components/Map/components/MapControls/components/DownloadControl/index.tsx +0 -10
- package/src/components/Map/components/MapControls/components/FullscreenControl/index.tsx +0 -7
- package/src/components/Map/components/MapControls/index.tsx +0 -24
- package/src/components/Map/components/MapLayer/components/BoundaryLayer/hooks/useBoundaryData.ts +0 -7
- package/src/components/Map/components/MapLayer/components/BoundaryLayer/index.tsx +0 -55
- package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/components/EarthEngineLegend.tsx +0 -76
- package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/constants/index.ts +0 -430
- package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/hooks/index.ts +0 -34
- package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/index.tsx +0 -185
- package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/interfaces/index.ts +0 -56
- package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/services/api.js +0 -34233
- package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/services/engine.ts +0 -431
- package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/utils/index.ts +0 -105
- package/src/components/Map/components/MapLayer/components/LegendArea/components/LegendCardHeader/index.tsx +0 -17
- package/src/components/Map/components/MapLayer/components/LegendArea/index.tsx +0 -168
- package/src/components/Map/components/MapLayer/components/PointLayer/components/PointLegend/index.tsx +0 -44
- package/src/components/Map/components/MapLayer/components/PointLayer/hooks/index.ts +0 -8
- package/src/components/Map/components/MapLayer/components/PointLayer/index.tsx +0 -36
- package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubble.tsx +0 -48
- package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/index.tsx +0 -39
- package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/index.tsx +0 -57
- package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/components/ChoroplethLegend.tsx +0 -43
- package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/index.tsx +0 -38
- package/src/components/Map/components/MapLayer/components/ThematicLayer/components/CustomTooltip/index.tsx +0 -26
- package/src/components/Map/components/MapLayer/components/ThematicLayer/hooks/config.ts +0 -10
- package/src/components/Map/components/MapLayer/components/ThematicLayer/index.tsx +0 -46
- package/src/components/Map/components/MapLayer/index.tsx +0 -32
- package/src/components/Map/components/MapLayer/interfaces/index.ts +0 -139
- package/src/components/Map/components/MapProvider/components/MapLayerProvider/hooks/index.tsx +0 -359
- package/src/components/Map/components/MapProvider/components/MapLayerProvider/index.tsx +0 -105
- package/src/components/Map/components/MapProvider/index.tsx +0 -93
- package/src/components/Map/components/MapUpdater/index.tsx +0 -8
- package/src/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfigModal.stories.tsx +0 -28
- package/src/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfiguration.stories.tsx +0 -34
- package/src/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/components/ColorScale/index.tsx +0 -24
- package/src/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/index.tsx +0 -50
- package/src/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/utils/colors.ts +0 -91
- package/src/components/Map/components/ThematicLayerConfiguration/components/CustomLegend/index.tsx +0 -45
- package/src/components/Map/components/ThematicLayerConfiguration/components/IndicatorSelectorModal/index.tsx +0 -47
- package/src/components/Map/components/ThematicLayerConfiguration/components/LegendSetSelector/index.tsx +0 -57
- package/src/components/Map/components/ThematicLayerConfiguration/index.tsx +0 -248
- package/src/components/Map/constants/legendSet.ts +0 -19
- package/src/components/Map/hooks/map.ts +0 -47
- package/src/components/Map/index.tsx +0 -65
- package/src/components/Map/interfaces/index.ts +0 -57
- package/src/components/Map/state/index.tsx +0 -31
- package/src/components/Map/utils/colors.ts +0 -95
- package/src/components/Map/utils/helpers.ts +0 -15
- package/src/components/Map/utils/map.ts +0 -150
- package/src/components/SingleValueContainer/SingleValueContainer.stories.tsx +0 -146
- package/src/components/SingleValueContainer/SingleValueContainer.test.tsx +0 -24
- package/src/components/SingleValueContainer/components/SingleValueItem/SingleValueItem.tsx +0 -46
- package/src/components/SingleValueContainer/components/SingleValueItem/SingleValuePercentage.tsx +0 -12
- package/src/components/SingleValueContainer/index.tsx +0 -30
- package/src/components/SingleValueContainer/types/props.tsx +0 -16
- package/src/dataProviders/map.tsx +0 -24
- package/src/index.test.ts +0 -7
- package/tsconfig.json +0 -45
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { colors } from "@dhis2/ui";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { GeoJSON } from "react-leaflet";
|
|
4
|
+
import { getColorFromLegendSet, highlightFeature, resetHighlight } from "../../../../../../utils/map";
|
|
5
|
+
import CustomTooltip from "../CustomTooltip";
|
|
6
|
+
const defaultStyle = {
|
|
7
|
+
weight: 1
|
|
8
|
+
};
|
|
9
|
+
const highlightStyle = {
|
|
10
|
+
weight: 2
|
|
11
|
+
};
|
|
12
|
+
export default function Choropleth(_ref) {
|
|
13
|
+
let {
|
|
14
|
+
data,
|
|
15
|
+
legends
|
|
16
|
+
} = _ref;
|
|
17
|
+
const {
|
|
18
|
+
orgUnit
|
|
19
|
+
} = data;
|
|
20
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(GeoJSON, {
|
|
21
|
+
data: orgUnit.geoJSON,
|
|
22
|
+
eventHandlers: {
|
|
23
|
+
mouseover: e => highlightFeature(e, highlightStyle),
|
|
24
|
+
mouseout: e => resetHighlight(e, defaultStyle)
|
|
25
|
+
},
|
|
26
|
+
pathOptions: {
|
|
27
|
+
fillColor: getColorFromLegendSet(legends, data.data),
|
|
28
|
+
fillOpacity: 1,
|
|
29
|
+
color: colors.grey900,
|
|
30
|
+
weight: 1
|
|
31
|
+
},
|
|
32
|
+
key: `${data.dataItem.id}-layer`
|
|
33
|
+
}, /*#__PURE__*/React.createElement(CustomTooltip, {
|
|
34
|
+
data: data
|
|
35
|
+
})));
|
|
36
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import i18n from "@dhis2/d2-i18n";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { Pane, Popup, Tooltip } from "react-leaflet";
|
|
4
|
+
import { useMapPeriods } from "../../../../../MapProvider/hooks";
|
|
5
|
+
export default function CustomTooltip(_ref) {
|
|
6
|
+
var _useMapPeriods;
|
|
7
|
+
let {
|
|
8
|
+
data: dataObject
|
|
9
|
+
} = _ref;
|
|
10
|
+
const {
|
|
11
|
+
dataItem,
|
|
12
|
+
orgUnit,
|
|
13
|
+
data
|
|
14
|
+
} = dataObject !== null && dataObject !== void 0 ? dataObject : {};
|
|
15
|
+
const {
|
|
16
|
+
periods
|
|
17
|
+
} = (_useMapPeriods = useMapPeriods()) !== null && _useMapPeriods !== void 0 ? _useMapPeriods : {};
|
|
18
|
+
return /*#__PURE__*/React.createElement(Pane, {
|
|
19
|
+
name: `${dataItem.displayName}-${orgUnit.id}-popup-pane`,
|
|
20
|
+
pane: "popupPane"
|
|
21
|
+
}, /*#__PURE__*/React.createElement(Tooltip, null, orgUnit === null || orgUnit === void 0 ? void 0 : orgUnit.name, " (", data, ")"), /*#__PURE__*/React.createElement(Popup, {
|
|
22
|
+
minWidth: 80
|
|
23
|
+
}, /*#__PURE__*/React.createElement("h3", {
|
|
24
|
+
style: {
|
|
25
|
+
margin: 0
|
|
26
|
+
}
|
|
27
|
+
}, orgUnit === null || orgUnit === void 0 ? void 0 : orgUnit.name), /*#__PURE__*/React.createElement("div", null, dataItem === null || dataItem === void 0 ? void 0 : dataItem.displayName), /*#__PURE__*/React.createElement("div", null, periods === null || periods === void 0 ? void 0 : periods.map(period => period.name).join(",")), /*#__PURE__*/React.createElement("div", null, i18n.t("Value"), ": ", data)));
|
|
28
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { find } from "lodash";
|
|
2
|
+
import { useContext } from "react";
|
|
3
|
+
import { MapLayersContext } from "../../../../../state";
|
|
4
|
+
export default function useThematicLayer(layerId) {
|
|
5
|
+
const {
|
|
6
|
+
layers
|
|
7
|
+
} = useContext(MapLayersContext);
|
|
8
|
+
return find(layers, ["id", layerId]);
|
|
9
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { last } from "lodash";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { LayerGroup, LayersControl, Pane } from "react-leaflet";
|
|
4
|
+
import Bubble from "./components/Bubble";
|
|
5
|
+
import Choropleth from "./components/Choropleth";
|
|
6
|
+
import useThematicLayer from "./hooks/config";
|
|
7
|
+
export default function ThematicLayer(_ref) {
|
|
8
|
+
let {
|
|
9
|
+
layerId,
|
|
10
|
+
index
|
|
11
|
+
} = _ref;
|
|
12
|
+
const layer = useThematicLayer(layerId);
|
|
13
|
+
if (!layer) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const {
|
|
17
|
+
type,
|
|
18
|
+
dataItem,
|
|
19
|
+
name,
|
|
20
|
+
data,
|
|
21
|
+
enabled,
|
|
22
|
+
legends
|
|
23
|
+
} = layer !== null && layer !== void 0 ? layer : {};
|
|
24
|
+
const uniqueName = name !== null && name !== void 0 ? name : dataItem.displayName;
|
|
25
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(LayersControl.Overlay, {
|
|
26
|
+
checked: enabled,
|
|
27
|
+
name: uniqueName
|
|
28
|
+
}, /*#__PURE__*/React.createElement(Pane, {
|
|
29
|
+
style: {
|
|
30
|
+
zIndex: type === "bubble" ? 500 : 500 - (index + 1)
|
|
31
|
+
},
|
|
32
|
+
name: uniqueName
|
|
33
|
+
}, /*#__PURE__*/React.createElement(LayerGroup, null, data === null || data === void 0 ? void 0 : data.map(datum => {
|
|
34
|
+
var _datum$dataItem, _datum$orgUnit;
|
|
35
|
+
return type === "choropleth" ? /*#__PURE__*/React.createElement(Choropleth, {
|
|
36
|
+
legends: legends !== null && legends !== void 0 ? legends : [],
|
|
37
|
+
data: datum,
|
|
38
|
+
key: `${datum === null || datum === void 0 ? void 0 : (_datum$dataItem = datum.dataItem) === null || _datum$dataItem === void 0 ? void 0 : _datum$dataItem.id}-${datum === null || datum === void 0 ? void 0 : (_datum$orgUnit = datum.orgUnit) === null || _datum$orgUnit === void 0 ? void 0 : _datum$orgUnit.id}-layer`
|
|
39
|
+
}) : null;
|
|
40
|
+
}), data === null || data === void 0 ? void 0 : data.map(datum => {
|
|
41
|
+
var _last$data, _last, _datum$dataItem2, _datum$orgUnit2;
|
|
42
|
+
return type === "bubble" ? /*#__PURE__*/React.createElement(Bubble, {
|
|
43
|
+
radius: layer === null || layer === void 0 ? void 0 : layer.radius,
|
|
44
|
+
legends: legends !== null && legends !== void 0 ? legends : [],
|
|
45
|
+
highestData: (_last$data = (_last = last(data)) === null || _last === void 0 ? void 0 : _last.data) !== null && _last$data !== void 0 ? _last$data : 1,
|
|
46
|
+
data: datum,
|
|
47
|
+
key: `${datum === null || datum === void 0 ? void 0 : (_datum$dataItem2 = datum.dataItem) === null || _datum$dataItem2 === void 0 ? void 0 : _datum$dataItem2.id}-${datum === null || datum === void 0 ? void 0 : (_datum$orgUnit2 = datum.orgUnit) === null || _datum$orgUnit2 === void 0 ? void 0 : _datum$orgUnit2.id}-layer`
|
|
48
|
+
}) : null;
|
|
49
|
+
})))));
|
|
50
|
+
}
|
package/build/es/components/Map/components/MapLayer/components/ThematicLayer/styles/legends.css
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
.legend-card {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
justify-content: center;
|
|
5
|
+
align-items: center;
|
|
6
|
+
height: 100%;
|
|
7
|
+
padding: 0.5rem;
|
|
8
|
+
border-radius: 0.2rem;
|
|
9
|
+
background-color: #fff;
|
|
10
|
+
box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
|
|
11
|
+
border: 2px solid rgba(0, 0, 0, 0.2);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.legend-card.collapsed {
|
|
15
|
+
padding: 0 !important;
|
|
16
|
+
float: right;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.legend-header {
|
|
20
|
+
font-weight: bold;
|
|
21
|
+
margin-bottom: 0.5rem;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.legend-item {
|
|
25
|
+
display: flex;
|
|
26
|
+
flex-direction: row;
|
|
27
|
+
align-items: center;
|
|
28
|
+
justify-content: start;
|
|
29
|
+
padding: 0 1rem;
|
|
30
|
+
gap: 16px;
|
|
31
|
+
width: 100%;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.legend-item-color {
|
|
35
|
+
width: 1rem;
|
|
36
|
+
height: 1rem;
|
|
37
|
+
border-radius: 1px;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.legend-item-label {
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.source-url {
|
|
44
|
+
background: none !important;
|
|
45
|
+
line-height: inherit !important;
|
|
46
|
+
text-align: inherit !important;
|
|
47
|
+
width: auto !important;
|
|
48
|
+
height: auto !important;
|
|
49
|
+
text-decoration: underline !important;
|
|
50
|
+
color: #0078A8 !important;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.legend-list {
|
|
54
|
+
display: flex;
|
|
55
|
+
flex-direction: column;
|
|
56
|
+
justify-content: flex-start;
|
|
57
|
+
align-items: center;
|
|
58
|
+
width: 100%;
|
|
59
|
+
height: 100%;
|
|
60
|
+
background-color: #fff;
|
|
61
|
+
gap: 4px;
|
|
62
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import BoundaryLayer from "./components/BoundaryLayer";
|
|
3
|
+
import GoogleEngineLayer from "./components/GoogleEngineLayer";
|
|
4
|
+
import { PointLayer } from "./components/PointLayer";
|
|
5
|
+
import ThematicLayer from "./components/ThematicLayer";
|
|
6
|
+
export default function MapLayer(_ref) {
|
|
7
|
+
let {
|
|
8
|
+
layer,
|
|
9
|
+
index
|
|
10
|
+
} = _ref;
|
|
11
|
+
switch (layer.type) {
|
|
12
|
+
case "overlay":
|
|
13
|
+
case "basemap":
|
|
14
|
+
return /*#__PURE__*/React.createElement(BoundaryLayer, layer);
|
|
15
|
+
case "bubble":
|
|
16
|
+
case "choropleth":
|
|
17
|
+
return /*#__PURE__*/React.createElement(ThematicLayer, {
|
|
18
|
+
layerId: layer.id,
|
|
19
|
+
index: index
|
|
20
|
+
});
|
|
21
|
+
case "point":
|
|
22
|
+
return /*#__PURE__*/React.createElement(PointLayer, null);
|
|
23
|
+
case "population":
|
|
24
|
+
case "elevation":
|
|
25
|
+
case "footprints":
|
|
26
|
+
case "landCover":
|
|
27
|
+
return /*#__PURE__*/React.createElement(GoogleEngineLayer, {
|
|
28
|
+
layerId: layer.id
|
|
29
|
+
});
|
|
30
|
+
default:
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const SUPPORTED_EARTH_ENGINE_LAYERS = ["population", "footprints", "elevation", "landCover"];
|
package/build/es/components/Map/components/MapProvider/components/MapLayerProvider/hooks/index.js
ADDED
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
import { compact, differenceBy, find, head, isEmpty, last, sortBy } from "lodash";
|
|
2
|
+
import { useMapOrganisationUnit, useMapPeriods } from "../../../hooks";
|
|
3
|
+
import { useCallback, useMemo, useState } from "react";
|
|
4
|
+
import { generateLegends, getOrgUnitsSelection, sanitizeDate, sanitizeOrgUnits, toGeoJson } from "../../../../../utils/map";
|
|
5
|
+
import { useDataEngine } from "@dhis2/app-runtime";
|
|
6
|
+
import { asyncify, map } from "async-es";
|
|
7
|
+
import { defaultClasses, defaultColorScaleName } from "../../../../../utils/colors";
|
|
8
|
+
import { useGoogleEngineToken } from "../../../../MapLayer/components/GoogleEngineLayer/hooks";
|
|
9
|
+
import { useBoundaryData } from "../../../../MapLayer/components/BoundaryLayer/hooks/useBoundaryData";
|
|
10
|
+
import { EarthEngine } from "../../../../MapLayer/components/GoogleEngineLayer/services/engine";
|
|
11
|
+
import { EARTH_ENGINE_LAYERS } from "../../../../MapLayer/components/GoogleEngineLayer/constants";
|
|
12
|
+
const analyticsQuery = {
|
|
13
|
+
analytics: {
|
|
14
|
+
resource: "analytics",
|
|
15
|
+
params: _ref => {
|
|
16
|
+
let {
|
|
17
|
+
ou,
|
|
18
|
+
pe,
|
|
19
|
+
dx,
|
|
20
|
+
startDate,
|
|
21
|
+
endDate
|
|
22
|
+
} = _ref;
|
|
23
|
+
const peDimension = !isEmpty(pe) ? `pe:${pe === null || pe === void 0 ? void 0 : pe.join(";")}` : undefined;
|
|
24
|
+
const ouDimension = !isEmpty(ou) ? `ou:${ou === null || ou === void 0 ? void 0 : ou.join(";")}` : undefined;
|
|
25
|
+
const dxDimension = !isEmpty(dx) ? `dx:${dx === null || dx === void 0 ? void 0 : dx.join(";")}` : undefined;
|
|
26
|
+
return {
|
|
27
|
+
dimension: compact([dxDimension, peDimension, ouDimension]),
|
|
28
|
+
startDate,
|
|
29
|
+
endDate,
|
|
30
|
+
displayProperty: "NAME"
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const query = {
|
|
36
|
+
layer: {
|
|
37
|
+
resource: "geoFeatures",
|
|
38
|
+
params: _ref2 => {
|
|
39
|
+
let {
|
|
40
|
+
ous
|
|
41
|
+
} = _ref2;
|
|
42
|
+
return {
|
|
43
|
+
ou: `ou:${ous.join(";")}`
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
analytics: {
|
|
48
|
+
resource: "analytics",
|
|
49
|
+
params: _ref3 => {
|
|
50
|
+
let {
|
|
51
|
+
ous
|
|
52
|
+
} = _ref3;
|
|
53
|
+
return {
|
|
54
|
+
dimension: [`ou:${ous.join(";")}`, `pe:${new Date().getFullYear()}`],
|
|
55
|
+
skipData: true,
|
|
56
|
+
hierarchyMeta: true
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const groupSetQuery = {
|
|
62
|
+
groupSet: {
|
|
63
|
+
resource: "organisationUnitGroupSets",
|
|
64
|
+
id: _ref4 => {
|
|
65
|
+
let {
|
|
66
|
+
groupSet
|
|
67
|
+
} = _ref4;
|
|
68
|
+
return groupSet;
|
|
69
|
+
},
|
|
70
|
+
params: {
|
|
71
|
+
fields: ["organisationUnitGroups[name,color,symbol,organisationUnits[id]]"]
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const legendSetsQuery = {
|
|
76
|
+
legendSets: {
|
|
77
|
+
resource: "legendSets",
|
|
78
|
+
id: _ref5 => {
|
|
79
|
+
let {
|
|
80
|
+
id
|
|
81
|
+
} = _ref5;
|
|
82
|
+
return id;
|
|
83
|
+
},
|
|
84
|
+
params: {
|
|
85
|
+
fields: ["id", "displayName", "legends[id,code,startValue,endValue,color]"]
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
export function useThematicLayers() {
|
|
90
|
+
var _useMapPeriods;
|
|
91
|
+
const engine = useDataEngine();
|
|
92
|
+
const [loading, setLoading] = useState(false);
|
|
93
|
+
const {
|
|
94
|
+
orgUnits,
|
|
95
|
+
orgUnitSelection
|
|
96
|
+
} = useMapOrganisationUnit();
|
|
97
|
+
const {
|
|
98
|
+
periods,
|
|
99
|
+
range
|
|
100
|
+
} = (_useMapPeriods = useMapPeriods()) !== null && _useMapPeriods !== void 0 ? _useMapPeriods : {};
|
|
101
|
+
const ou = useMemo(() => getOrgUnitsSelection(orgUnitSelection), [orgUnitSelection]);
|
|
102
|
+
const pe = useMemo(() => periods === null || periods === void 0 ? void 0 : periods.map(pe => pe.id), [periods]);
|
|
103
|
+
const {
|
|
104
|
+
startDate,
|
|
105
|
+
endDate
|
|
106
|
+
} = useMemo(() => {
|
|
107
|
+
if (!range) {
|
|
108
|
+
return {
|
|
109
|
+
startDate: undefined,
|
|
110
|
+
endDate: undefined
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
startDate: sanitizeDate(range.start.toDateString()),
|
|
115
|
+
endDate: sanitizeDate(range.end.toDateString())
|
|
116
|
+
};
|
|
117
|
+
}, [range]);
|
|
118
|
+
const sanitizeData = (data, layer) => {
|
|
119
|
+
if (data) {
|
|
120
|
+
const {
|
|
121
|
+
analytics
|
|
122
|
+
} = data;
|
|
123
|
+
const rows = analytics === null || analytics === void 0 ? void 0 : analytics.rows;
|
|
124
|
+
const ouIndex = analytics.headers.findIndex(header => header.name === "ou");
|
|
125
|
+
const dxIndex = analytics.headers.findIndex(header => header.name === "dx");
|
|
126
|
+
const valueIndex = analytics.headers.findIndex(header => header.name === "value");
|
|
127
|
+
if (!isEmpty(rows)) {
|
|
128
|
+
return sortBy(orgUnits === null || orgUnits === void 0 ? void 0 : orgUnits.map(ou => {
|
|
129
|
+
const row = rows.find(row => row[ouIndex] === ou.id && row[dxIndex] === layer.dataItem.id);
|
|
130
|
+
return {
|
|
131
|
+
orgUnit: ou,
|
|
132
|
+
data: row ? parseFloat(row[valueIndex]) : undefined,
|
|
133
|
+
dataItem: {
|
|
134
|
+
...layer.dataItem
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
}), ["data"]);
|
|
138
|
+
}
|
|
139
|
+
return [];
|
|
140
|
+
}
|
|
141
|
+
return [];
|
|
142
|
+
};
|
|
143
|
+
const sanitizeLegends = async layers => {
|
|
144
|
+
return await map(layers, asyncify(async layer => {
|
|
145
|
+
try {
|
|
146
|
+
const legends = [];
|
|
147
|
+
if (layer.dataItem.legendSet) {
|
|
148
|
+
const legendSetData = await engine.query(legendSetsQuery, {
|
|
149
|
+
variables: {
|
|
150
|
+
id: layer.dataItem.legendSet
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
const legendSet = legendSetData === null || legendSetData === void 0 ? void 0 : legendSetData.legendSets;
|
|
154
|
+
if (legendSet) {
|
|
155
|
+
legends.push(...legendSet.legends);
|
|
156
|
+
}
|
|
157
|
+
} else {
|
|
158
|
+
var _layer$dataItem$legen, _last$data, _last, _head$data, _head;
|
|
159
|
+
const {
|
|
160
|
+
scale,
|
|
161
|
+
colorClass
|
|
162
|
+
} = (_layer$dataItem$legen = layer.dataItem.legendConfig) !== null && _layer$dataItem$legen !== void 0 ? _layer$dataItem$legen : {
|
|
163
|
+
scale: defaultClasses,
|
|
164
|
+
colorClass: defaultColorScaleName
|
|
165
|
+
};
|
|
166
|
+
const sortedData = sortBy(layer.data, "data");
|
|
167
|
+
const autoLegends = generateLegends((_last$data = (_last = last(sortedData)) === null || _last === void 0 ? void 0 : _last.data) !== null && _last$data !== void 0 ? _last$data : 0, (_head$data = (_head = head(sortedData)) === null || _head === void 0 ? void 0 : _head.data) !== null && _head$data !== void 0 ? _head$data : 0, {
|
|
168
|
+
classesCount: scale,
|
|
169
|
+
colorClass
|
|
170
|
+
});
|
|
171
|
+
legends.push(...autoLegends);
|
|
172
|
+
}
|
|
173
|
+
return {
|
|
174
|
+
...layer,
|
|
175
|
+
legends
|
|
176
|
+
};
|
|
177
|
+
} catch (e) {
|
|
178
|
+
return layer;
|
|
179
|
+
}
|
|
180
|
+
}));
|
|
181
|
+
};
|
|
182
|
+
const sanitizeLayers = async layers => {
|
|
183
|
+
try {
|
|
184
|
+
setLoading(true);
|
|
185
|
+
const layersWithoutData = layers === null || layers === void 0 ? void 0 : layers.filter(layer => !layer.data);
|
|
186
|
+
const layersWithData = differenceBy(layers, layersWithoutData, "id");
|
|
187
|
+
const dx = layersWithoutData.map(layer => layer.dataItem.id);
|
|
188
|
+
let sanitizedLayersWithData = [];
|
|
189
|
+
if (!isEmpty(dx)) {
|
|
190
|
+
const data = await engine.query(analyticsQuery, {
|
|
191
|
+
variables: {
|
|
192
|
+
dx,
|
|
193
|
+
ou,
|
|
194
|
+
pe,
|
|
195
|
+
startDate,
|
|
196
|
+
endDate
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
sanitizedLayersWithData = layersWithoutData.map(layer => {
|
|
200
|
+
var _ref6, _layer$name, _layer$dataItem;
|
|
201
|
+
return {
|
|
202
|
+
...layer,
|
|
203
|
+
name: (_ref6 = (_layer$name = layer === null || layer === void 0 ? void 0 : layer.name) !== null && _layer$name !== void 0 ? _layer$name : layer === null || layer === void 0 ? void 0 : (_layer$dataItem = layer.dataItem) === null || _layer$dataItem === void 0 ? void 0 : _layer$dataItem.displayName) !== null && _ref6 !== void 0 ? _ref6 : layer.id,
|
|
204
|
+
data: sanitizeData(data, layer)
|
|
205
|
+
};
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
const sanitizedLayersWithOrgUnits = layersWithData.map(layer => {
|
|
209
|
+
var _layer$data;
|
|
210
|
+
return {
|
|
211
|
+
...layer,
|
|
212
|
+
data: (_layer$data = layer.data) === null || _layer$data === void 0 ? void 0 : _layer$data.map(datum => {
|
|
213
|
+
var _ref7, _layer$name2, _layer$dataItem2;
|
|
214
|
+
return {
|
|
215
|
+
...datum,
|
|
216
|
+
orgUnit: find(orgUnits, ["id", datum.orgUnit]),
|
|
217
|
+
dataItem: layer.dataItem,
|
|
218
|
+
name: (_ref7 = (_layer$name2 = layer === null || layer === void 0 ? void 0 : layer.name) !== null && _layer$name2 !== void 0 ? _layer$name2 : layer === null || layer === void 0 ? void 0 : (_layer$dataItem2 = layer.dataItem) === null || _layer$dataItem2 === void 0 ? void 0 : _layer$dataItem2.displayName) !== null && _ref7 !== void 0 ? _ref7 : layer.id
|
|
219
|
+
};
|
|
220
|
+
})
|
|
221
|
+
};
|
|
222
|
+
});
|
|
223
|
+
setLoading(false);
|
|
224
|
+
return await sanitizeLegends([...sanitizedLayersWithData, ...sanitizedLayersWithOrgUnits]);
|
|
225
|
+
} catch (e) {
|
|
226
|
+
console.error(`Error getting thematic layers`, e.details);
|
|
227
|
+
setLoading(false);
|
|
228
|
+
return [];
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
return {
|
|
232
|
+
sanitizeLayers,
|
|
233
|
+
loading
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
export function usePointLayer() {
|
|
237
|
+
const engine = useDataEngine();
|
|
238
|
+
const {
|
|
239
|
+
orgUnitSelection
|
|
240
|
+
} = useMapOrganisationUnit();
|
|
241
|
+
const [loading, setLoading] = useState(false);
|
|
242
|
+
const sanitizePointData = useCallback((orgUnitData, groupSetData) => {
|
|
243
|
+
var _ref8;
|
|
244
|
+
const {
|
|
245
|
+
analytics,
|
|
246
|
+
layer
|
|
247
|
+
} = (_ref8 = orgUnitData) !== null && _ref8 !== void 0 ? _ref8 : {};
|
|
248
|
+
const rawOrgUnits = sanitizeOrgUnits(analytics === null || analytics === void 0 ? void 0 : analytics.metaData);
|
|
249
|
+
const geoJSONObjects = toGeoJson(layer === null || layer === void 0 ? void 0 : layer.filter(bound => bound.co));
|
|
250
|
+
return compact(rawOrgUnits.map(orgUnit => {
|
|
251
|
+
var _organisationUnitGrou, _groupSetData$groupSe;
|
|
252
|
+
const geoJSONObject = geoJSONObjects === null || geoJSONObjects === void 0 ? void 0 : geoJSONObjects.find(geoJSON => geoJSON.properties.id === orgUnit.id);
|
|
253
|
+
const orgUnitGroups = (_organisationUnitGrou = groupSetData === null || groupSetData === void 0 ? void 0 : (_groupSetData$groupSe = groupSetData.groupSet) === null || _groupSetData$groupSe === void 0 ? void 0 : _groupSetData$groupSe.organisationUnitGroups) !== null && _organisationUnitGrou !== void 0 ? _organisationUnitGrou : [];
|
|
254
|
+
const ouGroup = find(orgUnitGroups, ouGroup => {
|
|
255
|
+
var _ouGroup$organisation;
|
|
256
|
+
return !!find((_ouGroup$organisation = ouGroup === null || ouGroup === void 0 ? void 0 : ouGroup.organisationUnits) !== null && _ouGroup$organisation !== void 0 ? _ouGroup$organisation : [], ["id", orgUnit.id]);
|
|
257
|
+
});
|
|
258
|
+
if (!geoJSONObject || geoJSONObject.properties.type !== "Point") {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
return {
|
|
262
|
+
...orgUnit,
|
|
263
|
+
geoJSON: geoJSONObject,
|
|
264
|
+
level: geoJSONObject.properties.level,
|
|
265
|
+
icon: {
|
|
266
|
+
type: "groupIcon",
|
|
267
|
+
icon: ouGroup === null || ouGroup === void 0 ? void 0 : ouGroup.symbol
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
}));
|
|
271
|
+
}, []);
|
|
272
|
+
const sanitizeLayer = useCallback(async layer => {
|
|
273
|
+
try {
|
|
274
|
+
var _layer$style, _organisationUnitGrou2, _groupSetData$groupSe2;
|
|
275
|
+
if (!layer.level && !layer.group) {
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
setLoading(true);
|
|
279
|
+
const level = layer.level ? `LEVEL-${layer.level}` : undefined;
|
|
280
|
+
const group = layer.group ? `OU_GROUP-${layer.group}` : undefined;
|
|
281
|
+
const ous = [...getOrgUnitsSelection(orgUnitSelection), level, group];
|
|
282
|
+
const pointData = await engine.query(query, {
|
|
283
|
+
variables: {
|
|
284
|
+
ous
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
const groupSetData = await engine.query(groupSetQuery, {
|
|
288
|
+
variables: {
|
|
289
|
+
groupSet: (_layer$style = layer.style) === null || _layer$style === void 0 ? void 0 : _layer$style.groupSet
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
const sanitizedOrgUnitData = sanitizePointData(pointData, groupSetData);
|
|
293
|
+
const orgUnitGroups = (_organisationUnitGrou2 = groupSetData === null || groupSetData === void 0 ? void 0 : (_groupSetData$groupSe2 = groupSetData.groupSet) === null || _groupSetData$groupSe2 === void 0 ? void 0 : _groupSetData$groupSe2.organisationUnitGroups) !== null && _organisationUnitGrou2 !== void 0 ? _organisationUnitGrou2 : [];
|
|
294
|
+
const sanitizedOrgUnitGroups = orgUnitGroups.map(ouGroup => ({
|
|
295
|
+
...ouGroup,
|
|
296
|
+
organisationUnits: undefined
|
|
297
|
+
}));
|
|
298
|
+
setLoading(false);
|
|
299
|
+
return {
|
|
300
|
+
...layer,
|
|
301
|
+
points: sanitizedOrgUnitData,
|
|
302
|
+
style: {
|
|
303
|
+
...layer.style,
|
|
304
|
+
orgUnitGroups: sanitizedOrgUnitGroups
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
} catch (e) {
|
|
308
|
+
setLoading(false);
|
|
309
|
+
console.error(`Error getting point layer`, e.details);
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
}, []);
|
|
313
|
+
return {
|
|
314
|
+
loading,
|
|
315
|
+
sanitizeLayer
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
export function useGoogleEngineLayers() {
|
|
319
|
+
const {
|
|
320
|
+
refresh
|
|
321
|
+
} = useGoogleEngineToken();
|
|
322
|
+
const orgUnits = useBoundaryData();
|
|
323
|
+
async function getImageUrl(earthEngine, _ref9) {
|
|
324
|
+
let {
|
|
325
|
+
filters
|
|
326
|
+
} = _ref9;
|
|
327
|
+
if (earthEngine.initialized) {
|
|
328
|
+
try {
|
|
329
|
+
earthEngine.setOrgUnits(orgUnits !== null && orgUnits !== void 0 ? orgUnits : []);
|
|
330
|
+
const period = filters === null || filters === void 0 ? void 0 : filters.period;
|
|
331
|
+
if (period) {
|
|
332
|
+
earthEngine.setPeriod(period);
|
|
333
|
+
}
|
|
334
|
+
return earthEngine.url();
|
|
335
|
+
} catch (e) {
|
|
336
|
+
console.error(e);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
const sanitizeLayers = useCallback(async layers => {
|
|
341
|
+
try {
|
|
342
|
+
const {
|
|
343
|
+
token
|
|
344
|
+
} = await refresh();
|
|
345
|
+
await EarthEngine.setToken(token, refresh);
|
|
346
|
+
return map(layers, asyncify(async layer => {
|
|
347
|
+
try {
|
|
348
|
+
var _find, _layer$aggregations, _layer$params;
|
|
349
|
+
const defaultOptions = (_find = find(EARTH_ENGINE_LAYERS, ["id", layer.type])) !== null && _find !== void 0 ? _find : {};
|
|
350
|
+
const options = {
|
|
351
|
+
...defaultOptions,
|
|
352
|
+
aggregations: (_layer$aggregations = layer.aggregations) !== null && _layer$aggregations !== void 0 ? _layer$aggregations : defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.aggregations,
|
|
353
|
+
params: (_layer$params = layer.params) !== null && _layer$params !== void 0 ? _layer$params : defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.params
|
|
354
|
+
};
|
|
355
|
+
const updatedLayer = {
|
|
356
|
+
...layer,
|
|
357
|
+
options
|
|
358
|
+
};
|
|
359
|
+
const earthEngine = new EarthEngine({
|
|
360
|
+
options
|
|
361
|
+
});
|
|
362
|
+
const url = await getImageUrl(earthEngine, updatedLayer);
|
|
363
|
+
return {
|
|
364
|
+
...updatedLayer,
|
|
365
|
+
engine: earthEngine,
|
|
366
|
+
url
|
|
367
|
+
};
|
|
368
|
+
} catch (e) {
|
|
369
|
+
console.error(e);
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
}));
|
|
373
|
+
} catch (e) {
|
|
374
|
+
console.error(`Error getting thematic layers`, e.details);
|
|
375
|
+
return [];
|
|
376
|
+
}
|
|
377
|
+
}, [refresh]);
|
|
378
|
+
return {
|
|
379
|
+
sanitizeLayers
|
|
380
|
+
};
|
|
381
|
+
}
|