@hisptz/dhis2-analytics 1.0.4 → 1.0.6
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 +10 -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/index.test.js +7 -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 +10 -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/{src/index.ts → build/es/index.js} +1 -0
- package/build/es/index.test.js +6 -0
- package/build/es/locales/en/translations.json +128 -0
- package/build/es/locales/index.js +13 -0
- package/package.json +21 -4
- 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/components/DownloadMenu/interfaces/menu.ts +0 -1
- 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 -423
- 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,172 @@
|
|
|
1
|
+
import { colors, IconLegend24, Popper, Portal } from "@dhis2/ui";
|
|
2
|
+
import { compact, head } from "lodash";
|
|
3
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
4
|
+
import { CustomControl } from "../../../MapControls/components/CustomControl";
|
|
5
|
+
import { SUPPORTED_EARTH_ENGINE_LAYERS } from "../../interfaces";
|
|
6
|
+
import PointLegend from "../PointLayer/components/PointLegend";
|
|
7
|
+
import BubbleLegend from "../ThematicLayer/components/Bubble/components/BubbleLegend";
|
|
8
|
+
import ChoroplethLegend from "../ThematicLayer/components/Choropleth/components/ChoroplethLegend";
|
|
9
|
+
import EarthEngineLegend from "../GoogleEngineLayer/components/EarthEngineLegend";
|
|
10
|
+
import classes from "./LegendArea.module.css";
|
|
11
|
+
import { usePrintMedia } from "../../../../hooks/map";
|
|
12
|
+
const TOOLTIP_OFFSET = 4;
|
|
13
|
+
function getLegendComponent(layer) {
|
|
14
|
+
var _ref, _radius, _head$dataItem, _head, _head$dataItem2, _head2;
|
|
15
|
+
if (layer.type === "point") {
|
|
16
|
+
return /*#__PURE__*/React.createElement(PointLegend, {
|
|
17
|
+
name: layer.label
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
if (SUPPORTED_EARTH_ENGINE_LAYERS.includes(layer.type)) {
|
|
21
|
+
var _layer$name;
|
|
22
|
+
return /*#__PURE__*/React.createElement(EarthEngineLegend, {
|
|
23
|
+
name: (_layer$name = layer.name) !== null && _layer$name !== void 0 ? _layer$name : "",
|
|
24
|
+
layer: layer
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
const {
|
|
28
|
+
type,
|
|
29
|
+
enabled,
|
|
30
|
+
control,
|
|
31
|
+
dataItem,
|
|
32
|
+
name,
|
|
33
|
+
data,
|
|
34
|
+
legends
|
|
35
|
+
} = (_ref = layer) !== null && _ref !== void 0 ? _ref : {};
|
|
36
|
+
if (!enabled || !control) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
switch (type) {
|
|
40
|
+
case "bubble":
|
|
41
|
+
return /*#__PURE__*/React.createElement(BubbleLegend, {
|
|
42
|
+
radius: (_radius = layer === null || layer === void 0 ? void 0 : layer.radius) !== null && _radius !== void 0 ? _radius : {
|
|
43
|
+
min: 0,
|
|
44
|
+
max: 50
|
|
45
|
+
},
|
|
46
|
+
legends: legends !== null && legends !== void 0 ? legends : [],
|
|
47
|
+
name: name !== null && name !== void 0 ? name : dataItem.displayName,
|
|
48
|
+
data: data,
|
|
49
|
+
dataItem: (_head$dataItem = (_head = head(data)) === null || _head === void 0 ? void 0 : _head.dataItem) !== null && _head$dataItem !== void 0 ? _head$dataItem : dataItem
|
|
50
|
+
});
|
|
51
|
+
case "choropleth":
|
|
52
|
+
return /*#__PURE__*/React.createElement(ChoroplethLegend, {
|
|
53
|
+
legends: legends !== null && legends !== void 0 ? legends : [],
|
|
54
|
+
name: name !== null && name !== void 0 ? name : dataItem.displayName,
|
|
55
|
+
data: data,
|
|
56
|
+
dataItem: (_head$dataItem2 = (_head2 = head(data)) === null || _head2 === void 0 ? void 0 : _head2.dataItem) !== null && _head$dataItem2 !== void 0 ? _head$dataItem2 : dataItem
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function CollapsedLegendIcon(_ref2) {
|
|
61
|
+
let {
|
|
62
|
+
onCollapse,
|
|
63
|
+
name
|
|
64
|
+
} = _ref2;
|
|
65
|
+
const openDelay = 200;
|
|
66
|
+
const closeDelay = 200;
|
|
67
|
+
const [openTooltip, setOpenTooltip] = useState(false);
|
|
68
|
+
const openTimerRef = useRef(null);
|
|
69
|
+
const closeTimerRef = useRef(null);
|
|
70
|
+
const ref = useRef(null);
|
|
71
|
+
const hideModifier = {
|
|
72
|
+
name: "hide"
|
|
73
|
+
};
|
|
74
|
+
const offsetModifier = {
|
|
75
|
+
name: "offset",
|
|
76
|
+
options: {
|
|
77
|
+
offset: [0, TOOLTIP_OFFSET]
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const flipModifier = {
|
|
81
|
+
name: "flip",
|
|
82
|
+
options: {
|
|
83
|
+
altBoundary: true
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
const onMouseOver = () => {
|
|
87
|
+
clearTimeout(closeTimerRef.current);
|
|
88
|
+
openTimerRef.current = setTimeout(() => {
|
|
89
|
+
setOpenTooltip(true);
|
|
90
|
+
}, openDelay);
|
|
91
|
+
};
|
|
92
|
+
const onMouseOut = () => {
|
|
93
|
+
clearTimeout(openTimerRef.current);
|
|
94
|
+
closeTimerRef.current = setTimeout(() => {
|
|
95
|
+
setOpenTooltip(false);
|
|
96
|
+
}, closeDelay);
|
|
97
|
+
};
|
|
98
|
+
useEffect(() => () => {
|
|
99
|
+
clearTimeout(openTimerRef.current);
|
|
100
|
+
clearTimeout(closeTimerRef.current);
|
|
101
|
+
}, []);
|
|
102
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
103
|
+
ref: ref,
|
|
104
|
+
onMouseOver: onMouseOver,
|
|
105
|
+
onMouseOut: onMouseOut,
|
|
106
|
+
onClick: onCollapse,
|
|
107
|
+
style: {
|
|
108
|
+
width: 28,
|
|
109
|
+
height: 28
|
|
110
|
+
},
|
|
111
|
+
className: "legend-card collapsed"
|
|
112
|
+
}, /*#__PURE__*/React.createElement(IconLegend24, null), openTooltip && /*#__PURE__*/React.createElement(Portal, {
|
|
113
|
+
className: classes["map-tooltip"]
|
|
114
|
+
}, /*#__PURE__*/React.createElement(Popper, {
|
|
115
|
+
className: classes["map-tooltip"],
|
|
116
|
+
reference: ref,
|
|
117
|
+
modifiers: [offsetModifier, flipModifier, hideModifier]
|
|
118
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
119
|
+
style: {
|
|
120
|
+
backgroundColor: `${colors.grey900}`,
|
|
121
|
+
borderRadius: 3,
|
|
122
|
+
color: `${colors.white}`,
|
|
123
|
+
padding: "4px 6px"
|
|
124
|
+
},
|
|
125
|
+
"data-test": `content`
|
|
126
|
+
}, name))));
|
|
127
|
+
}
|
|
128
|
+
function Legend(_ref3) {
|
|
129
|
+
var _head3;
|
|
130
|
+
let {
|
|
131
|
+
children,
|
|
132
|
+
collapsible
|
|
133
|
+
} = _ref3;
|
|
134
|
+
const [collapsed, setCollapsed] = useState(collapsible);
|
|
135
|
+
const inPrintMode = usePrintMedia();
|
|
136
|
+
const onCollapse = () => {
|
|
137
|
+
if (collapsible) {
|
|
138
|
+
setCollapsed(prevState => !prevState);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
const name = (_head3 = head(React.Children.toArray(children))) === null || _head3 === void 0 ? void 0 : _head3.props.name;
|
|
142
|
+
const shouldCollapse = collapsed && !inPrintMode;
|
|
143
|
+
console.log(inPrintMode);
|
|
144
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
145
|
+
className: "w-100"
|
|
146
|
+
}, shouldCollapse ? /*#__PURE__*/React.createElement(CollapsedLegendIcon, {
|
|
147
|
+
name: name,
|
|
148
|
+
onCollapse: onCollapse
|
|
149
|
+
}) : React.Children.map(children, child => /*#__PURE__*/React.cloneElement(child, {
|
|
150
|
+
collapsible,
|
|
151
|
+
onCollapse
|
|
152
|
+
})));
|
|
153
|
+
}
|
|
154
|
+
export default function LegendArea(_ref4) {
|
|
155
|
+
let {
|
|
156
|
+
layers,
|
|
157
|
+
legends: legendConfig
|
|
158
|
+
} = _ref4;
|
|
159
|
+
const legends = compact(layers.filter(layer => layer.enabled).map(getLegendComponent));
|
|
160
|
+
const {
|
|
161
|
+
position,
|
|
162
|
+
collapsible
|
|
163
|
+
} = legendConfig !== null && legendConfig !== void 0 ? legendConfig : {};
|
|
164
|
+
return /*#__PURE__*/React.createElement(CustomControl, {
|
|
165
|
+
position: position
|
|
166
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
167
|
+
className: "column gap-16 align-items-end"
|
|
168
|
+
}, legends === null || legends === void 0 ? void 0 : legends.map((legend, index) => /*#__PURE__*/React.createElement(Legend, {
|
|
169
|
+
collapsible: collapsible !== null && collapsible !== void 0 ? collapsible : true,
|
|
170
|
+
key: `${index}-map-legend`
|
|
171
|
+
}, legend))));
|
|
172
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { useConfig } from "@dhis2/app-runtime";
|
|
2
|
+
import { Divider } from "@dhis2/ui";
|
|
3
|
+
import React, { forwardRef } from "react";
|
|
4
|
+
import { getIconUrl } from "../../../../../../utils/helpers";
|
|
5
|
+
import LegendCardHeader from "../../../LegendArea/components/LegendCardHeader";
|
|
6
|
+
import { usePointLayer } from "../../hooks";
|
|
7
|
+
function PointLegends(_ref) {
|
|
8
|
+
let {
|
|
9
|
+
orgUnitGroups,
|
|
10
|
+
icon,
|
|
11
|
+
label
|
|
12
|
+
} = _ref;
|
|
13
|
+
const {
|
|
14
|
+
baseUrl
|
|
15
|
+
} = useConfig();
|
|
16
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
17
|
+
style: {
|
|
18
|
+
minWidth: 100,
|
|
19
|
+
alignItems: "flex-start"
|
|
20
|
+
},
|
|
21
|
+
className: "w-100 p-8 legend-list column"
|
|
22
|
+
}, icon && /*#__PURE__*/React.createElement("div", {
|
|
23
|
+
key: `${icon}-legend`,
|
|
24
|
+
className: "row gap-16 align-items-center"
|
|
25
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
26
|
+
height: 20,
|
|
27
|
+
width: 20,
|
|
28
|
+
alt: `${name}-icon`,
|
|
29
|
+
src: getIconUrl(icon, {
|
|
30
|
+
baseUrl
|
|
31
|
+
})
|
|
32
|
+
}), /*#__PURE__*/React.createElement("p", null, label)), orgUnitGroups.map(_ref2 => {
|
|
33
|
+
let {
|
|
34
|
+
name,
|
|
35
|
+
symbol
|
|
36
|
+
} = _ref2;
|
|
37
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
38
|
+
key: `${name}-legend`,
|
|
39
|
+
className: "row gap-16 align-items-center"
|
|
40
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
41
|
+
height: 20,
|
|
42
|
+
width: 20,
|
|
43
|
+
alt: `${name}-icon`,
|
|
44
|
+
src: getIconUrl(symbol !== null && symbol !== void 0 ? symbol : "", {
|
|
45
|
+
baseUrl
|
|
46
|
+
})
|
|
47
|
+
}), /*#__PURE__*/React.createElement("p", null, name));
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
function PointLegend(_ref3, ref) {
|
|
51
|
+
var _style$orgUnitGroups;
|
|
52
|
+
let {
|
|
53
|
+
collapsible,
|
|
54
|
+
onCollapse
|
|
55
|
+
} = _ref3;
|
|
56
|
+
const pointLayer = usePointLayer();
|
|
57
|
+
const {
|
|
58
|
+
label,
|
|
59
|
+
style
|
|
60
|
+
} = pointLayer !== null && pointLayer !== void 0 ? pointLayer : {};
|
|
61
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
62
|
+
ref: ref,
|
|
63
|
+
className: "legend-card"
|
|
64
|
+
}, /*#__PURE__*/React.createElement(LegendCardHeader, {
|
|
65
|
+
collapsible: collapsible,
|
|
66
|
+
onCollapse: onCollapse,
|
|
67
|
+
title: label !== null && label !== void 0 ? label : "Points"
|
|
68
|
+
}), /*#__PURE__*/React.createElement(Divider, {
|
|
69
|
+
margin: "0"
|
|
70
|
+
}), /*#__PURE__*/React.createElement(PointLegends, {
|
|
71
|
+
label: label,
|
|
72
|
+
orgUnitGroups: (_style$orgUnitGroups = style === null || style === void 0 ? void 0 : style.orgUnitGroups) !== null && _style$orgUnitGroups !== void 0 ? _style$orgUnitGroups : [],
|
|
73
|
+
icon: style === null || style === void 0 ? void 0 : style.icon
|
|
74
|
+
}));
|
|
75
|
+
}
|
|
76
|
+
export default /*#__PURE__*/forwardRef(PointLegend);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useConfig } from "@dhis2/app-runtime";
|
|
2
|
+
import i18n from "@dhis2/d2-i18n";
|
|
3
|
+
import L from "leaflet";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { GeoJSON, LayerGroup, LayersControl, Popup, Tooltip } from "react-leaflet";
|
|
6
|
+
import { getIcon, getIconUrl } from "../../../../utils/helpers";
|
|
7
|
+
import { usePointLayer } from "./hooks";
|
|
8
|
+
export function PointLayer() {
|
|
9
|
+
const pointLayer = usePointLayer();
|
|
10
|
+
const {
|
|
11
|
+
enabled,
|
|
12
|
+
label,
|
|
13
|
+
points: orgUnits,
|
|
14
|
+
style
|
|
15
|
+
} = pointLayer !== null && pointLayer !== void 0 ? pointLayer : {};
|
|
16
|
+
const {
|
|
17
|
+
baseUrl
|
|
18
|
+
} = useConfig();
|
|
19
|
+
return /*#__PURE__*/React.createElement(LayersControl.Overlay, {
|
|
20
|
+
checked: enabled,
|
|
21
|
+
name: label !== null && label !== void 0 ? label : i18n.t("Points")
|
|
22
|
+
}, /*#__PURE__*/React.createElement(LayerGroup, null, orgUnits === null || orgUnits === void 0 ? void 0 : orgUnits.map(area => {
|
|
23
|
+
return /*#__PURE__*/React.createElement(GeoJSON, {
|
|
24
|
+
pointToLayer: (_, coordinates) => {
|
|
25
|
+
var _area$icon$icon;
|
|
26
|
+
return L.marker(coordinates, {
|
|
27
|
+
icon: getIcon(getIconUrl((_area$icon$icon = area.icon.icon) !== null && _area$icon$icon !== void 0 ? _area$icon$icon : style === null || style === void 0 ? void 0 : style.icon, {
|
|
28
|
+
baseUrl
|
|
29
|
+
}))
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
data: area.geoJSON,
|
|
33
|
+
interactive: true,
|
|
34
|
+
key: `${area.id}-polygon`
|
|
35
|
+
}, /*#__PURE__*/React.createElement(Tooltip, null, area.name), /*#__PURE__*/React.createElement(Popup, {
|
|
36
|
+
minWidth: 80
|
|
37
|
+
}, /*#__PURE__*/React.createElement("h3", null, area.name)));
|
|
38
|
+
})));
|
|
39
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { guideLength, textPadding } from "./Bubbles";
|
|
3
|
+
const Bubble = _ref => {
|
|
4
|
+
let {
|
|
5
|
+
radius,
|
|
6
|
+
maxRadius,
|
|
7
|
+
text,
|
|
8
|
+
textAlign,
|
|
9
|
+
color,
|
|
10
|
+
stroke,
|
|
11
|
+
pattern
|
|
12
|
+
} = _ref;
|
|
13
|
+
const leftAlign = textAlign === "left";
|
|
14
|
+
const x = maxRadius;
|
|
15
|
+
const y = maxRadius * 2 - radius;
|
|
16
|
+
const x2 = leftAlign ? x - maxRadius - guideLength : x + maxRadius + guideLength;
|
|
17
|
+
const y2 = maxRadius * 2 - radius * 2;
|
|
18
|
+
const textX = x2 + (leftAlign ? -textPadding : textPadding);
|
|
19
|
+
const textAnchor = leftAlign ? "end" : "start";
|
|
20
|
+
return /*#__PURE__*/React.createElement("g", null, /*#__PURE__*/React.createElement("circle", {
|
|
21
|
+
cx: x,
|
|
22
|
+
cy: y,
|
|
23
|
+
r: radius,
|
|
24
|
+
stroke: stroke || "#000",
|
|
25
|
+
style: {
|
|
26
|
+
fill: pattern ? `url(#${pattern})` : color || "none",
|
|
27
|
+
strokeWidth: 0.5
|
|
28
|
+
}
|
|
29
|
+
}), text && /*#__PURE__*/React.createElement("g", null, /*#__PURE__*/React.createElement("line", {
|
|
30
|
+
x1: x,
|
|
31
|
+
x2: x2,
|
|
32
|
+
y1: y2,
|
|
33
|
+
y2: y2,
|
|
34
|
+
stroke: "black",
|
|
35
|
+
style: {
|
|
36
|
+
strokeDasharray: "2, 2",
|
|
37
|
+
strokeWidth: 0.5
|
|
38
|
+
}
|
|
39
|
+
}), /*#__PURE__*/React.createElement("text", {
|
|
40
|
+
x: textX,
|
|
41
|
+
y: y2,
|
|
42
|
+
textAnchor: textAnchor,
|
|
43
|
+
alignmentBaseline: "middle",
|
|
44
|
+
style: {
|
|
45
|
+
fontSize: 12
|
|
46
|
+
}
|
|
47
|
+
}, text)));
|
|
48
|
+
};
|
|
49
|
+
export default Bubble;
|
|
@@ -1,80 +1,76 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
1
2
|
import i18n from "@dhis2/d2-i18n";
|
|
2
|
-
import {scaleSqrt} from "d3-scale";
|
|
3
|
-
import {reduce} from "lodash";
|
|
4
|
-
import React, {memo} from "react";
|
|
5
|
-
import {getContrastColor} from "../../../../../../../../../utils/colors";
|
|
6
|
-
import {getLongestTextLength} from "../../../../../../../../../utils/helpers";
|
|
7
|
-
import Bubble
|
|
8
|
-
|
|
3
|
+
import { scaleSqrt } from "d3-scale";
|
|
4
|
+
import { reduce } from "lodash";
|
|
5
|
+
import React, { memo } from "react";
|
|
6
|
+
import { getContrastColor } from "../../../../../../../../../utils/colors";
|
|
7
|
+
import { getLongestTextLength } from "../../../../../../../../../utils/helpers";
|
|
8
|
+
import Bubble from "./Bubble";
|
|
9
9
|
const style = {
|
|
10
10
|
paddingTop: 10,
|
|
11
11
|
display: "flex",
|
|
12
12
|
alignItems: "center",
|
|
13
|
-
justifyContent: "center"
|
|
13
|
+
justifyContent: "center"
|
|
14
14
|
};
|
|
15
|
-
|
|
16
15
|
const legendWidth = 200;
|
|
17
16
|
const digitWidth = 6.8;
|
|
18
17
|
export const guideLength = 16;
|
|
19
18
|
export const textPadding = 4;
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
const Bubbles = _ref => {
|
|
20
|
+
let {
|
|
21
|
+
radiusLow,
|
|
22
|
+
radiusHigh,
|
|
23
|
+
color,
|
|
24
|
+
classes
|
|
25
|
+
} = _ref;
|
|
22
26
|
const height = radiusHigh * 2 + 4;
|
|
23
27
|
const scale = scaleSqrt().range([radiusLow, radiusHigh]);
|
|
24
28
|
const radiusMid = scale(0.5);
|
|
25
|
-
|
|
26
29
|
if (isNaN(radiusLow) || isNaN(radiusHigh)) {
|
|
27
30
|
return null;
|
|
28
31
|
}
|
|
29
|
-
|
|
30
|
-
let bubbles: Array<BubbleProps> = [];
|
|
32
|
+
let bubbles = [];
|
|
31
33
|
|
|
32
34
|
// If color legend
|
|
33
35
|
if (Array.isArray(classes) && classes.length) {
|
|
34
36
|
const startValue = classes[0].startValue;
|
|
35
37
|
const endValue = classes[classes.length - 1].endValue;
|
|
36
38
|
const itemScale = scale.domain([startValue, endValue]);
|
|
37
|
-
|
|
38
|
-
bubbles = [...classes].reverse().map((c) => ({
|
|
39
|
+
bubbles = [...classes].reverse().map(c => ({
|
|
39
40
|
radius: itemScale(c.endValue),
|
|
40
41
|
maxRadius: radiusHigh,
|
|
41
42
|
color: c.color,
|
|
42
|
-
text: String(c.endValue)
|
|
43
|
+
text: String(c.endValue)
|
|
43
44
|
}));
|
|
44
45
|
|
|
45
46
|
// Add the smallest bubble for the lowest value
|
|
46
47
|
bubbles.push({
|
|
47
48
|
radius: itemScale(startValue),
|
|
48
49
|
maxRadius: radiusHigh,
|
|
49
|
-
text: String(startValue)
|
|
50
|
+
text: String(startValue)
|
|
50
51
|
});
|
|
51
52
|
} else {
|
|
52
53
|
// If single color
|
|
53
54
|
const stroke = color && getContrastColor(color);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
color,
|
|
74
|
-
stroke,
|
|
75
|
-
text: i18n.t("Min"),
|
|
76
|
-
},
|
|
77
|
-
];
|
|
55
|
+
bubbles = [{
|
|
56
|
+
radius: radiusHigh,
|
|
57
|
+
maxRadius: radiusHigh,
|
|
58
|
+
color,
|
|
59
|
+
stroke,
|
|
60
|
+
text: i18n.t("Max")
|
|
61
|
+
}, {
|
|
62
|
+
radius: radiusMid,
|
|
63
|
+
maxRadius: radiusHigh,
|
|
64
|
+
color,
|
|
65
|
+
stroke,
|
|
66
|
+
text: i18n.t("Mid")
|
|
67
|
+
}, {
|
|
68
|
+
radius: radiusLow,
|
|
69
|
+
maxRadius: radiusHigh,
|
|
70
|
+
color,
|
|
71
|
+
stroke,
|
|
72
|
+
text: i18n.t("Min")
|
|
73
|
+
}];
|
|
78
74
|
}
|
|
79
75
|
|
|
80
76
|
// Calculate the pixel length of the longest number
|
|
@@ -82,23 +78,16 @@ const Bubbles = ({ radiusLow, radiusHigh, color, classes }: { radiusLow: number;
|
|
|
82
78
|
|
|
83
79
|
// Calculate the total length if numbers are alternate on each side
|
|
84
80
|
const alternateLength = (radiusHigh + guideLength + textPadding + textLength) * 2;
|
|
85
|
-
|
|
86
|
-
let smallestGap = reduce(bubbles, (prev, curr: any, i) => {
|
|
81
|
+
let smallestGap = reduce(bubbles, (prev, curr, i) => {
|
|
87
82
|
const gap = prev.radius - curr.radius;
|
|
88
83
|
const smallestGap = prev.gap === undefined || gap < prev.gap ? gap : prev.gap;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
radius: curr.radius,
|
|
94
|
-
gap: smallestGap,
|
|
95
|
-
};
|
|
84
|
+
return i === bubbles.length - 1 ? Math.round(smallestGap * 2) : {
|
|
85
|
+
radius: curr.radius,
|
|
86
|
+
gap: smallestGap
|
|
87
|
+
};
|
|
96
88
|
});
|
|
97
|
-
|
|
98
89
|
const alternateFit = alternateLength < legendWidth;
|
|
99
|
-
|
|
100
90
|
const alternate = alternateFit && smallestGap > 5 && smallestGap < 12;
|
|
101
|
-
|
|
102
91
|
if (!alternateFit) {
|
|
103
92
|
smallestGap = smallestGap / 2;
|
|
104
93
|
}
|
|
@@ -113,38 +102,32 @@ const Bubbles = ({ radiusLow, radiusHigh, color, classes }: { radiusLow: number;
|
|
|
113
102
|
if (gap > 4) {
|
|
114
103
|
showNumbers.push(bubbles.length - 1);
|
|
115
104
|
}
|
|
116
|
-
|
|
117
105
|
if (gap > 15) {
|
|
118
106
|
const midRadius = minBubble.radius + gap / 2;
|
|
119
107
|
|
|
120
108
|
// Find the closest bubble above the mid-radius
|
|
121
|
-
const midBubble = bubbles.reduce((prev, curr) =>
|
|
122
|
-
|
|
109
|
+
const midBubble = bubbles.reduce((prev, curr) => curr.radius >= midRadius && curr.radius - midRadius < prev.radius - midRadius ? curr : prev);
|
|
123
110
|
showNumbers.push(bubbles.indexOf(midBubble));
|
|
124
111
|
}
|
|
125
|
-
|
|
126
112
|
bubbles.forEach((b, i) => {
|
|
127
113
|
if (!showNumbers.includes(i)) {
|
|
128
114
|
delete b.text;
|
|
129
115
|
}
|
|
130
116
|
});
|
|
131
117
|
}
|
|
132
|
-
|
|
133
118
|
textLength = Math.ceil(getLongestTextLength(bubbles, "text") * digitWidth);
|
|
134
|
-
|
|
135
119
|
const offset = textLength + guideLength + textPadding;
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
);
|
|
120
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
121
|
+
style: style
|
|
122
|
+
}, /*#__PURE__*/React.createElement("svg", {
|
|
123
|
+
width: legendWidth,
|
|
124
|
+
height: height + 50
|
|
125
|
+
}, /*#__PURE__*/React.createElement("g", {
|
|
126
|
+
transform: `translate(${alternate ? offset : "16"} 24)`
|
|
127
|
+
}, bubbles.map((bubble, i) => /*#__PURE__*/React.createElement(Bubble, _extends({
|
|
128
|
+
key: i
|
|
129
|
+
}, bubble, {
|
|
130
|
+
textAlign: alternate && i % 2 == 0 ? "left" : "right"
|
|
131
|
+
}))))));
|
|
148
132
|
};
|
|
149
|
-
|
|
150
|
-
export default memo(Bubbles);
|
|
133
|
+
export default /*#__PURE__*/memo(Bubbles);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Divider } from "@dhis2/ui";
|
|
2
|
+
import React, { forwardRef } from "react";
|
|
3
|
+
import LegendCardHeader from "../../../../../LegendArea/components/LegendCardHeader";
|
|
4
|
+
import Bubbles from "./components/Bubbles";
|
|
5
|
+
function BubbleLegend(_ref, ref) {
|
|
6
|
+
let {
|
|
7
|
+
radius,
|
|
8
|
+
dataItem,
|
|
9
|
+
data,
|
|
10
|
+
name,
|
|
11
|
+
collapsible,
|
|
12
|
+
onCollapse,
|
|
13
|
+
legends
|
|
14
|
+
} = _ref;
|
|
15
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
16
|
+
className: "legend-card",
|
|
17
|
+
ref: ref
|
|
18
|
+
}, /*#__PURE__*/React.createElement(LegendCardHeader, {
|
|
19
|
+
title: dataItem.displayName,
|
|
20
|
+
onCollapse: onCollapse,
|
|
21
|
+
collapsible: collapsible
|
|
22
|
+
}), /*#__PURE__*/React.createElement(Divider, {
|
|
23
|
+
margin: "0"
|
|
24
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
25
|
+
className: "legend-list pt-8"
|
|
26
|
+
}, /*#__PURE__*/React.createElement(Bubbles, {
|
|
27
|
+
classes: legends.reverse(),
|
|
28
|
+
radiusHigh: radius.max,
|
|
29
|
+
radiusLow: radius.min,
|
|
30
|
+
color: "#FF0000"
|
|
31
|
+
})));
|
|
32
|
+
}
|
|
33
|
+
export default /*#__PURE__*/forwardRef(BubbleLegend);
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { colors } from "@dhis2/ui";
|
|
2
|
+
import { geoJSON } from "leaflet";
|
|
3
|
+
import React, { useMemo } from "react";
|
|
4
|
+
import { CircleMarker } from "react-leaflet";
|
|
5
|
+
import { getColorFromLegendSet, highlightFeature, resetHighlight } from "../../../../../../utils/map";
|
|
6
|
+
import CustomTooltip from "../CustomTooltip";
|
|
7
|
+
const defaultStyle = {
|
|
8
|
+
weight: 1
|
|
9
|
+
};
|
|
10
|
+
const highlightStyle = {
|
|
11
|
+
weight: 2
|
|
12
|
+
};
|
|
13
|
+
export default function Bubble(_ref) {
|
|
14
|
+
let {
|
|
15
|
+
data,
|
|
16
|
+
highestData,
|
|
17
|
+
legends,
|
|
18
|
+
radius
|
|
19
|
+
} = _ref;
|
|
20
|
+
const {
|
|
21
|
+
orgUnit,
|
|
22
|
+
data: value
|
|
23
|
+
} = data !== null && data !== void 0 ? data : {};
|
|
24
|
+
const geoJSONObject = orgUnit.geoJSON;
|
|
25
|
+
const center = geoJSON(geoJSONObject).getBounds().getCenter();
|
|
26
|
+
const circleRadius = useMemo(() => {
|
|
27
|
+
var _radius$max;
|
|
28
|
+
return (value !== null && value !== void 0 ? value : 0) * ((_radius$max = radius === null || radius === void 0 ? void 0 : radius.max) !== null && _radius$max !== void 0 ? _radius$max : 50) / highestData;
|
|
29
|
+
}, [radius, data, highestData]);
|
|
30
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CircleMarker, {
|
|
31
|
+
interactive: true,
|
|
32
|
+
eventHandlers: {
|
|
33
|
+
mouseover: e => highlightFeature(e, highlightStyle),
|
|
34
|
+
mouseout: e => resetHighlight(e, defaultStyle)
|
|
35
|
+
},
|
|
36
|
+
pathOptions: {
|
|
37
|
+
fillColor: getColorFromLegendSet(legends, data.data),
|
|
38
|
+
fillOpacity: 1,
|
|
39
|
+
color: colors.grey900,
|
|
40
|
+
weight: 1
|
|
41
|
+
},
|
|
42
|
+
radius: circleRadius,
|
|
43
|
+
center: center
|
|
44
|
+
}, /*#__PURE__*/React.createElement(CustomTooltip, {
|
|
45
|
+
data: data
|
|
46
|
+
})));
|
|
47
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import "../../../styles/legends.css";
|
|
2
|
+
import { Divider } from "@dhis2/ui";
|
|
3
|
+
import React, { forwardRef } from "react";
|
|
4
|
+
import { getLegendCount } from "../../../../../../../utils/map";
|
|
5
|
+
import LegendCardHeader from "../../../../LegendArea/components/LegendCardHeader";
|
|
6
|
+
export function LegendItem(_ref) {
|
|
7
|
+
let {
|
|
8
|
+
legend,
|
|
9
|
+
value
|
|
10
|
+
} = _ref;
|
|
11
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
12
|
+
className: "legend-item"
|
|
13
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
14
|
+
className: "legend-item-color",
|
|
15
|
+
style: {
|
|
16
|
+
backgroundColor: legend.color
|
|
17
|
+
}
|
|
18
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
19
|
+
className: "legend-item-label"
|
|
20
|
+
}, `${legend.startValue} - ${legend.endValue}`), /*#__PURE__*/React.createElement("div", {
|
|
21
|
+
className: "legend-item-value"
|
|
22
|
+
}, `(${value})`));
|
|
23
|
+
}
|
|
24
|
+
function ChoroplethLegend(_ref2, ref) {
|
|
25
|
+
let {
|
|
26
|
+
dataItem,
|
|
27
|
+
data,
|
|
28
|
+
name,
|
|
29
|
+
collapsible,
|
|
30
|
+
onCollapse,
|
|
31
|
+
legends
|
|
32
|
+
} = _ref2;
|
|
33
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
34
|
+
className: "legend-card",
|
|
35
|
+
ref: ref
|
|
36
|
+
}, /*#__PURE__*/React.createElement(LegendCardHeader, {
|
|
37
|
+
title: dataItem.displayName,
|
|
38
|
+
collapsible: collapsible,
|
|
39
|
+
onCollapse: onCollapse
|
|
40
|
+
}), /*#__PURE__*/React.createElement(Divider, {
|
|
41
|
+
margin: "0"
|
|
42
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
43
|
+
className: "legend-list pt-8"
|
|
44
|
+
}, legends === null || legends === void 0 ? void 0 : legends.map(legend => /*#__PURE__*/React.createElement(LegendItem, {
|
|
45
|
+
key: `${legend === null || legend === void 0 ? void 0 : legend.color}-legend-list`,
|
|
46
|
+
legend: legend,
|
|
47
|
+
value: getLegendCount(legend, data)
|
|
48
|
+
}))));
|
|
49
|
+
}
|
|
50
|
+
export default /*#__PURE__*/forwardRef(ChoroplethLegend);
|