Skip to content
Snippets Groups Projects
Commit 8fd14f1e authored by Tiago Varela's avatar Tiago Varela Committed by Tom Robinson
Browse files

Use feature name on hover (#10065)

parent 66e93821
No related merge requests found
...@@ -162,7 +162,7 @@ export default class ChoroplethMap extends Component { ...@@ -162,7 +162,7 @@ export default class ChoroplethMap extends Component {
projection = null; projection = null;
} }
// const nameProperty = details.region_name; const nameProperty = details.region_name;
const keyProperty = details.region_key; const keyProperty = details.region_key;
if (!geoJson) { if (!geoJson) {
...@@ -191,7 +191,7 @@ export default class ChoroplethMap extends Component { ...@@ -191,7 +191,7 @@ export default class ChoroplethMap extends Component {
getCanonicalRowKey(row[dimensionIndex], settings["map.region"]); getCanonicalRowKey(row[dimensionIndex], settings["map.region"]);
const getRowValue = row => row[metricIndex] || 0; const getRowValue = row => row[metricIndex] || 0;
// const getFeatureName = feature => String(feature.properties[nameProperty]); const getFeatureName = feature => String(feature.properties[nameProperty]);
const getFeatureKey = feature => const getFeatureKey = feature =>
String(feature.properties[keyProperty]).toLowerCase(); String(feature.properties[keyProperty]).toLowerCase();
...@@ -202,12 +202,13 @@ export default class ChoroplethMap extends Component { ...@@ -202,12 +202,13 @@ export default class ChoroplethMap extends Component {
const rowByFeatureKey = new Map(rows.map(row => [getRowKey(row), row])); const rowByFeatureKey = new Map(rows.map(row => [getRowKey(row), row]));
const getFeatureClickObject = row => ({ const getFeatureClickObject = (row, feature) => ({
value: row[metricIndex], value: row[metricIndex],
column: cols[metricIndex], column: cols[metricIndex],
dimensions: [ dimensions: [
{ {
value: row[dimensionIndex], value:
feature != null ? getFeatureName(feature) : row[dimensionIndex],
column: cols[dimensionIndex], column: cols[dimensionIndex],
}, },
], ],
...@@ -234,7 +235,7 @@ export default class ChoroplethMap extends Component { ...@@ -234,7 +235,7 @@ export default class ChoroplethMap extends Component {
const row = hover && rowByFeatureKey.get(getFeatureKey(hover.feature)); const row = hover && rowByFeatureKey.get(getFeatureKey(hover.feature));
if (row && onHoverChange) { if (row && onHoverChange) {
onHoverChange({ onHoverChange({
...getFeatureClickObject(row), ...getFeatureClickObject(row, hover.feature),
event: hover.event, event: hover.event,
}); });
} else if (onHoverChange) { } else if (onHoverChange) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment