@hisptz/dhis2-analytics 2.1.16 → 2.1.18
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/dist/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/index.js +35 -7
- package/dist/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/index.js.map +1 -1
- package/dist/components/Map/components/MapLayer/components/ThematicLayer/components/LabelMarker/index.js +35 -0
- package/dist/components/Map/components/MapLayer/components/ThematicLayer/components/LabelMarker/index.js.map +1 -0
- package/dist/components/Map/components/MapLayer/components/ThematicLayer/components/LabelMarker/label.css +11 -0
- package/dist/components/Map/components/MapLayer/components/ThematicLayer/components/LabelMarker/label.css.map +1 -0
- package/dist/components/Map/components/MapLayer/components/ThematicLayer/index.js +1 -0
- package/dist/components/Map/components/MapLayer/components/ThematicLayer/index.js.map +1 -1
- package/dist/components/Map/components/MapLayer/components/ThematicLayer/utils/label.js +20 -0
- package/dist/components/Map/components/MapLayer/components/ThematicLayer/utils/label.js.map +1 -0
- package/dist/components/Map/components/MapLayer/interfaces/index.js.map +1 -1
- package/dist/components/Map/components/MapProvider/index.js +20 -14
- package/dist/components/Map/components/MapProvider/index.js.map +1 -1
- package/dist/esm/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/index.js +34 -6
- package/dist/esm/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/index.js.map +1 -1
- package/dist/esm/components/Map/components/MapLayer/components/ThematicLayer/components/LabelMarker/index.js +29 -0
- package/dist/esm/components/Map/components/MapLayer/components/ThematicLayer/components/LabelMarker/index.js.map +1 -0
- package/dist/esm/components/Map/components/MapLayer/components/ThematicLayer/components/LabelMarker/label.css +11 -0
- package/dist/esm/components/Map/components/MapLayer/components/ThematicLayer/components/LabelMarker/label.css.map +1 -0
- package/dist/esm/components/Map/components/MapLayer/components/ThematicLayer/index.js +1 -0
- package/dist/esm/components/Map/components/MapLayer/components/ThematicLayer/index.js.map +1 -1
- package/dist/esm/components/Map/components/MapLayer/components/ThematicLayer/utils/label.js +18 -0
- package/dist/esm/components/Map/components/MapLayer/components/ThematicLayer/utils/label.js.map +1 -0
- package/dist/esm/components/Map/components/MapLayer/interfaces/index.js.map +1 -1
- package/dist/esm/components/Map/components/MapProvider/index.js +16 -10
- package/dist/esm/components/Map/components/MapProvider/index.js.map +1 -1
- package/dist/types/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/index.d.ts +6 -5
- package/dist/types/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/index.d.ts.map +1 -1
- package/dist/types/components/Map/components/MapLayer/components/ThematicLayer/components/LabelMarker/index.d.ts +13 -0
- package/dist/types/components/Map/components/MapLayer/components/ThematicLayer/components/LabelMarker/index.d.ts.map +1 -0
- package/dist/types/components/Map/components/MapLayer/components/ThematicLayer/index.d.ts +1 -1
- package/dist/types/components/Map/components/MapLayer/components/ThematicLayer/index.d.ts.map +1 -1
- package/dist/types/components/Map/components/MapLayer/components/ThematicLayer/utils/label.d.ts +9 -0
- package/dist/types/components/Map/components/MapLayer/components/ThematicLayer/utils/label.d.ts.map +1 -0
- package/dist/types/components/Map/components/MapLayer/interfaces/index.d.ts +10 -3
- package/dist/types/components/Map/components/MapLayer/interfaces/index.d.ts.map +1 -1
- package/dist/types/components/Map/components/MapProvider/index.d.ts +2 -2
- package/dist/types/components/Map/components/MapProvider/index.d.ts.map +1 -1
- package/package.json +6 -5
|
@@ -3,8 +3,11 @@
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var ui = require('@dhis2/ui');
|
|
5
5
|
var reactLeaflet = require('react-leaflet');
|
|
6
|
-
var
|
|
6
|
+
var utils = require('../../../../../../utils');
|
|
7
7
|
var CustomTooltip = require('../CustomTooltip/index.js');
|
|
8
|
+
var LabelMarker = require('../LabelMarker');
|
|
9
|
+
var geolib = require('geolib');
|
|
10
|
+
var lodash = require('lodash');
|
|
8
11
|
|
|
9
12
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
13
|
|
|
@@ -20,16 +23,27 @@ function Choropleth({
|
|
|
20
23
|
data,
|
|
21
24
|
legends,
|
|
22
25
|
customEventHandlers,
|
|
23
|
-
onLayerClick
|
|
26
|
+
onLayerClick,
|
|
27
|
+
labelConfig
|
|
24
28
|
}) {
|
|
25
29
|
const { orgUnit } = data;
|
|
26
|
-
|
|
30
|
+
const color = utils.getColorFromLegendSet(legends, data.data);
|
|
31
|
+
const center = geolib.getCenter(
|
|
32
|
+
lodash.chunk(
|
|
33
|
+
lodash.flattenDeep(orgUnit.geoJSON.geometry.coordinates),
|
|
34
|
+
2
|
|
35
|
+
).map(([latitude, longitude]) => ({
|
|
36
|
+
longitude,
|
|
37
|
+
latitude
|
|
38
|
+
}))
|
|
39
|
+
);
|
|
40
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
27
41
|
reactLeaflet.GeoJSON,
|
|
28
42
|
{
|
|
29
43
|
data: orgUnit.geoJSON,
|
|
30
44
|
eventHandlers: {
|
|
31
|
-
mouseover: (e) =>
|
|
32
|
-
mouseout: (e) =>
|
|
45
|
+
mouseover: (e) => utils.highlightFeature(e, highlightStyle),
|
|
46
|
+
mouseout: (e) => utils.resetHighlight(e, defaultStyle),
|
|
33
47
|
...customEventHandlers ?? {},
|
|
34
48
|
mousedown: (e) => {
|
|
35
49
|
if (onLayerClick) {
|
|
@@ -37,13 +51,27 @@ function Choropleth({
|
|
|
37
51
|
}
|
|
38
52
|
}
|
|
39
53
|
},
|
|
54
|
+
interactive: true,
|
|
40
55
|
pathOptions: {
|
|
41
|
-
fillColor:
|
|
56
|
+
fillColor: color,
|
|
42
57
|
fillOpacity: 1,
|
|
43
58
|
color: ui.colors.grey900,
|
|
59
|
+
fill: true,
|
|
44
60
|
weight: 1
|
|
45
61
|
},
|
|
46
|
-
children:
|
|
62
|
+
children: [
|
|
63
|
+
labelConfig && /* @__PURE__ */ jsxRuntime.jsx(
|
|
64
|
+
LabelMarker.LabelMarker,
|
|
65
|
+
{
|
|
66
|
+
layerColor: color,
|
|
67
|
+
labelConfig,
|
|
68
|
+
data: data.data,
|
|
69
|
+
orgUnit,
|
|
70
|
+
center: [center.longitude, center.latitude]
|
|
71
|
+
}
|
|
72
|
+
),
|
|
73
|
+
/* @__PURE__ */ jsxRuntime.jsx(CustomTooltip__default.default, { data })
|
|
74
|
+
]
|
|
47
75
|
},
|
|
48
76
|
`${data.dataItem.id}-layer`
|
|
49
77
|
) });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../../src/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/index.tsx"],"names":["jsx","Fragment","GeoJSON","highlightFeature","resetHighlight","
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../src/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/index.tsx"],"names":["getColorFromLegendSet","getCenter","chunk","flattenDeep","jsx","Fragment","jsxs","GeoJSON","highlightFeature","resetHighlight","colors","LabelMarker","CustomTooltip"],"mappings":";;;;;;;;;;;;;;;AAoBA,MAAM,YAAe,GAAA;AAAA,EACpB,MAAQ,EAAA;AACT,CAAA;AACA,MAAM,cAAiB,GAAA;AAAA,EACtB,MAAQ,EAAA;AACT,CAAA;AAQe,SAAR,UAA4B,CAAA;AAAA,EAClC,IAAA;AAAA,EACA,OAAA;AAAA,EACA,mBAAA;AAAA,EACA,YAAA;AAAA,EACA;AACD,CAMG,EAAA;AACF,EAAM,MAAA,EAAE,SAAY,GAAA,IAAA;AACpB,EAAA,MAAM,KAAQ,GAAAA,2BAAA,CAAsB,OAAS,EAAA,IAAA,CAAK,IAAI,CAAA;AAEtD,EAAA,MAAM,MAAS,GAAAC,gBAAA;AAAA,IACdC,YAAA;AAAA,MACCC,kBAAoB,CAAA,OAAA,CAAQ,OAAQ,CAAA,QAAA,CAAS,WAAW,CAAA;AAAA,MACxD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a1B,EAAA,CAAA;AAEF","file":"index.js","sourcesContent":["import { colors } from \"@dhis2/ui\";\nimport type { Legend } from \"@hisptz/dhis2-utils\";\nimport React from \"react\";\nimport { GeoJSON } from \"react-leaflet\";\nimport { MapOrgUnit } from \"../../../../../../interfaces\";\nimport {\n\tgetColorFromLegendSet,\n\thighlightFeature,\n\tresetHighlight,\n} from \"../../../../../../utils\";\nimport {\n\ttype LayerLabelConfig,\n\tThematicLayerDataItem,\n} from \"../../../../interfaces\";\nimport CustomTooltip from \"../CustomTooltip/index.js\";\nimport { type LeafletEventHandlerFnMap, type LeafletMouseEvent } from \"leaflet\";\nimport { LabelMarker } from \"../LabelMarker\";\nimport { getCenter } from \"geolib\";\nimport { chunk, flattenDeep } from \"lodash\";\n\nconst defaultStyle = {\n\tweight: 1,\n};\nconst highlightStyle = {\n\tweight: 2,\n};\n\ninterface LayerData {\n\torgUnit: MapOrgUnit;\n\tdata?: number;\n\tdataItem: ThematicLayerDataItem;\n}\n\nexport default function Choropleth({\n\tdata,\n\tlegends,\n\tcustomEventHandlers,\n\tonLayerClick,\n\tlabelConfig,\n}: {\n\tdata: LayerData;\n\tlegends: Legend[];\n\tcustomEventHandlers?: LeafletEventHandlerFnMap;\n\tonLayerClick?: (e: LeafletMouseEvent, data: LayerData) => void;\n\tlabelConfig?: LayerLabelConfig;\n}) {\n\tconst { orgUnit } = data;\n\tconst color = getColorFromLegendSet(legends, data.data);\n\n\tconst center = getCenter(\n\t\tchunk<number>(\n\t\t\tflattenDeep<number>(orgUnit.geoJSON.geometry.coordinates),\n\t\t\t2,\n\t\t).map(([latitude, longitude]: number[]) => ({\n\t\t\tlongitude,\n\t\t\tlatitude,\n\t\t})),\n\t) as {\n\t\tlongitude: number;\n\t\tlatitude: number;\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<GeoJSON\n\t\t\t\tdata={orgUnit.geoJSON}\n\t\t\t\teventHandlers={{\n\t\t\t\t\tmouseover: (e) => highlightFeature(e, highlightStyle),\n\t\t\t\t\tmouseout: (e) => resetHighlight(e, defaultStyle),\n\t\t\t\t\t...(customEventHandlers ?? {}),\n\t\t\t\t\tmousedown: (e) => {\n\t\t\t\t\t\tif (onLayerClick) {\n\t\t\t\t\t\t\tonLayerClick(e, data);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t}}\n\t\t\t\tinteractive\n\t\t\t\tpathOptions={{\n\t\t\t\t\tfillColor: color,\n\t\t\t\t\tfillOpacity: 1,\n\t\t\t\t\tcolor: colors.grey900,\n\t\t\t\t\tfill: true,\n\t\t\t\t\tweight: 1,\n\t\t\t\t}}\n\t\t\t\tkey={`${data.dataItem.id}-layer`}\n\t\t\t>\n\t\t\t\t{labelConfig && (\n\t\t\t\t\t<LabelMarker\n\t\t\t\t\t\tlayerColor={color}\n\t\t\t\t\t\tlabelConfig={labelConfig}\n\t\t\t\t\t\tdata={data.data}\n\t\t\t\t\t\torgUnit={orgUnit}\n\t\t\t\t\t\tcenter={[center.longitude, center.latitude]}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t\t<CustomTooltip data={data} />\n\t\t\t</GeoJSON>\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var reactLeaflet = require('react-leaflet');
|
|
5
|
+
var label = require('../../utils/label');
|
|
6
|
+
var L = require('leaflet');
|
|
7
|
+
require('./label.css');
|
|
8
|
+
var color = require('../../../../../../../DHIS2PivotTable/utils/color');
|
|
9
|
+
|
|
10
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
|
|
12
|
+
var L__default = /*#__PURE__*/_interopDefault(L);
|
|
13
|
+
|
|
14
|
+
function LabelMarker({
|
|
15
|
+
labelConfig,
|
|
16
|
+
data,
|
|
17
|
+
orgUnit,
|
|
18
|
+
center,
|
|
19
|
+
layerColor
|
|
20
|
+
}) {
|
|
21
|
+
const label$1 = label.getLabel({
|
|
22
|
+
labelConfig,
|
|
23
|
+
data,
|
|
24
|
+
orgUnit
|
|
25
|
+
});
|
|
26
|
+
const labelIcon = L__default.default.divIcon({
|
|
27
|
+
className: "label-icon",
|
|
28
|
+
html: `<span style="color: ${color.getTextColorFromBackgroundColor(layerColor)}; text-align: center; font-size: 12px">${label$1}</span>`
|
|
29
|
+
});
|
|
30
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactLeaflet.Marker, { zIndexOffset: 1e3, icon: labelIcon, position: center });
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
exports.LabelMarker = LabelMarker;
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../src/components/Map/components/MapLayer/components/ThematicLayer/components/LabelMarker/index.tsx"],"names":["label","getLabel","L","getTextColorFromBackgroundColor","Marker"],"mappings":";;;;;;;;;;;;;AAOO,SAAS,WAAY,CAAA;AAAA,EAC3B,WAAA;AAAA,EACA,IAAA;AAAA,EACA,OAAA;AAAA,EACA,MAAA;AAAA,EACA;AACD,CAMG,EAAA;AACF,EAAA,MAAMA,UAAQC,cAAS,CAAA;AAAA,IACtB,WAAA;AAAA,IACA,IAAA;AAAA,IACA;AAAA,GACA,CAAA;AAED,EAAM,MAAA,SAAA,GAAYC,mBAAE,OAAQ,CAAA;AAAA,IAC3B,SAAW,EAAA,YAAA;AAAA,IACX,MAAM,CAAuB,oBAAA,EAAAC,qCAAA,CAAgC,UAAU,CAAC,0CAA0CH,OAAK,CAAA,OAAA;AAAA,GACvH,CAAA;AAED,EAAA,sCAAQI,mBAAO,EAAA,EAAA,YAAA,EAAc,KAAM,IAAM,EAAA,SAAA,EAAW,UAAU,MAAQ,EAAA,CAAA;AACvE","file":"index.js","sourcesContent":["import { Marker } from \"react-leaflet\";\nimport { getLabel } from \"../../utils/label\";\nimport type { LayerLabelConfig } from \"../../../../interfaces\";\nimport L, { type LatLngExpression } from \"leaflet\";\nimport \"./label.css\";\nimport { getTextColorFromBackgroundColor } from \"../../../../../../../DHIS2PivotTable/utils/color\";\n\nexport function LabelMarker({\n\tlabelConfig,\n\tdata,\n\torgUnit,\n\tcenter,\n\tlayerColor,\n}: {\n\tlabelConfig: LayerLabelConfig;\n\tdata: number | undefined;\n\torgUnit: { name: string };\n\tcenter: LatLngExpression;\n\tlayerColor: string;\n}) {\n\tconst label = getLabel({\n\t\tlabelConfig,\n\t\tdata,\n\t\torgUnit,\n\t});\n\n\tconst labelIcon = L.divIcon({\n\t\tclassName: \"label-icon\",\n\t\thtml: `<span style=\"color: ${getTextColorFromBackgroundColor(layerColor)}; text-align: center; font-size: 12px\">${label}</span>`,\n\t});\n\n\treturn <Marker zIndexOffset={1000} icon={labelIcon} position={center} />;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../src/components/Map/components/MapLayer/components/ThematicLayer/components/LabelMarker/label.css"],"sourcesContent":[".label-icon {\n background: transparent;\n border: none;\n font-size: 12px;\n font-weight: bold;\n text-align: center;\n white-space: nowrap;\n pointer-events: none; /* prevents label from blocking map clicks */\n margin: auto\n}\n"],"mappings":"AAAA,CAAC;AACG,cAAY;AACZ,UAAQ;AACR,aAAW;AACX,eAAa;AACb,cAAY;AACZ,eAAa;AACb,kBAAgB;AAChB,UAAQ;AACZ;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/components/Map/components/MapLayer/components/ThematicLayer/index.tsx"],"names":["useThematicLayer","jsx","Fragment","LayersControl","Pane","LayerGroup","Choropleth","Bubble","last"],"mappings":";;;;;;;;;;;;;;;AAQe,SAAR,aAA+B,CAAA;AAAA,EACrC,OAAA;AAAA,EACA;AACD,CAGG,EAAA;AACF,EAAM,MAAA,KAAA,GAAQA,kCAAiB,OAAO,CAAA;A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AAAA,cACrB,WAAa,EAAAC,WAAA,CAAK,IAAI,CAAA,EAAG,IAAQ,IAAA,CAAA;AAAA,cACjC,IAAM,EAAA;AAAA,aAAA;AAAA,YACD,GAAG,KAAO,EAAA,QAAA,EAAU,EAAE,CAAI,CAAA,EAAA,KAAA,EAAO,SAAS,EAAE,CAAA,MAAA;AAAA,WAE/C,GAAA;AAAA;AACL,OACD,EAAA;AAAA;AAAA,KAEF,CACD,EAAA,CAAA;AAEF","file":"index.js","sourcesContent":["import { last } from \"lodash\";\nimport React from \"react\";\nimport { LayerGroup, LayersControl, Pane } from \"react-leaflet\";\nimport { CustomBubbleLayer } from \"../../interfaces
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/components/Map/components/MapLayer/components/ThematicLayer/index.tsx"],"names":["useThematicLayer","jsx","Fragment","LayersControl","Pane","LayerGroup","Choropleth","Bubble","last"],"mappings":";;;;;;;;;;;;;;;AAQe,SAAR,aAA+B,CAAA;AAAA,EACrC,OAAA;AAAA,EACA;AACD,CAGG,EAAA;AACF,EAAM,MAAA,KAAA,GAAQA,kCAAiB,OAAO,CAAA;AAEtC,EAAA,IAAI,CAAC,KAAO,EAAA;AACX,IAAO,OAAA,IAAA;AAAA;AAGR,EAAM,MAAA;AAAA,IACL,IAAA;AAAA,IACA,QAAA;AAAA,IACA,IAAA;AAAA,IACA,IAAA;AAAA,IACA,OAAA;AAAA,IACA,OAAA;AAAA,IACA,mBAAA;AAAA,IACA;AAAA,GACD,GAAI,SAAS,EAAC;AACd,EAAM,MAAA,UAAA,GAAa,QAAQ,QAAS,CAAA,WAAA;AACpC,EACC,uBAAAC,cAAA,CAAAC,mBAAA,EAAA,EACC,yCAACC,0BAAc,CAAA,OAAA,EAAd,EAAsB,OAAS,EAAA,OAAA,EAAS,MAAM,UAC9C,EAAA,QAAA,kBAAAF,cAAA;AAAA,IAACG,iBAAA;AAAA,IAAA;AAAA,MACA,KAAO,EAAA;AAAA,QACN,MAAQ,EAAA,IAAA,KAAS,QAAW,GAAA,GAAA,GAAM,OAAO,KAAQ,GAAA,CAAA;AAAA,OAClD;AAAA,MACA,IAAM,EAAA,UAAA;AAAA,MAEN,0CAACC,uBACC,EAAA,EAAA,QAAA,EAAA;AAAA,QAAM,IAAA,EAAA,GAAA;AAAA,UAAI,CAAC,KACX,KAAA,IAAA,KAAS,YACR,mBAAAJ,cAAA;AAAA,YAACK,2BAAA;AAAA,YAAA;AAAA,cACA,aAAa,KAAM,CAAA,WAAA;AAAA,cACnB,mBAAA;AAAA,cACA,YAAA;AAAA,cACA,OAAA,EAAS,WAAW,EAAC;AAAA,cACrB,IAAM,EAAA;AAAA,aAAA;AAAA,YACD,GAAG,KAAO,EAAA,QAAA,EAAU,EAAE,CAAI,CAAA,EAAA,KAAA,EAAO,SAAS,EAAE,CAAA,MAAA;AAAA,WAE/C,GAAA;AAAA,SACL;AAAA,QACC,IAAM,EAAA,GAAA;AAAA,UAAI,CAAC,KACX,KAAA,IAAA,KAAS,QACR,mBAAAL,cAAA;AAAA,YAACM,uBAAA;AAAA,YAAA;AAAA,cACA,QACE,KAA6B,EAAA,MAAA;AAAA,cAE/B,OAAA,EAAS,WAAW,EAAC;AAAA,cACrB,WAAa,EAAAC,WAAA,CAAK,IAAI,CAAA,EAAG,IAAQ,IAAA,CAAA;AAAA,cACjC,IAAM,EAAA;AAAA,aAAA;AAAA,YACD,GAAG,KAAO,EAAA,QAAA,EAAU,EAAE,CAAI,CAAA,EAAA,KAAA,EAAO,SAAS,EAAE,CAAA,MAAA;AAAA,WAE/C,GAAA;AAAA;AACL,OACD,EAAA;AAAA;AAAA,KAEF,CACD,EAAA,CAAA;AAEF","file":"index.js","sourcesContent":["import { last } from \"lodash\";\nimport React from \"react\";\nimport { LayerGroup, LayersControl, Pane } from \"react-leaflet\";\nimport { CustomBubbleLayer } from \"../../interfaces\";\nimport Bubble from \"./components/Bubble/index.js\";\nimport Choropleth from \"./components/Choropleth/index.js\";\nimport useThematicLayer from \"./hooks/config.js\";\n\nexport default function ThematicLayer({\n\tlayerId,\n\tindex,\n}: {\n\tlayerId: string;\n\tindex: number;\n}) {\n\tconst layer = useThematicLayer(layerId);\n\n\tif (!layer) {\n\t\treturn null;\n\t}\n\n\tconst {\n\t\ttype,\n\t\tdataItem,\n\t\tname,\n\t\tdata,\n\t\tenabled,\n\t\tlegends,\n\t\tcustomEventHandlers,\n\t\tonLayerClick,\n\t} = layer ?? {};\n\tconst uniqueName = name ?? dataItem.displayName;\n\treturn (\n\t\t<>\n\t\t\t<LayersControl.Overlay checked={enabled} name={uniqueName}>\n\t\t\t\t<Pane\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tzIndex: type === \"bubble\" ? 500 : 500 - (index + 1),\n\t\t\t\t\t}}\n\t\t\t\t\tname={uniqueName}\n\t\t\t\t>\n\t\t\t\t\t<LayerGroup>\n\t\t\t\t\t\t{data?.map((datum) =>\n\t\t\t\t\t\t\ttype === \"choropleth\" ? (\n\t\t\t\t\t\t\t\t<Choropleth\n\t\t\t\t\t\t\t\t\tlabelConfig={layer.labelConfig}\n\t\t\t\t\t\t\t\t\tcustomEventHandlers={customEventHandlers}\n\t\t\t\t\t\t\t\t\tonLayerClick={onLayerClick}\n\t\t\t\t\t\t\t\t\tlegends={legends ?? []}\n\t\t\t\t\t\t\t\t\tdata={datum}\n\t\t\t\t\t\t\t\t\tkey={`${datum?.dataItem?.id}-${datum?.orgUnit?.id}-layer`}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) : null,\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t{data?.map((datum) =>\n\t\t\t\t\t\t\ttype === \"bubble\" ? (\n\t\t\t\t\t\t\t\t<Bubble\n\t\t\t\t\t\t\t\t\tradius={\n\t\t\t\t\t\t\t\t\t\t(layer as CustomBubbleLayer)?.radius\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tlegends={legends ?? []}\n\t\t\t\t\t\t\t\t\thighestData={last(data)?.data ?? 1}\n\t\t\t\t\t\t\t\t\tdata={datum}\n\t\t\t\t\t\t\t\t\tkey={`${datum?.dataItem?.id}-${datum?.orgUnit?.id}-layer`}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) : null,\n\t\t\t\t\t\t)}\n\t\t\t\t\t</LayerGroup>\n\t\t\t\t</Pane>\n\t\t\t</LayersControl.Overlay>\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var lodash = require('lodash');
|
|
4
|
+
|
|
5
|
+
const valueFormatter = Intl.NumberFormat(navigator.language).format;
|
|
6
|
+
function getLabel({
|
|
7
|
+
orgUnit,
|
|
8
|
+
data,
|
|
9
|
+
labelConfig
|
|
10
|
+
}) {
|
|
11
|
+
lodash.templateSettings.interpolate = /{([\s\S]+?)}/g;
|
|
12
|
+
return lodash.template(labelConfig.labelTemplate.replace(/\n/g, "<br />"))({
|
|
13
|
+
name: orgUnit.name,
|
|
14
|
+
value: data ? valueFormatter(data) : ""
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
exports.getLabel = getLabel;
|
|
19
|
+
//# sourceMappingURL=label.js.map
|
|
20
|
+
//# sourceMappingURL=label.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../src/components/Map/components/MapLayer/components/ThematicLayer/utils/label.ts"],"names":["templateSettings","template"],"mappings":";;;;AAGA,MAAM,cAAiB,GAAA,IAAA,CAAK,YAAa,CAAA,SAAA,CAAU,QAAQ,CAAE,CAAA,MAAA;AAEtD,SAAS,QAAS,CAAA;AAAA,EACxB,OAAA;AAAA,EACA,IAAA;AAAA,EACA;AACD,CAIG,EAAA;AACF,EAAAA,uBAAA,CAAiB,WAAc,GAAA,eAAA;AAE/B,EAAA,OAAOC,gBAAS,WAAY,CAAA,aAAA,CAAc,QAAQ,KAAO,EAAA,QAAQ,CAAC,CAAE,CAAA;AAAA,IACnE,MAAM,OAAQ,CAAA,IAAA;AAAA,IACd,KAAO,EAAA,IAAA,GAAO,cAAe,CAAA,IAAI,CAAI,GAAA;AAAA,GACrC,CAAA;AACF","file":"label.js","sourcesContent":["import { template, templateSettings } from \"lodash\";\nimport type { LayerLabelConfig } from \"../../../interfaces\";\n\nconst valueFormatter = Intl.NumberFormat(navigator.language).format;\n\nexport function getLabel({\n\torgUnit,\n\tdata,\n\tlabelConfig,\n}: {\n\tlabelConfig: LayerLabelConfig;\n\torgUnit: { name: string };\n\tdata?: number;\n}) {\n\ttemplateSettings.interpolate = /{([\\s\\S]+?)}/g;\n\n\treturn template(labelConfig.labelTemplate.replace(/\\n/g, \"<br />\"))({\n\t\tname: orgUnit.name,\n\t\tvalue: data ? valueFormatter(data) : \"\",\n\t});\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/components/Map/components/MapLayer/interfaces/index.ts"],"names":[],"mappings":";;AAUO,MAAM,6BAAgC,GAAA;AAAA,EAC5C,YAAA;AAAA,EACA,YAAA;AAAA,EACA,WAAA;AAAA,EACA;AACD","file":"index.js","sourcesContent":["import type { Legend } from \"@hisptz/dhis2-utils\";\nimport { MapOrgUnit, PointOrgUnit } from \"../../../interfaces
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/components/Map/components/MapLayer/interfaces/index.ts"],"names":[],"mappings":";;AAUO,MAAM,6BAAgC,GAAA;AAAA,EAC5C,YAAA;AAAA,EACA,YAAA;AAAA,EACA,WAAA;AAAA,EACA;AACD","file":"index.js","sourcesContent":["import type { Legend } from \"@hisptz/dhis2-utils\";\nimport { MapOrgUnit, PointOrgUnit } from \"../../../interfaces\";\nimport { LegendColorScale } from \"../../../utils\";\nimport { EarthEngineOptions } from \"../components/GoogleEngineLayer/interfaces\";\nimport { EarthEngine } from \"../components/GoogleEngineLayer/services/engine.js\";\nimport type { LeafletEventHandlerFnMap, LeafletMouseEvent } from \"leaflet\";\n\nexport type BoundaryLayerType = \"basemap\" | \"overlay\";\nexport type ThematicLayerType = \"choropleth\" | \"bubble\";\n\nexport const SUPPORTED_EARTH_ENGINE_LAYERS = [\n\t\"population\",\n\t\"footprints\",\n\t\"elevation\",\n\t\"landCover\",\n];\n\nexport type GoogleEngineLayerType =\n\t| \"population\"\n\t| \"footprints\"\n\t| \"elevation\"\n\t| \"landCover\";\n\nexport interface CustomBoundaryLayer extends CustomMapLayer {\n\tid: string;\n\ttype: BoundaryLayerType;\n\tenabled: boolean;\n}\n\nexport interface EarthEngineLayerConfig extends CustomMapLayer {\n\ttype: GoogleEngineLayerType;\n\taggregations?: string[];\n\tname?: string;\n\tfilters?: {\n\t\tperiod: string;\n\t};\n\tparams?: {\n\t\tmin: number;\n\t\tmax: number;\n\t\tpalette?: string;\n\t};\n}\n\nexport interface CustomGoogleEngineLayer extends CustomMapLayer {\n\ttype: GoogleEngineLayerType;\n\toptions: EarthEngineOptions;\n\taggregations?: string[];\n\tname: string;\n\turl: string;\n\tengine?: EarthEngine;\n}\n\nexport interface CustomPointLayer extends CustomMapLayer {\n\tid: string;\n\ttype: \"point\";\n\tlabel?: string;\n\tlevel?: string | number;\n\tgroup?: string;\n\tstyle?: {\n\t\ticon?: string;\n\t\tgroupSet?: string;\n\t\torgUnitGroups?: Array<{ name: string; symbol: string }>;\n\t};\n\tpoints?: Array<PointOrgUnit>;\n}\n\nexport type DataItemType = \"dataElement\" | \"indicator\" | \"programIndicator\";\n\nexport interface ThematicLayerDataItem {\n\tid: string;\n\tdisplayName: string;\n\ttype: DataItemType;\n\tlegendSet?: string;\n\tlegendConfig?: {\n\t\tcolorClass: LegendColorScale;\n\t\tscale: number;\n\t};\n}\n\nexport interface ThematicLayerControl {\n\tposition: \"topleft\" | \"topright\" | \"bottomleft\" | \"bottomright\";\n\tenabled: boolean;\n}\n\nexport interface ThematicLayerData {\n\torgUnit: MapOrgUnit;\n\tdata?: number;\n\tdataItem: ThematicLayerDataItem;\n}\n\nexport interface ThematicLayerRawData {\n\torgUnit: string;\n\tdata?: number;\n\tdataItem: string;\n}\n\nexport interface CustomChoroplethLayer extends CustomMapLayer {\n\tenabled: boolean;\n\tname?: string;\n\tdata: ThematicLayerData[];\n\tdataItem: ThematicLayerDataItem;\n\ttype: \"choropleth\";\n\tcontrol?: ThematicLayerControl;\n\tlegends?: Legend[];\n\tcustomEventHandlers?: LeafletEventHandlerFnMap;\n}\n\nexport interface CustomBubbleLayer extends CustomMapLayer {\n\tenabled: boolean;\n\tname?: string;\n\tdata: ThematicLayerData[];\n\tdataItem: ThematicLayerDataItem;\n\ttype: \"bubble\";\n\tcontrol?: ThematicLayerControl;\n\tlegends?: Legend[];\n\tradius?: {\n\t\tmin: number;\n\t\tmax: number;\n\t};\n}\n\nexport type CustomThematicLayer = CustomBubbleLayer | CustomChoroplethLayer;\n\ninterface LayerData {\n\torgUnit: MapOrgUnit;\n\tdata?: number;\n\tdataItem?: ThematicLayerDataItem;\n}\n\nexport type LayerLabelConfig = {\n\tlabels: boolean;\n\tlabelFontWeight: string;\n\tlabelTemplate: string;\n};\n\nexport interface ThematicLayerConfig {\n\tid: string;\n\tdata?: ThematicLayerRawData[];\n\tenabled: boolean;\n\tname?: string;\n\tdataItem: ThematicLayerDataItem;\n\ttype: ThematicLayerType;\n\tcontrol?: ThematicLayerControl;\n\tcustomEventHandlers?: LeafletEventHandlerFnMap;\n\tonLayerClick?: (e: LeafletMouseEvent, data: LayerData) => void;\n\tlabelConfig?: LayerLabelConfig;\n\tradius?: {\n\t\tmin: number;\n\t\tmax: number;\n\t};\n}\n\nexport interface CustomMapLayer {\n\tid: string;\n\ttype: string;\n\tenabled: boolean;\n\tcustomEventHandlers?: LeafletEventHandlerFnMap;\n\tonLayerClick?: (e: LeafletMouseEvent, data: LayerData) => void;\n\tlabelConfig?: LayerLabelConfig;\n}\n\nexport type MapLayer =\n\t| CustomBoundaryLayer\n\t| ThematicLayerConfig\n\t| CustomPointLayer\n\t| CustomGoogleEngineLayer;\n\nexport interface MapLayerProps {\n\tenabled: boolean;\n\ttype: \"boundary\" | \"thematic\" | \"external\" | \"point\" | \"earthEngine\";\n\tlayer: MapLayer;\n}\n"]}
|
|
@@ -6,9 +6,9 @@ var i18n = require('@dhis2/d2-i18n');
|
|
|
6
6
|
var ui = require('@dhis2/ui');
|
|
7
7
|
var lodash = require('lodash');
|
|
8
8
|
var react = require('react');
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
9
|
+
var state = require('../../state');
|
|
10
|
+
var utils = require('../../utils');
|
|
11
|
+
var src = require('@hisptz/dhis2-utils/src');
|
|
12
12
|
|
|
13
13
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
14
|
|
|
@@ -23,10 +23,10 @@ const boundaryQuery = {
|
|
|
23
23
|
},
|
|
24
24
|
analytics: {
|
|
25
25
|
resource: "analytics",
|
|
26
|
-
params: ({ orgUnitIds }) => ({
|
|
26
|
+
params: ({ orgUnitIds, periodIds }) => ({
|
|
27
27
|
dimension: [
|
|
28
28
|
`ou:${orgUnitIds.join(";")}`,
|
|
29
|
-
`pe:${
|
|
29
|
+
`pe:${periodIds.join(";")}`
|
|
30
30
|
],
|
|
31
31
|
skipData: true,
|
|
32
32
|
hierarchyMeta: true
|
|
@@ -39,16 +39,20 @@ function MapProvider({
|
|
|
39
39
|
periodSelection
|
|
40
40
|
}) {
|
|
41
41
|
const [orgUnits, setOrgUnits] = react.useState([]);
|
|
42
|
+
const [periods, setPeriods] = react.useState([]);
|
|
42
43
|
const { refetch, loading, error } = appRuntime.useDataQuery(boundaryQuery, {
|
|
43
44
|
lazy: true
|
|
44
45
|
});
|
|
45
46
|
react.useEffect(() => {
|
|
46
47
|
async function getOrgUnits() {
|
|
47
|
-
const rawOrgUnitIds =
|
|
48
|
-
const data = await refetch({
|
|
48
|
+
const rawOrgUnitIds = utils.getOrgUnitsSelection(orgUnitSelection);
|
|
49
|
+
const data = await refetch({
|
|
50
|
+
orgUnitIds: rawOrgUnitIds,
|
|
51
|
+
periodIds: periodSelection?.periods
|
|
52
|
+
});
|
|
49
53
|
const { analytics, boundaries } = data ?? {};
|
|
50
|
-
const rawOrgUnits =
|
|
51
|
-
const geoJSONObjects =
|
|
54
|
+
const rawOrgUnits = utils.sanitizeOrgUnits(analytics?.metaData);
|
|
55
|
+
const geoJSONObjects = utils.toGeoJson(
|
|
52
56
|
boundaries.filter((bound) => bound.co)
|
|
53
57
|
);
|
|
54
58
|
const orgUnits2 = lodash.compact(
|
|
@@ -67,6 +71,11 @@ function MapProvider({
|
|
|
67
71
|
};
|
|
68
72
|
})
|
|
69
73
|
);
|
|
74
|
+
const periodIds = analytics?.metaData?.dimensions?.pe ?? periodSelection?.periods;
|
|
75
|
+
const periods2 = periodIds.map(
|
|
76
|
+
(pe) => src.PeriodUtility.getPeriodById(pe)
|
|
77
|
+
);
|
|
78
|
+
setPeriods(periods2);
|
|
70
79
|
setOrgUnits(orgUnits2);
|
|
71
80
|
}
|
|
72
81
|
getOrgUnits().catch((error2) => console.log(error2));
|
|
@@ -81,12 +90,9 @@ function MapProvider({
|
|
|
81
90
|
error.message
|
|
82
91
|
] }) }) });
|
|
83
92
|
}
|
|
84
|
-
const periods = lodash.compact(
|
|
85
|
-
periodSelection?.periods?.map((pe) => dhis2Utils.PeriodUtility.getPeriodById(pe))
|
|
86
|
-
);
|
|
87
93
|
if (!lodash.isEmpty(orgUnits)) {
|
|
88
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
89
|
-
|
|
94
|
+
return /* @__PURE__ */ jsxRuntime.jsx(state.MapOrgUnitContext.Provider, { value: { orgUnitSelection, orgUnits }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
95
|
+
state.MapPeriodContext.Provider,
|
|
90
96
|
{
|
|
91
97
|
value: { ...periodSelection, periods },
|
|
92
98
|
children
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/components/Map/components/MapProvider/index.tsx"],"names":["useState","useDataQuery","useEffect","getOrgUnitsSelection","sanitizeOrgUnits","toGeoJson","orgUnits","compact","error","jsx","Center","CircularLoader","jsxs","i18n","
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/Map/components/MapProvider/index.tsx"],"names":["useState","useDataQuery","useEffect","getOrgUnitsSelection","sanitizeOrgUnits","toGeoJson","orgUnits","compact","periods","PeriodUtility","error","jsx","Center","CircularLoader","jsxs","i18n","isEmpty","MapOrgUnitContext","MapPeriodContext"],"mappings":";;;;;;;;;;;;;;;;AAUA,MAAM,aAAgB,GAAA;AAAA,EACrB,UAAY,EAAA;AAAA,IACX,QAAU,EAAA,aAAA;AAAA,IACV,MAAQ,EAAA,CAAC,EAAE,UAAA,EAAuB,MAAA;AAAA,MACjC,EAAI,EAAA,CAAA,GAAA,EAAM,UAAY,EAAA,IAAA,CAAK,GAAG,CAAC,CAAA;AAAA,KAChC;AAAA,GACD;AAAA,EACA,SAAW,EAAA;AAAA,IACV,QAAU,EAAA,WAAA;AAAA,IACV,MAAQ,EAAA,CAAC,EAAE,UAAA,EAAY,WAAsB,MAAA;AAAA,MAC5C,SAAW,EAAA;AAAA,QACV,CAAM,GAAA,EAAA,UAAA,CAAW,IAAK,CAAA,GAAG,CAAC,CAAA,CAAA;AAAA,QAC1B,CAAM,GAAA,EAAA,SAAA,CAAU,IAAK,CAAA,GAAG,CAAC,CAAA;AAAA,OAC1B;AAAA,MACA,QAAU,EAAA,IAAA;AAAA,MACV,aAAe,EAAA;AAAA,KAChB;AAAA;AAEF,CAAA;AAEO,SAAS,WAAY,CAAA;AAAA,EAC3B,QAAA;AAAA,EACA,gBAAA;AAAA,EACA;AACD,CAAqB,EAAA;AACpB,EAAA,MAAM,CAAC,QAAU,EAAA,WAAW,CAAI,GAAAA,cAAA,CAAuB,EAAE,CAAA;AACzD,EAAA,MAAM,CAAC,OAAS,EAAA,UAAU,CAAI,GAAAA,cAAA,CAAuB,EAAE,CAAA;AACvD,EAAA,MAAM,EAAE,OAAS,EAAA,OAA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AAA;AAIF,EAAO,OAAA,IAAA;AACR","file":"index.js","sourcesContent":["import { useDataQuery } from \"@dhis2/app-runtime\";\nimport i18n from \"@dhis2/d2-i18n\";\nimport { Center, CircularLoader } from \"@dhis2/ui\";\nimport { compact, isEmpty } from \"lodash\";\nimport React, { useEffect, useState } from \"react\";\nimport { MapOrgUnit, MapProviderProps } from \"../../interfaces\";\nimport { MapOrgUnitContext, MapPeriodContext } from \"../../state\";\nimport { getOrgUnitsSelection, sanitizeOrgUnits, toGeoJson } from \"../../utils\";\nimport { BasePeriod, PeriodUtility } from \"@hisptz/dhis2-utils/src\";\n\nconst boundaryQuery = {\n\tboundaries: {\n\t\tresource: \"geoFeatures\",\n\t\tparams: ({ orgUnitIds }: any) => ({\n\t\t\tou: `ou:${orgUnitIds?.join(\";\")}`,\n\t\t}),\n\t},\n\tanalytics: {\n\t\tresource: \"analytics\",\n\t\tparams: ({ orgUnitIds, periodIds }: any) => ({\n\t\t\tdimension: [\n\t\t\t\t`ou:${orgUnitIds.join(\";\")}`,\n\t\t\t\t`pe:${periodIds.join(\";\")}`,\n\t\t\t],\n\t\t\tskipData: true,\n\t\t\thierarchyMeta: true,\n\t\t}),\n\t},\n};\n\nexport function MapProvider({\n\tchildren,\n\torgUnitSelection,\n\tperiodSelection,\n}: MapProviderProps) {\n\tconst [orgUnits, setOrgUnits] = useState<MapOrgUnit[]>([]);\n\tconst [periods, setPeriods] = useState<BasePeriod[]>([]);\n\tconst { refetch, loading, error } = useDataQuery(boundaryQuery, {\n\t\tlazy: true,\n\t});\n\n\tuseEffect(() => {\n\t\tasync function getOrgUnits() {\n\t\t\tconst rawOrgUnitIds = getOrgUnitsSelection(orgUnitSelection);\n\t\t\tconst data = await refetch({\n\t\t\t\torgUnitIds: rawOrgUnitIds,\n\t\t\t\tperiodIds: periodSelection?.periods,\n\t\t\t});\n\t\t\tconst { analytics, boundaries } = (data as any) ?? {};\n\t\t\tconst rawOrgUnits = sanitizeOrgUnits(analytics?.metaData);\n\t\t\tconst geoJSONObjects = toGeoJson(\n\t\t\t\tboundaries.filter((bound: any) => bound.co),\n\t\t\t);\n\t\t\tconst orgUnits: MapOrgUnit[] = compact(\n\t\t\t\trawOrgUnits.map((orgUnit: any) => {\n\t\t\t\t\tconst geoJSONObject: any = geoJSONObjects?.find(\n\t\t\t\t\t\t(geoJSON: any) => geoJSON.properties.id === orgUnit.id,\n\t\t\t\t\t);\n\n\t\t\t\t\tif (!geoJSONObject) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...orgUnit,\n\t\t\t\t\t\tgeoJSON: geoJSONObject,\n\t\t\t\t\t\tbounds: [],\n\t\t\t\t\t\tlevel: geoJSONObject.properties.level,\n\t\t\t\t\t};\n\t\t\t\t}),\n\t\t\t);\n\t\t\tconst periodIds =\n\t\t\t\tanalytics?.metaData?.dimensions?.pe ?? periodSelection?.periods;\n\t\t\tconst periods = periodIds.map((pe: string) =>\n\t\t\t\tPeriodUtility.getPeriodById(pe),\n\t\t\t);\n\t\t\tsetPeriods(periods);\n\t\t\tsetOrgUnits(orgUnits);\n\t\t}\n\n\t\tgetOrgUnits().catch((error) => console.log(error));\n\t}, [orgUnitSelection, refetch]);\n\n\tif (loading) {\n\t\treturn (\n\t\t\t<div style={{ height: \"100%\", width: \"100%\" }}>\n\t\t\t\t<Center>\n\t\t\t\t\t<CircularLoader small />\n\t\t\t\t</Center>\n\t\t\t</div>\n\t\t);\n\t}\n\n\tif (error) {\n\t\treturn (\n\t\t\t<div style={{ height: \"100%\", width: \"100%\" }}>\n\t\t\t\t<Center>\n\t\t\t\t\t<h4>\n\t\t\t\t\t\t{i18n.t(\"Error\")}: {error.message}\n\t\t\t\t\t</h4>\n\t\t\t\t</Center>\n\t\t\t</div>\n\t\t);\n\t}\n\n\tif (!isEmpty(orgUnits)) {\n\t\treturn (\n\t\t\t<MapOrgUnitContext.Provider value={{ orgUnitSelection, orgUnits }}>\n\t\t\t\t<MapPeriodContext.Provider\n\t\t\t\t\tvalue={{ ...periodSelection, periods }}\n\t\t\t\t>\n\t\t\t\t\t{children}\n\t\t\t\t</MapPeriodContext.Provider>\n\t\t\t</MapOrgUnitContext.Provider>\n\t\t);\n\t}\n\n\treturn null;\n}\n"]}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
1
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import { colors } from '@dhis2/ui';
|
|
3
3
|
import { GeoJSON } from 'react-leaflet';
|
|
4
|
-
import { getColorFromLegendSet, resetHighlight, highlightFeature } from '../../../../../../utils
|
|
4
|
+
import { getColorFromLegendSet, resetHighlight, highlightFeature } from '../../../../../../utils';
|
|
5
5
|
import CustomTooltip from '../CustomTooltip/index.js';
|
|
6
|
+
import { LabelMarker } from '../LabelMarker';
|
|
7
|
+
import { getCenter } from 'geolib';
|
|
8
|
+
import { chunk, flattenDeep } from 'lodash';
|
|
6
9
|
|
|
7
10
|
const defaultStyle = {
|
|
8
11
|
weight: 1
|
|
@@ -14,10 +17,21 @@ function Choropleth({
|
|
|
14
17
|
data,
|
|
15
18
|
legends,
|
|
16
19
|
customEventHandlers,
|
|
17
|
-
onLayerClick
|
|
20
|
+
onLayerClick,
|
|
21
|
+
labelConfig
|
|
18
22
|
}) {
|
|
19
23
|
const { orgUnit } = data;
|
|
20
|
-
|
|
24
|
+
const color = getColorFromLegendSet(legends, data.data);
|
|
25
|
+
const center = getCenter(
|
|
26
|
+
chunk(
|
|
27
|
+
flattenDeep(orgUnit.geoJSON.geometry.coordinates),
|
|
28
|
+
2
|
|
29
|
+
).map(([latitude, longitude]) => ({
|
|
30
|
+
longitude,
|
|
31
|
+
latitude
|
|
32
|
+
}))
|
|
33
|
+
);
|
|
34
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
|
|
21
35
|
GeoJSON,
|
|
22
36
|
{
|
|
23
37
|
data: orgUnit.geoJSON,
|
|
@@ -31,13 +45,27 @@ function Choropleth({
|
|
|
31
45
|
}
|
|
32
46
|
}
|
|
33
47
|
},
|
|
48
|
+
interactive: true,
|
|
34
49
|
pathOptions: {
|
|
35
|
-
fillColor:
|
|
50
|
+
fillColor: color,
|
|
36
51
|
fillOpacity: 1,
|
|
37
52
|
color: colors.grey900,
|
|
53
|
+
fill: true,
|
|
38
54
|
weight: 1
|
|
39
55
|
},
|
|
40
|
-
children:
|
|
56
|
+
children: [
|
|
57
|
+
labelConfig && /* @__PURE__ */ jsx(
|
|
58
|
+
LabelMarker,
|
|
59
|
+
{
|
|
60
|
+
layerColor: color,
|
|
61
|
+
labelConfig,
|
|
62
|
+
data: data.data,
|
|
63
|
+
orgUnit,
|
|
64
|
+
center: [center.longitude, center.latitude]
|
|
65
|
+
}
|
|
66
|
+
),
|
|
67
|
+
/* @__PURE__ */ jsx(CustomTooltip, { data })
|
|
68
|
+
]
|
|
41
69
|
},
|
|
42
70
|
`${data.dataItem.id}-layer`
|
|
43
71
|
) });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../../../src/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../../src/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/index.tsx"],"names":[],"mappings":";;;;;;;;;AAoBA,MAAM,YAAe,GAAA;AAAA,EACpB,MAAQ,EAAA;AACT,CAAA;AACA,MAAM,cAAiB,GAAA;AAAA,EACtB,MAAQ,EAAA;AACT,CAAA;AAQe,SAAR,UAA4B,CAAA;AAAA,EAClC,IAAA;AAAA,EACA,OAAA;AAAA,EACA,mBAAA;AAAA,EACA,YAAA;AAAA,EACA;AACD,CAMG,EAAA;AACF,EAAM,MAAA,EAAE,SAAY,GAAA,IAAA;AACpB,EAAA,MAAM,KAAQ,GAAA,qBAAA,CAAsB,OAAS,EAAA,IAAA,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3C;AAAA,wBAED,GAAA,CAAC,iBAAc,IAAY,EAAA;AAAA;AAAA,KAAA;AAAA,IAXtB,CAAA,EAAG,IAAK,CAAA,QAAA,CAAS,EAAE,CAAA,MAAA;AAAA,GAa1B,EAAA,CAAA;AAEF","file":"index.js","sourcesContent":["import { colors } from \"@dhis2/ui\";\nimport type { Legend } from \"@hisptz/dhis2-utils\";\nimport React from \"react\";\nimport { GeoJSON } from \"react-leaflet\";\nimport { MapOrgUnit } from \"../../../../../../interfaces\";\nimport {\n\tgetColorFromLegendSet,\n\thighlightFeature,\n\tresetHighlight,\n} from \"../../../../../../utils\";\nimport {\n\ttype LayerLabelConfig,\n\tThematicLayerDataItem,\n} from \"../../../../interfaces\";\nimport CustomTooltip from \"../CustomTooltip/index.js\";\nimport { type LeafletEventHandlerFnMap, type LeafletMouseEvent } from \"leaflet\";\nimport { LabelMarker } from \"../LabelMarker\";\nimport { getCenter } from \"geolib\";\nimport { chunk, flattenDeep } from \"lodash\";\n\nconst defaultStyle = {\n\tweight: 1,\n};\nconst highlightStyle = {\n\tweight: 2,\n};\n\ninterface LayerData {\n\torgUnit: MapOrgUnit;\n\tdata?: number;\n\tdataItem: ThematicLayerDataItem;\n}\n\nexport default function Choropleth({\n\tdata,\n\tlegends,\n\tcustomEventHandlers,\n\tonLayerClick,\n\tlabelConfig,\n}: {\n\tdata: LayerData;\n\tlegends: Legend[];\n\tcustomEventHandlers?: LeafletEventHandlerFnMap;\n\tonLayerClick?: (e: LeafletMouseEvent, data: LayerData) => void;\n\tlabelConfig?: LayerLabelConfig;\n}) {\n\tconst { orgUnit } = data;\n\tconst color = getColorFromLegendSet(legends, data.data);\n\n\tconst center = getCenter(\n\t\tchunk<number>(\n\t\t\tflattenDeep<number>(orgUnit.geoJSON.geometry.coordinates),\n\t\t\t2,\n\t\t).map(([latitude, longitude]: number[]) => ({\n\t\t\tlongitude,\n\t\t\tlatitude,\n\t\t})),\n\t) as {\n\t\tlongitude: number;\n\t\tlatitude: number;\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<GeoJSON\n\t\t\t\tdata={orgUnit.geoJSON}\n\t\t\t\teventHandlers={{\n\t\t\t\t\tmouseover: (e) => highlightFeature(e, highlightStyle),\n\t\t\t\t\tmouseout: (e) => resetHighlight(e, defaultStyle),\n\t\t\t\t\t...(customEventHandlers ?? {}),\n\t\t\t\t\tmousedown: (e) => {\n\t\t\t\t\t\tif (onLayerClick) {\n\t\t\t\t\t\t\tonLayerClick(e, data);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t}}\n\t\t\t\tinteractive\n\t\t\t\tpathOptions={{\n\t\t\t\t\tfillColor: color,\n\t\t\t\t\tfillOpacity: 1,\n\t\t\t\t\tcolor: colors.grey900,\n\t\t\t\t\tfill: true,\n\t\t\t\t\tweight: 1,\n\t\t\t\t}}\n\t\t\t\tkey={`${data.dataItem.id}-layer`}\n\t\t\t>\n\t\t\t\t{labelConfig && (\n\t\t\t\t\t<LabelMarker\n\t\t\t\t\t\tlayerColor={color}\n\t\t\t\t\t\tlabelConfig={labelConfig}\n\t\t\t\t\t\tdata={data.data}\n\t\t\t\t\t\torgUnit={orgUnit}\n\t\t\t\t\t\tcenter={[center.longitude, center.latitude]}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t\t<CustomTooltip data={data} />\n\t\t\t</GeoJSON>\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { Marker } from 'react-leaflet';
|
|
3
|
+
import { getLabel } from '../../utils/label';
|
|
4
|
+
import L from 'leaflet';
|
|
5
|
+
import './label.css';
|
|
6
|
+
import { getTextColorFromBackgroundColor } from '../../../../../../../DHIS2PivotTable/utils/color';
|
|
7
|
+
|
|
8
|
+
function LabelMarker({
|
|
9
|
+
labelConfig,
|
|
10
|
+
data,
|
|
11
|
+
orgUnit,
|
|
12
|
+
center,
|
|
13
|
+
layerColor
|
|
14
|
+
}) {
|
|
15
|
+
const label = getLabel({
|
|
16
|
+
labelConfig,
|
|
17
|
+
data,
|
|
18
|
+
orgUnit
|
|
19
|
+
});
|
|
20
|
+
const labelIcon = L.divIcon({
|
|
21
|
+
className: "label-icon",
|
|
22
|
+
html: `<span style="color: ${getTextColorFromBackgroundColor(layerColor)}; text-align: center; font-size: 12px">${label}</span>`
|
|
23
|
+
});
|
|
24
|
+
return /* @__PURE__ */ jsx(Marker, { zIndexOffset: 1e3, icon: labelIcon, position: center });
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { LabelMarker };
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../../src/components/Map/components/MapLayer/components/ThematicLayer/components/LabelMarker/index.tsx"],"names":[],"mappings":";;;;;;;AAOO,SAAS,WAAY,CAAA;AAAA,EAC3B,WAAA;AAAA,EACA,IAAA;AAAA,EACA,OAAA;AAAA,EACA,MAAA;AAAA,EACA;AACD,CAMG,EAAA;AACF,EAAA,MAAM,QAAQ,QAAS,CAAA;AAAA,IACtB,WAAA;AAAA,IACA,IAAA;AAAA,IACA;AAAA,GACA,CAAA;AAED,EAAM,MAAA,SAAA,GAAY,EAAE,OAAQ,CAAA;AAAA,IAC3B,SAAW,EAAA,YAAA;AAAA,IACX,MAAM,CAAuB,oBAAA,EAAA,+BAAA,CAAgC,UAAU,CAAC,0CAA0C,KAAK,CAAA,OAAA;AAAA,GACvH,CAAA;AAED,EAAA,2BAAQ,MAAO,EAAA,EAAA,YAAA,EAAc,KAAM,IAAM,EAAA,SAAA,EAAW,UAAU,MAAQ,EAAA,CAAA;AACvE","file":"index.js","sourcesContent":["import { Marker } from \"react-leaflet\";\nimport { getLabel } from \"../../utils/label\";\nimport type { LayerLabelConfig } from \"../../../../interfaces\";\nimport L, { type LatLngExpression } from \"leaflet\";\nimport \"./label.css\";\nimport { getTextColorFromBackgroundColor } from \"../../../../../../../DHIS2PivotTable/utils/color\";\n\nexport function LabelMarker({\n\tlabelConfig,\n\tdata,\n\torgUnit,\n\tcenter,\n\tlayerColor,\n}: {\n\tlabelConfig: LayerLabelConfig;\n\tdata: number | undefined;\n\torgUnit: { name: string };\n\tcenter: LatLngExpression;\n\tlayerColor: string;\n}) {\n\tconst label = getLabel({\n\t\tlabelConfig,\n\t\tdata,\n\t\torgUnit,\n\t});\n\n\tconst labelIcon = L.divIcon({\n\t\tclassName: \"label-icon\",\n\t\thtml: `<span style=\"color: ${getTextColorFromBackgroundColor(layerColor)}; text-align: center; font-size: 12px\">${label}</span>`,\n\t});\n\n\treturn <Marker zIndexOffset={1000} icon={labelIcon} position={center} />;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../../src/components/Map/components/MapLayer/components/ThematicLayer/components/LabelMarker/label.css"],"sourcesContent":[".label-icon {\n background: transparent;\n border: none;\n font-size: 12px;\n font-weight: bold;\n text-align: center;\n white-space: nowrap;\n pointer-events: none; /* prevents label from blocking map clicks */\n margin: auto\n}\n"],"mappings":"AAAA,CAAC;AACG,cAAY;AACZ,UAAQ;AACR,aAAW;AACX,eAAa;AACb,cAAY;AACZ,eAAa;AACb,kBAAgB;AAChB,UAAQ;AACZ;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../src/components/Map/components/MapLayer/components/ThematicLayer/index.tsx"],"names":[],"mappings":";;;;;;;AAQe,SAAR,aAA+B,CAAA;AAAA,EACrC,OAAA;AAAA,EACA;AACD,CAGG,EAAA;AACF,EAAM,MAAA,KAAA,GAAQ,iBAAiB,OAAO,CAAA;AAEtC,EAAA,IAAI,CAAC,KAAO,EAAA;AACX,IAAO,OAAA,IAAA;AAAA;AAGR,EAAM,MAAA;AAAA,IACL,IAAA;AAAA,IACA,QAAA;AAAA,IACA,IAAA;AAAA,IACA,IA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,CAAA,EAAA,KAAA,EAAO,SAAS,EAAE,CAAA,MAAA;AAAA,WAE/C,GAAA;AAAA;AACL,OACD,EAAA;AAAA;AAAA,KAEF,CACD,EAAA,CAAA;AAEF","file":"index.js","sourcesContent":["import { last } from \"lodash\";\nimport React from \"react\";\nimport { LayerGroup, LayersControl, Pane } from \"react-leaflet\";\nimport { CustomBubbleLayer } from \"../../interfaces
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../src/components/Map/components/MapLayer/components/ThematicLayer/index.tsx"],"names":[],"mappings":";;;;;;;AAQe,SAAR,aAA+B,CAAA;AAAA,EACrC,OAAA;AAAA,EACA;AACD,CAGG,EAAA;AACF,EAAM,MAAA,KAAA,GAAQ,iBAAiB,OAAO,CAAA;AAEtC,EAAA,IAAI,CAAC,KAAO,EAAA;AACX,IAAO,OAAA,IAAA;AAAA;AAGR,EAAM,MAAA;AAAA,IACL,IAAA;AAAA,IACA,QAAA;AAAA,IACA,IAAA;AAAA,IACA,IAAA;AAAA,IACA,OAAA;AAAA,IACA,OAAA;AAAA,IACA,mBAAA;AAAA,IACA;AAAA,GACD,GAAI,SAAS,EAAC;AACd,EAAM,MAAA,UAAA,GAAa,QAAQ,QAAS,CAAA,WAAA;AACpC,EACC,uBAAA,GAAA,CAAA,QAAA,EAAA,EACC,8BAAC,aAAc,CAAA,OAAA,EAAd,EAAsB,OAAS,EAAA,OAAA,EAAS,MAAM,UAC9C,EAAA,QAAA,kBAAA,GAAA;AAAA,IAAC,IAAA;AAAA,IAAA;AAAA,MACA,KAAO,EAAA;AAAA,QACN,MAAQ,EAAA,IAAA,KAAS,QAAW,GAAA,GAAA,GAAM,OAAO,KAAQ,GAAA,CAAA;AAAA,OAClD;AAAA,MACA,IAAM,EAAA,UAAA;AAAA,MAEN,+BAAC,UACC,EAAA,EAAA,QAAA,EAAA;AAAA,QAAM,IAAA,EAAA,GAAA;AAAA,UAAI,CAAC,KACX,KAAA,IAAA,KAAS,YACR,mBAAA,GAAA;AAAA,YAAC,UAAA;AAAA,YAAA;AAAA,cACA,aAAa,KAAM,CAAA,WAAA;AAAA,cACnB,mBAAA;AAAA,cACA,YAAA;AAAA,cACA,OAAA,EAAS,WAAW,EAAC;AAAA,cACrB,IAAM,EAAA;AAAA,aAAA;AAAA,YACD,GAAG,KAAO,EAAA,QAAA,EAAU,EAAE,CAAI,CAAA,EAAA,KAAA,EAAO,SAAS,EAAE,CAAA,MAAA;AAAA,WAE/C,GAAA;AAAA,SACL;AAAA,QACC,IAAM,EAAA,GAAA;AAAA,UAAI,CAAC,KACX,KAAA,IAAA,KAAS,QACR,mBAAA,GAAA;AAAA,YAAC,MAAA;AAAA,YAAA;AAAA,cACA,QACE,KAA6B,EAAA,MAAA;AAAA,cAE/B,OAAA,EAAS,WAAW,EAAC;AAAA,cACrB,WAAa,EAAA,IAAA,CAAK,IAAI,CAAA,EAAG,IAAQ,IAAA,CAAA;AAAA,cACjC,IAAM,EAAA;AAAA,aAAA;AAAA,YACD,GAAG,KAAO,EAAA,QAAA,EAAU,EAAE,CAAI,CAAA,EAAA,KAAA,EAAO,SAAS,EAAE,CAAA,MAAA;AAAA,WAE/C,GAAA;AAAA;AACL,OACD,EAAA;AAAA;AAAA,KAEF,CACD,EAAA,CAAA;AAEF","file":"index.js","sourcesContent":["import { last } from \"lodash\";\nimport React from \"react\";\nimport { LayerGroup, LayersControl, Pane } from \"react-leaflet\";\nimport { CustomBubbleLayer } from \"../../interfaces\";\nimport Bubble from \"./components/Bubble/index.js\";\nimport Choropleth from \"./components/Choropleth/index.js\";\nimport useThematicLayer from \"./hooks/config.js\";\n\nexport default function ThematicLayer({\n\tlayerId,\n\tindex,\n}: {\n\tlayerId: string;\n\tindex: number;\n}) {\n\tconst layer = useThematicLayer(layerId);\n\n\tif (!layer) {\n\t\treturn null;\n\t}\n\n\tconst {\n\t\ttype,\n\t\tdataItem,\n\t\tname,\n\t\tdata,\n\t\tenabled,\n\t\tlegends,\n\t\tcustomEventHandlers,\n\t\tonLayerClick,\n\t} = layer ?? {};\n\tconst uniqueName = name ?? dataItem.displayName;\n\treturn (\n\t\t<>\n\t\t\t<LayersControl.Overlay checked={enabled} name={uniqueName}>\n\t\t\t\t<Pane\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tzIndex: type === \"bubble\" ? 500 : 500 - (index + 1),\n\t\t\t\t\t}}\n\t\t\t\t\tname={uniqueName}\n\t\t\t\t>\n\t\t\t\t\t<LayerGroup>\n\t\t\t\t\t\t{data?.map((datum) =>\n\t\t\t\t\t\t\ttype === \"choropleth\" ? (\n\t\t\t\t\t\t\t\t<Choropleth\n\t\t\t\t\t\t\t\t\tlabelConfig={layer.labelConfig}\n\t\t\t\t\t\t\t\t\tcustomEventHandlers={customEventHandlers}\n\t\t\t\t\t\t\t\t\tonLayerClick={onLayerClick}\n\t\t\t\t\t\t\t\t\tlegends={legends ?? []}\n\t\t\t\t\t\t\t\t\tdata={datum}\n\t\t\t\t\t\t\t\t\tkey={`${datum?.dataItem?.id}-${datum?.orgUnit?.id}-layer`}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) : null,\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t{data?.map((datum) =>\n\t\t\t\t\t\t\ttype === \"bubble\" ? (\n\t\t\t\t\t\t\t\t<Bubble\n\t\t\t\t\t\t\t\t\tradius={\n\t\t\t\t\t\t\t\t\t\t(layer as CustomBubbleLayer)?.radius\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tlegends={legends ?? []}\n\t\t\t\t\t\t\t\t\thighestData={last(data)?.data ?? 1}\n\t\t\t\t\t\t\t\t\tdata={datum}\n\t\t\t\t\t\t\t\t\tkey={`${datum?.dataItem?.id}-${datum?.orgUnit?.id}-layer`}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) : null,\n\t\t\t\t\t\t)}\n\t\t\t\t\t</LayerGroup>\n\t\t\t\t</Pane>\n\t\t\t</LayersControl.Overlay>\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { templateSettings, template } from 'lodash';
|
|
2
|
+
|
|
3
|
+
const valueFormatter = Intl.NumberFormat(navigator.language).format;
|
|
4
|
+
function getLabel({
|
|
5
|
+
orgUnit,
|
|
6
|
+
data,
|
|
7
|
+
labelConfig
|
|
8
|
+
}) {
|
|
9
|
+
templateSettings.interpolate = /{([\s\S]+?)}/g;
|
|
10
|
+
return template(labelConfig.labelTemplate.replace(/\n/g, "<br />"))({
|
|
11
|
+
name: orgUnit.name,
|
|
12
|
+
value: data ? valueFormatter(data) : ""
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { getLabel };
|
|
17
|
+
//# sourceMappingURL=label.js.map
|
|
18
|
+
//# sourceMappingURL=label.js.map
|
package/dist/esm/components/Map/components/MapLayer/components/ThematicLayer/utils/label.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../src/components/Map/components/MapLayer/components/ThematicLayer/utils/label.ts"],"names":[],"mappings":";;AAGA,MAAM,cAAiB,GAAA,IAAA,CAAK,YAAa,CAAA,SAAA,CAAU,QAAQ,CAAE,CAAA,MAAA;AAEtD,SAAS,QAAS,CAAA;AAAA,EACxB,OAAA;AAAA,EACA,IAAA;AAAA,EACA;AACD,CAIG,EAAA;AACF,EAAA,gBAAA,CAAiB,WAAc,GAAA,eAAA;AAE/B,EAAA,OAAO,SAAS,WAAY,CAAA,aAAA,CAAc,QAAQ,KAAO,EAAA,QAAQ,CAAC,CAAE,CAAA;AAAA,IACnE,MAAM,OAAQ,CAAA,IAAA;AAAA,IACd,KAAO,EAAA,IAAA,GAAO,cAAe,CAAA,IAAI,CAAI,GAAA;AAAA,GACrC,CAAA;AACF","file":"label.js","sourcesContent":["import { template, templateSettings } from \"lodash\";\nimport type { LayerLabelConfig } from \"../../../interfaces\";\n\nconst valueFormatter = Intl.NumberFormat(navigator.language).format;\n\nexport function getLabel({\n\torgUnit,\n\tdata,\n\tlabelConfig,\n}: {\n\tlabelConfig: LayerLabelConfig;\n\torgUnit: { name: string };\n\tdata?: number;\n}) {\n\ttemplateSettings.interpolate = /{([\\s\\S]+?)}/g;\n\n\treturn template(labelConfig.labelTemplate.replace(/\\n/g, \"<br />\"))({\n\t\tname: orgUnit.name,\n\t\tvalue: data ? valueFormatter(data) : \"\",\n\t});\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/components/Map/components/MapLayer/interfaces/index.ts"],"names":[],"mappings":"AAUO,MAAM,6BAAgC,GAAA;AAAA,EAC5C,YAAA;AAAA,EACA,YAAA;AAAA,EACA,WAAA;AAAA,EACA;AACD","file":"index.js","sourcesContent":["import type { Legend } from \"@hisptz/dhis2-utils\";\nimport { MapOrgUnit, PointOrgUnit } from \"../../../interfaces
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/components/Map/components/MapLayer/interfaces/index.ts"],"names":[],"mappings":"AAUO,MAAM,6BAAgC,GAAA;AAAA,EAC5C,YAAA;AAAA,EACA,YAAA;AAAA,EACA,WAAA;AAAA,EACA;AACD","file":"index.js","sourcesContent":["import type { Legend } from \"@hisptz/dhis2-utils\";\nimport { MapOrgUnit, PointOrgUnit } from \"../../../interfaces\";\nimport { LegendColorScale } from \"../../../utils\";\nimport { EarthEngineOptions } from \"../components/GoogleEngineLayer/interfaces\";\nimport { EarthEngine } from \"../components/GoogleEngineLayer/services/engine.js\";\nimport type { LeafletEventHandlerFnMap, LeafletMouseEvent } from \"leaflet\";\n\nexport type BoundaryLayerType = \"basemap\" | \"overlay\";\nexport type ThematicLayerType = \"choropleth\" | \"bubble\";\n\nexport const SUPPORTED_EARTH_ENGINE_LAYERS = [\n\t\"population\",\n\t\"footprints\",\n\t\"elevation\",\n\t\"landCover\",\n];\n\nexport type GoogleEngineLayerType =\n\t| \"population\"\n\t| \"footprints\"\n\t| \"elevation\"\n\t| \"landCover\";\n\nexport interface CustomBoundaryLayer extends CustomMapLayer {\n\tid: string;\n\ttype: BoundaryLayerType;\n\tenabled: boolean;\n}\n\nexport interface EarthEngineLayerConfig extends CustomMapLayer {\n\ttype: GoogleEngineLayerType;\n\taggregations?: string[];\n\tname?: string;\n\tfilters?: {\n\t\tperiod: string;\n\t};\n\tparams?: {\n\t\tmin: number;\n\t\tmax: number;\n\t\tpalette?: string;\n\t};\n}\n\nexport interface CustomGoogleEngineLayer extends CustomMapLayer {\n\ttype: GoogleEngineLayerType;\n\toptions: EarthEngineOptions;\n\taggregations?: string[];\n\tname: string;\n\turl: string;\n\tengine?: EarthEngine;\n}\n\nexport interface CustomPointLayer extends CustomMapLayer {\n\tid: string;\n\ttype: \"point\";\n\tlabel?: string;\n\tlevel?: string | number;\n\tgroup?: string;\n\tstyle?: {\n\t\ticon?: string;\n\t\tgroupSet?: string;\n\t\torgUnitGroups?: Array<{ name: string; symbol: string }>;\n\t};\n\tpoints?: Array<PointOrgUnit>;\n}\n\nexport type DataItemType = \"dataElement\" | \"indicator\" | \"programIndicator\";\n\nexport interface ThematicLayerDataItem {\n\tid: string;\n\tdisplayName: string;\n\ttype: DataItemType;\n\tlegendSet?: string;\n\tlegendConfig?: {\n\t\tcolorClass: LegendColorScale;\n\t\tscale: number;\n\t};\n}\n\nexport interface ThematicLayerControl {\n\tposition: \"topleft\" | \"topright\" | \"bottomleft\" | \"bottomright\";\n\tenabled: boolean;\n}\n\nexport interface ThematicLayerData {\n\torgUnit: MapOrgUnit;\n\tdata?: number;\n\tdataItem: ThematicLayerDataItem;\n}\n\nexport interface ThematicLayerRawData {\n\torgUnit: string;\n\tdata?: number;\n\tdataItem: string;\n}\n\nexport interface CustomChoroplethLayer extends CustomMapLayer {\n\tenabled: boolean;\n\tname?: string;\n\tdata: ThematicLayerData[];\n\tdataItem: ThematicLayerDataItem;\n\ttype: \"choropleth\";\n\tcontrol?: ThematicLayerControl;\n\tlegends?: Legend[];\n\tcustomEventHandlers?: LeafletEventHandlerFnMap;\n}\n\nexport interface CustomBubbleLayer extends CustomMapLayer {\n\tenabled: boolean;\n\tname?: string;\n\tdata: ThematicLayerData[];\n\tdataItem: ThematicLayerDataItem;\n\ttype: \"bubble\";\n\tcontrol?: ThematicLayerControl;\n\tlegends?: Legend[];\n\tradius?: {\n\t\tmin: number;\n\t\tmax: number;\n\t};\n}\n\nexport type CustomThematicLayer = CustomBubbleLayer | CustomChoroplethLayer;\n\ninterface LayerData {\n\torgUnit: MapOrgUnit;\n\tdata?: number;\n\tdataItem?: ThematicLayerDataItem;\n}\n\nexport type LayerLabelConfig = {\n\tlabels: boolean;\n\tlabelFontWeight: string;\n\tlabelTemplate: string;\n};\n\nexport interface ThematicLayerConfig {\n\tid: string;\n\tdata?: ThematicLayerRawData[];\n\tenabled: boolean;\n\tname?: string;\n\tdataItem: ThematicLayerDataItem;\n\ttype: ThematicLayerType;\n\tcontrol?: ThematicLayerControl;\n\tcustomEventHandlers?: LeafletEventHandlerFnMap;\n\tonLayerClick?: (e: LeafletMouseEvent, data: LayerData) => void;\n\tlabelConfig?: LayerLabelConfig;\n\tradius?: {\n\t\tmin: number;\n\t\tmax: number;\n\t};\n}\n\nexport interface CustomMapLayer {\n\tid: string;\n\ttype: string;\n\tenabled: boolean;\n\tcustomEventHandlers?: LeafletEventHandlerFnMap;\n\tonLayerClick?: (e: LeafletMouseEvent, data: LayerData) => void;\n\tlabelConfig?: LayerLabelConfig;\n}\n\nexport type MapLayer =\n\t| CustomBoundaryLayer\n\t| ThematicLayerConfig\n\t| CustomPointLayer\n\t| CustomGoogleEngineLayer;\n\nexport interface MapLayerProps {\n\tenabled: boolean;\n\ttype: \"boundary\" | \"thematic\" | \"external\" | \"point\" | \"earthEngine\";\n\tlayer: MapLayer;\n}\n"]}
|
|
@@ -2,11 +2,11 @@ import { jsx, jsxs } from 'react/jsx-runtime';
|
|
|
2
2
|
import { useDataQuery } from '@dhis2/app-runtime';
|
|
3
3
|
import i18n from '@dhis2/d2-i18n';
|
|
4
4
|
import { Center, CircularLoader } from '@dhis2/ui';
|
|
5
|
-
import {
|
|
5
|
+
import { isEmpty, compact } from 'lodash';
|
|
6
6
|
import { useState, useEffect } from 'react';
|
|
7
|
-
import { MapOrgUnitContext, MapPeriodContext } from '../../state
|
|
8
|
-
import { getOrgUnitsSelection, sanitizeOrgUnits, toGeoJson } from '../../utils
|
|
9
|
-
import { PeriodUtility } from '@hisptz/dhis2-utils';
|
|
7
|
+
import { MapOrgUnitContext, MapPeriodContext } from '../../state';
|
|
8
|
+
import { getOrgUnitsSelection, sanitizeOrgUnits, toGeoJson } from '../../utils';
|
|
9
|
+
import { PeriodUtility } from '@hisptz/dhis2-utils/src';
|
|
10
10
|
|
|
11
11
|
const boundaryQuery = {
|
|
12
12
|
boundaries: {
|
|
@@ -17,10 +17,10 @@ const boundaryQuery = {
|
|
|
17
17
|
},
|
|
18
18
|
analytics: {
|
|
19
19
|
resource: "analytics",
|
|
20
|
-
params: ({ orgUnitIds }) => ({
|
|
20
|
+
params: ({ orgUnitIds, periodIds }) => ({
|
|
21
21
|
dimension: [
|
|
22
22
|
`ou:${orgUnitIds.join(";")}`,
|
|
23
|
-
`pe:${
|
|
23
|
+
`pe:${periodIds.join(";")}`
|
|
24
24
|
],
|
|
25
25
|
skipData: true,
|
|
26
26
|
hierarchyMeta: true
|
|
@@ -33,13 +33,17 @@ function MapProvider({
|
|
|
33
33
|
periodSelection
|
|
34
34
|
}) {
|
|
35
35
|
const [orgUnits, setOrgUnits] = useState([]);
|
|
36
|
+
const [periods, setPeriods] = useState([]);
|
|
36
37
|
const { refetch, loading, error } = useDataQuery(boundaryQuery, {
|
|
37
38
|
lazy: true
|
|
38
39
|
});
|
|
39
40
|
useEffect(() => {
|
|
40
41
|
async function getOrgUnits() {
|
|
41
42
|
const rawOrgUnitIds = getOrgUnitsSelection(orgUnitSelection);
|
|
42
|
-
const data = await refetch({
|
|
43
|
+
const data = await refetch({
|
|
44
|
+
orgUnitIds: rawOrgUnitIds,
|
|
45
|
+
periodIds: periodSelection?.periods
|
|
46
|
+
});
|
|
43
47
|
const { analytics, boundaries } = data ?? {};
|
|
44
48
|
const rawOrgUnits = sanitizeOrgUnits(analytics?.metaData);
|
|
45
49
|
const geoJSONObjects = toGeoJson(
|
|
@@ -61,6 +65,11 @@ function MapProvider({
|
|
|
61
65
|
};
|
|
62
66
|
})
|
|
63
67
|
);
|
|
68
|
+
const periodIds = analytics?.metaData?.dimensions?.pe ?? periodSelection?.periods;
|
|
69
|
+
const periods2 = periodIds.map(
|
|
70
|
+
(pe) => PeriodUtility.getPeriodById(pe)
|
|
71
|
+
);
|
|
72
|
+
setPeriods(periods2);
|
|
64
73
|
setOrgUnits(orgUnits2);
|
|
65
74
|
}
|
|
66
75
|
getOrgUnits().catch((error2) => console.log(error2));
|
|
@@ -75,9 +84,6 @@ function MapProvider({
|
|
|
75
84
|
error.message
|
|
76
85
|
] }) }) });
|
|
77
86
|
}
|
|
78
|
-
const periods = compact(
|
|
79
|
-
periodSelection?.periods?.map((pe) => PeriodUtility.getPeriodById(pe))
|
|
80
|
-
);
|
|
81
87
|
if (!isEmpty(orgUnits)) {
|
|
82
88
|
return /* @__PURE__ */ jsx(MapOrgUnitContext.Provider, { value: { orgUnitSelection, orgUnits }, children: /* @__PURE__ */ jsx(
|
|
83
89
|
MapPeriodContext.Provider,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/components/Map/components/MapProvider/index.tsx"],"names":["orgUnits","error"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/components/Map/components/MapProvider/index.tsx"],"names":["orgUnits","periods","error"],"mappings":";;;;;;;;;;AAUA,MAAM,aAAgB,GAAA;AAAA,EACrB,UAAY,EAAA;AAAA,IACX,QAAU,EAAA,aAAA;AAAA,IACV,MAAQ,EAAA,CAAC,EAAE,UAAA,EAAuB,MAAA;AAAA,MACjC,EAAI,EAAA,CAAA,GAAA,EAAM,UAAY,EAAA,I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F,EAAA,IAAI,KAAO,EAAA;AACV,IAAA,uBACE,GAAA,CAAA,KAAA,EAAA,EAAI,KAAO,EAAA,EAAE,MAAQ,EAAA,MAAA,EAAQ,KAAO,EAAA,MAAA,EACpC,EAAA,QAAA,kBAAA,GAAA,CAAC,MACA,EAAA,EAAA,QAAA,kBAAA,IAAA,CAAC,IACC,EAAA,EAAA,QAAA,EAAA;AAAA,MAAA,IAAA,CAAK,EAAE,OAAO,CAAA;AAAA,MAAE,IAAA;AAAA,MAAG,KAAM,CAAA;AAAA,KAAA,EAC3B,GACD,CACD,EAAA,CAAA;AAAA;AAIF,EAAI,IAAA,CAAC,OAAQ,CAAA,QAAQ,CAAG,EAAA;AACvB,IACC,uBAAA,GAAA,CAAC,kBAAkB,QAAlB,EAAA,EAA2B,OAAO,EAAE,gBAAA,EAAkB,UACtD,EAAA,QAAA,kBAAA,GAAA;AAAA,MAAC,gBAAiB,CAAA,QAAA;AAAA,MAAjB;AAAA,QACA,KAAO,EAAA,EAAE,GAAG,eAAA,EAAiB,OAAQ,EAAA;AAAA,QAEpC;AAAA;AAAA,KAEH,EAAA,CAAA;AAAA;AAIF,EAAO,OAAA,IAAA;AACR","file":"index.js","sourcesContent":["import { useDataQuery } from \"@dhis2/app-runtime\";\nimport i18n from \"@dhis2/d2-i18n\";\nimport { Center, CircularLoader } from \"@dhis2/ui\";\nimport { compact, isEmpty } from \"lodash\";\nimport React, { useEffect, useState } from \"react\";\nimport { MapOrgUnit, MapProviderProps } from \"../../interfaces\";\nimport { MapOrgUnitContext, MapPeriodContext } from \"../../state\";\nimport { getOrgUnitsSelection, sanitizeOrgUnits, toGeoJson } from \"../../utils\";\nimport { BasePeriod, PeriodUtility } from \"@hisptz/dhis2-utils/src\";\n\nconst boundaryQuery = {\n\tboundaries: {\n\t\tresource: \"geoFeatures\",\n\t\tparams: ({ orgUnitIds }: any) => ({\n\t\t\tou: `ou:${orgUnitIds?.join(\";\")}`,\n\t\t}),\n\t},\n\tanalytics: {\n\t\tresource: \"analytics\",\n\t\tparams: ({ orgUnitIds, periodIds }: any) => ({\n\t\t\tdimension: [\n\t\t\t\t`ou:${orgUnitIds.join(\";\")}`,\n\t\t\t\t`pe:${periodIds.join(\";\")}`,\n\t\t\t],\n\t\t\tskipData: true,\n\t\t\thierarchyMeta: true,\n\t\t}),\n\t},\n};\n\nexport function MapProvider({\n\tchildren,\n\torgUnitSelection,\n\tperiodSelection,\n}: MapProviderProps) {\n\tconst [orgUnits, setOrgUnits] = useState<MapOrgUnit[]>([]);\n\tconst [periods, setPeriods] = useState<BasePeriod[]>([]);\n\tconst { refetch, loading, error } = useDataQuery(boundaryQuery, {\n\t\tlazy: true,\n\t});\n\n\tuseEffect(() => {\n\t\tasync function getOrgUnits() {\n\t\t\tconst rawOrgUnitIds = getOrgUnitsSelection(orgUnitSelection);\n\t\t\tconst data = await refetch({\n\t\t\t\torgUnitIds: rawOrgUnitIds,\n\t\t\t\tperiodIds: periodSelection?.periods,\n\t\t\t});\n\t\t\tconst { analytics, boundaries } = (data as any) ?? {};\n\t\t\tconst rawOrgUnits = sanitizeOrgUnits(analytics?.metaData);\n\t\t\tconst geoJSONObjects = toGeoJson(\n\t\t\t\tboundaries.filter((bound: any) => bound.co),\n\t\t\t);\n\t\t\tconst orgUnits: MapOrgUnit[] = compact(\n\t\t\t\trawOrgUnits.map((orgUnit: any) => {\n\t\t\t\t\tconst geoJSONObject: any = geoJSONObjects?.find(\n\t\t\t\t\t\t(geoJSON: any) => geoJSON.properties.id === orgUnit.id,\n\t\t\t\t\t);\n\n\t\t\t\t\tif (!geoJSONObject) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...orgUnit,\n\t\t\t\t\t\tgeoJSON: geoJSONObject,\n\t\t\t\t\t\tbounds: [],\n\t\t\t\t\t\tlevel: geoJSONObject.properties.level,\n\t\t\t\t\t};\n\t\t\t\t}),\n\t\t\t);\n\t\t\tconst periodIds =\n\t\t\t\tanalytics?.metaData?.dimensions?.pe ?? periodSelection?.periods;\n\t\t\tconst periods = periodIds.map((pe: string) =>\n\t\t\t\tPeriodUtility.getPeriodById(pe),\n\t\t\t);\n\t\t\tsetPeriods(periods);\n\t\t\tsetOrgUnits(orgUnits);\n\t\t}\n\n\t\tgetOrgUnits().catch((error) => console.log(error));\n\t}, [orgUnitSelection, refetch]);\n\n\tif (loading) {\n\t\treturn (\n\t\t\t<div style={{ height: \"100%\", width: \"100%\" }}>\n\t\t\t\t<Center>\n\t\t\t\t\t<CircularLoader small />\n\t\t\t\t</Center>\n\t\t\t</div>\n\t\t);\n\t}\n\n\tif (error) {\n\t\treturn (\n\t\t\t<div style={{ height: \"100%\", width: \"100%\" }}>\n\t\t\t\t<Center>\n\t\t\t\t\t<h4>\n\t\t\t\t\t\t{i18n.t(\"Error\")}: {error.message}\n\t\t\t\t\t</h4>\n\t\t\t\t</Center>\n\t\t\t</div>\n\t\t);\n\t}\n\n\tif (!isEmpty(orgUnits)) {\n\t\treturn (\n\t\t\t<MapOrgUnitContext.Provider value={{ orgUnitSelection, orgUnits }}>\n\t\t\t\t<MapPeriodContext.Provider\n\t\t\t\t\tvalue={{ ...periodSelection, periods }}\n\t\t\t\t>\n\t\t\t\t\t{children}\n\t\t\t\t</MapPeriodContext.Provider>\n\t\t\t</MapOrgUnitContext.Provider>\n\t\t);\n\t}\n\n\treturn null;\n}\n"]}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import type { Legend } from "@hisptz/dhis2-utils";
|
|
2
|
-
import { MapOrgUnit } from "../../../../../../interfaces
|
|
3
|
-
import { ThematicLayerDataItem } from "../../../../interfaces
|
|
4
|
-
import type
|
|
2
|
+
import { MapOrgUnit } from "../../../../../../interfaces";
|
|
3
|
+
import { type LayerLabelConfig, ThematicLayerDataItem } from "../../../../interfaces";
|
|
4
|
+
import { type LeafletEventHandlerFnMap, type LeafletMouseEvent } from "leaflet";
|
|
5
5
|
interface LayerData {
|
|
6
6
|
orgUnit: MapOrgUnit;
|
|
7
7
|
data?: number;
|
|
8
8
|
dataItem: ThematicLayerDataItem;
|
|
9
9
|
}
|
|
10
|
-
export default function Choropleth({ data, legends, customEventHandlers, onLayerClick, }: {
|
|
10
|
+
export default function Choropleth({ data, legends, customEventHandlers, onLayerClick, labelConfig, }: {
|
|
11
11
|
data: LayerData;
|
|
12
12
|
legends: Legend[];
|
|
13
13
|
customEventHandlers?: LeafletEventHandlerFnMap;
|
|
14
14
|
onLayerClick?: (e: LeafletMouseEvent, data: LayerData) => void;
|
|
15
|
-
|
|
15
|
+
labelConfig?: LayerLabelConfig;
|
|
16
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
16
17
|
export {};
|
|
17
18
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../../../src/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAGlD,OAAO,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../../../src/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAGlD,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAM1D,OAAO,EACN,KAAK,gBAAgB,EACrB,qBAAqB,EACrB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,KAAK,wBAAwB,EAAE,KAAK,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAYhF,UAAU,SAAS;IAClB,OAAO,EAAE,UAAU,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,qBAAqB,CAAC;CAChC;AAED,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EAClC,IAAI,EACJ,OAAO,EACP,mBAAmB,EACnB,YAAY,EACZ,WAAW,GACX,EAAE;IACF,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,mBAAmB,CAAC,EAAE,wBAAwB,CAAC;IAC/C,YAAY,CAAC,EAAE,CAAC,CAAC,EAAE,iBAAiB,EAAE,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;IAC/D,WAAW,CAAC,EAAE,gBAAgB,CAAC;CAC/B,2CAsDA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { LayerLabelConfig } from "../../../../interfaces";
|
|
2
|
+
import { type LatLngExpression } from "leaflet";
|
|
3
|
+
import "./label.css";
|
|
4
|
+
export declare function LabelMarker({ labelConfig, data, orgUnit, center, layerColor, }: {
|
|
5
|
+
labelConfig: LayerLabelConfig;
|
|
6
|
+
data: number | undefined;
|
|
7
|
+
orgUnit: {
|
|
8
|
+
name: string;
|
|
9
|
+
};
|
|
10
|
+
center: LatLngExpression;
|
|
11
|
+
layerColor: string;
|
|
12
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../../../src/components/Map/components/MapLayer/components/ThematicLayer/components/LabelMarker/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAU,EAAE,KAAK,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,aAAa,CAAC;AAGrB,wBAAgB,WAAW,CAAC,EAC3B,WAAW,EACX,IAAI,EACJ,OAAO,EACP,MAAM,EACN,UAAU,GACV,EAAE;IACF,WAAW,EAAE,gBAAgB,CAAC;IAC9B,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1B,MAAM,EAAE,gBAAgB,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;CACnB,2CAaA"}
|
package/dist/types/components/Map/components/MapLayer/components/ThematicLayer/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../src/components/Map/components/MapLayer/components/ThematicLayer/index.tsx"],"names":[],"mappings":"AAQA,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EACrC,OAAO,EACP,KAAK,GACL,EAAE;IACF,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACd,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../src/components/Map/components/MapLayer/components/ThematicLayer/index.tsx"],"names":[],"mappings":"AAQA,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EACrC,OAAO,EACP,KAAK,GACL,EAAE;IACF,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACd,kDA0DA"}
|
package/dist/types/components/Map/components/MapLayer/components/ThematicLayer/utils/label.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { LayerLabelConfig } from "../../../interfaces";
|
|
2
|
+
export declare function getLabel({ orgUnit, data, labelConfig, }: {
|
|
3
|
+
labelConfig: LayerLabelConfig;
|
|
4
|
+
orgUnit: {
|
|
5
|
+
name: string;
|
|
6
|
+
};
|
|
7
|
+
data?: number;
|
|
8
|
+
}): string;
|
|
9
|
+
//# sourceMappingURL=label.d.ts.map
|
package/dist/types/components/Map/components/MapLayer/components/ThematicLayer/utils/label.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"label.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/components/Map/components/MapLayer/components/ThematicLayer/utils/label.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAI5D,wBAAgB,QAAQ,CAAC,EACxB,OAAO,EACP,IAAI,EACJ,WAAW,GACX,EAAE;IACF,WAAW,EAAE,gBAAgB,CAAC;IAC9B,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;CACd,UAOA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Legend } from "@hisptz/dhis2-utils";
|
|
2
|
-
import { MapOrgUnit, PointOrgUnit } from "../../../interfaces
|
|
3
|
-
import { LegendColorScale } from "../../../utils
|
|
4
|
-
import { EarthEngineOptions } from "../components/GoogleEngineLayer/interfaces
|
|
2
|
+
import { MapOrgUnit, PointOrgUnit } from "../../../interfaces";
|
|
3
|
+
import { LegendColorScale } from "../../../utils";
|
|
4
|
+
import { EarthEngineOptions } from "../components/GoogleEngineLayer/interfaces";
|
|
5
5
|
import { EarthEngine } from "../components/GoogleEngineLayer/services/engine.js";
|
|
6
6
|
import type { LeafletEventHandlerFnMap, LeafletMouseEvent } from "leaflet";
|
|
7
7
|
export type BoundaryLayerType = "basemap" | "overlay";
|
|
@@ -104,6 +104,11 @@ interface LayerData {
|
|
|
104
104
|
data?: number;
|
|
105
105
|
dataItem?: ThematicLayerDataItem;
|
|
106
106
|
}
|
|
107
|
+
export type LayerLabelConfig = {
|
|
108
|
+
labels: boolean;
|
|
109
|
+
labelFontWeight: string;
|
|
110
|
+
labelTemplate: string;
|
|
111
|
+
};
|
|
107
112
|
export interface ThematicLayerConfig {
|
|
108
113
|
id: string;
|
|
109
114
|
data?: ThematicLayerRawData[];
|
|
@@ -114,6 +119,7 @@ export interface ThematicLayerConfig {
|
|
|
114
119
|
control?: ThematicLayerControl;
|
|
115
120
|
customEventHandlers?: LeafletEventHandlerFnMap;
|
|
116
121
|
onLayerClick?: (e: LeafletMouseEvent, data: LayerData) => void;
|
|
122
|
+
labelConfig?: LayerLabelConfig;
|
|
117
123
|
radius?: {
|
|
118
124
|
min: number;
|
|
119
125
|
max: number;
|
|
@@ -125,6 +131,7 @@ export interface CustomMapLayer {
|
|
|
125
131
|
enabled: boolean;
|
|
126
132
|
customEventHandlers?: LeafletEventHandlerFnMap;
|
|
127
133
|
onLayerClick?: (e: LeafletMouseEvent, data: LayerData) => void;
|
|
134
|
+
labelConfig?: LayerLabelConfig;
|
|
128
135
|
}
|
|
129
136
|
export type MapLayer = CustomBoundaryLayer | ThematicLayerConfig | CustomPointLayer | CustomGoogleEngineLayer;
|
|
130
137
|
export interface MapLayerProps {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/components/Map/components/MapLayer/interfaces/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/components/Map/components/MapLayer/interfaces/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,oDAAoD,CAAC;AACjF,OAAO,KAAK,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE3E,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,SAAS,CAAC;AACtD,MAAM,MAAM,iBAAiB,GAAG,YAAY,GAAG,QAAQ,CAAC;AAExD,eAAO,MAAM,6BAA6B,UAKzC,C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,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,mBAAmB,CAAC,EAAE,wBAAwB,CAAC;IAC/C,YAAY,CAAC,EAAE,CAAC,CAAC,EAAE,iBAAiB,EAAE,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;IAC/D,WAAW,CAAC,EAAE,gBAAgB,CAAC;CAC/B;AAED,MAAM,MAAM,QAAQ,GACjB,mBAAmB,GACnB,mBAAmB,GACnB,gBAAgB,GAChB,uBAAuB,CAAC;AAE3B,MAAM,WAAW,aAAa;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,UAAU,GAAG,UAAU,GAAG,UAAU,GAAG,OAAO,GAAG,aAAa,CAAC;IACrE,KAAK,EAAE,QAAQ,CAAC;CAChB"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { MapProviderProps } from "../../interfaces
|
|
2
|
-
export declare function MapProvider({ children, orgUnitSelection, periodSelection, }: MapProviderProps): import("react/jsx-runtime
|
|
1
|
+
import { MapProviderProps } from "../../interfaces";
|
|
2
|
+
export declare function MapProvider({ children, orgUnitSelection, periodSelection, }: MapProviderProps): import("react/jsx-runtime").JSX.Element | null;
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Map/components/MapProvider/index.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAc,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Map/components/MapProvider/index.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAc,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAyBhE,wBAAgB,WAAW,CAAC,EAC3B,QAAQ,EACR,gBAAgB,EAChB,eAAe,GACf,EAAE,gBAAgB,kDAmFlB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hisptz/dhis2-analytics",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.18",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/esm/index.js",
|
|
6
6
|
"types": "./dist/types/index.d.ts",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"tsup": "^8.4.0",
|
|
42
42
|
"typescript": "^5.3.3",
|
|
43
43
|
"usehooks-ts": "^2.16.0",
|
|
44
|
-
"@repo/
|
|
45
|
-
"@repo/
|
|
44
|
+
"@repo/eslint-config": "0.0.0",
|
|
45
|
+
"@repo/typescript-config": "0.0.2"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@google/earthengine": "^1.5.21",
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
"d3-color": "^3.1.0",
|
|
54
54
|
"d3-scale": "^4.0.2",
|
|
55
55
|
"file-saver": "^2.0.5",
|
|
56
|
+
"geolib": "^3.3.4",
|
|
56
57
|
"highcharts": "^12.2.0",
|
|
57
58
|
"highcharts-react-official": "^3.2.1",
|
|
58
59
|
"jotai-devtools": "^0.10.1",
|
|
@@ -72,8 +73,8 @@
|
|
|
72
73
|
"react-to-print": "^3.0.1",
|
|
73
74
|
"screenfull": "^6.0.2",
|
|
74
75
|
"xlsx": "^0.18.5",
|
|
75
|
-
"@hisptz/dhis2-
|
|
76
|
-
"@hisptz/dhis2-
|
|
76
|
+
"@hisptz/dhis2-utils": "2.0.18",
|
|
77
|
+
"@hisptz/dhis2-ui": "2.0.48"
|
|
77
78
|
},
|
|
78
79
|
"peerDependencies": {
|
|
79
80
|
"@dhis2/app-runtime": "^3",
|