Drilldown option requires several configurations. First we need to define a hierarchy in the system that reflects the maps topological hierarchy. Then we need to add several configs to the aggregation config and lastly we need to add the layers object to the chart config.
Hierarchy
To learn how to define a data hierarchy go to Creating a data hierarchy
In this example we need the following hierarchy:
Generel overview and country level:
province level:
district level:
Chart config
layers: [ { mapKey: 'afghanistan-provinces', layer: 1, filterField: 'ADM0_NAME' }, { mapKey: 'afghanistan-districts', filterField: 'NAME_1', layer: 2, parentMapFilterField: 'ADM0_NAME' } ],
Here, we add an Array of layers to the config. Each layer has a “mapKey” which is the code of the topoMap uploaded and a layer number called “layer“ that defines the position in the layer hierarchy. The lower layer (the one drilled down to) has an additional property “parentLayerIdentifier“.
The property “parentLayerIdentifier“ is for filtering the correct features from the map. Its the property of the current layer that identifies that a feature is part of the area that has been clicked.
Example:
If we have a map of all provinces of Afghanistan and we click on the province Hirat to load a map of all districts of Hirat. Now this identifier tells us to only fetch the districts that have the value “Hirat“ in the field given to “parentLayerIdentifier“. If you are unsure what field to put into “parentLayerIdentifier“ then look what is defined as “filterField“ under “filter” in your chart config. The values in those two fields should match. So if you have selected a field for the filter that matches a name then you should configure an equivalent field as “parentLayerIdentifier“. Often the fields are named exactly the same in both maps but if you have the maps from different sources their names might differ.
Aggregation config
Example aggregation config for data collection named “consultants“. We want all consultants in a Province or district on a topo map:
{ modificationTime: '2022-03-29T06:14:39.352+00:00', parameters: [ { code: 'hierarchy', type: 'REPLACE', required: false, multiValue: false, name: { en: 'Hierarchy' }, dataType: 'STRING', expressionValue: false }, { code: 'hierarchySelector', type: 'REPLACE', required: false, multiValue: false, name: { en: 'Hierarchy Selector' }, dataType: 'STRING', expressionValue: false } ], parameterValues: { hierarchy: 'province' }, filterCriteria: [], permissionProfiles: [], lookUpPaths: [], aggregations: [ { '$group': { _id: '###hierarchy###', count: { '$sum': 1 }, consultant: { '$first': '$$ROOT' } } }, { '$project': { _id: 0, value: '$consultant.###hierarchyProjectionPath.iso###', result: '$count', total: '$count' } } ] }
Explanations
Parameters:
“code: hierarchy”:
“code: hierarchySelector“:
ParameterValues:
hierarchy: The code of the entry layer for the chart and config. E.g. if you have the layers with codes “country”, “province” and “district” and you want a map that first shows the results by provinces when first loading the dashboard, then you would type “province“ as your entry layer. The codes are the same as defined in your chart config above for the object “layers“.
aggregations:
###hierarchy###:
$$ROOT:
###hierarchyProjectionPath.iso###:
Additionally we need to select our data hierarchy defined previously in the field “Use Data Hierarchy“ on the left panel and define the entry path into the hierarchy from our collection in the field “Data Hierarchy entry path“ also on the left panel.
Add Comment