Skip to content
Snippets Groups Projects
Unverified Commit 0871aee7 authored by Tom Robinson's avatar Tom Robinson
Browse files

Give clickable region maps cursor-pointer

parent 8a6647bd
Branches
Tags
No related merge requests found
......@@ -118,7 +118,7 @@ export default class ChoroplethMap extends Component {
);
}
const { series, className, gridSize, hovered, onHoverChange, onVisualizationClick, settings } = this.props;
const { series, className, gridSize, hovered, onHoverChange, visualizationIsClickable, onVisualizationClick, settings } = this.props;
let { geoJson, minimalBounds } = this.state;
// special case builtin maps to use legacy choropleth map
......@@ -161,21 +161,28 @@ export default class ChoroplethMap extends Component {
data: { key: getFeatureName(hover.feature), value: getFeatureValue(hover.feature)
} })
}
const onClickFeature = (click) => {
const getFeatureClickObject = (row) => ({
value: row[metricIndex],
column: cols[metricIndex],
dimensions: [{
value: row[dimensionIndex],
column: cols[dimensionIndex]
}]
})
const isClickable = onVisualizationClick && visualizationIsClickable(getFeatureClickObject(rows[0]))
const onClickFeature = isClickable && ((click) => {
const featureKey = getFeatureKey(click.feature);
const row = _.find(rows, row => getRowKey(row) === featureKey);
if (onVisualizationClick && row !== undefined) {
onVisualizationClick({
value: row[metricIndex],
column: cols[metricIndex],
dimensions: [{
value: row[dimensionIndex],
column: cols[dimensionIndex]
}],
...getFeatureClickObject(row),
event: click.event
});
}
}
})
const valuesMap = {};
const domain = []
......
......@@ -2,6 +2,7 @@ import React, { Component } from "react";
import { isSameSeries } from "metabase/visualizations/lib/utils";
import d3 from "d3";
import cx from "classnames";
const LegacyChoropleth = ({ series, geoJson, projection, getColor, onHoverFeature, onClickFeature }) => {
let geo = d3.geo.path()
......@@ -27,6 +28,7 @@ const LegacyChoropleth = ({ series, geoJson, projection, getColor, onHoverFeatur
event: e.nativeEvent
})}
onMouseLeave={() => onHoverFeature(null)}
className={cx({ "cursor-pointer": !!onClickFeature })}
onClick={(e) => onClickFeature({
feature: feature,
event: e.nativeEvent
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment