Skip to content

Commit

Permalink
Perform the check for has_custom_metric through not None to produce…
Browse files Browse the repository at this point in the history
… a boolean and rename the field reflect it is a boolean.
  • Loading branch information
xtinec committed Sep 18, 2018
1 parent 6284b57 commit 55a1955
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions superset/assets/src/visualizations/MapBox/MapBox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class MapBox extends React.Component {
pointRadiusUnit,
renderWhileDragging,
rgb,
customMetric,
hasCustomMetric,
bounds,
} = this.props;
const { viewport } = this.state;
Expand Down Expand Up @@ -110,7 +110,7 @@ class MapBox extends React.Component {
globalOpacity={globalOpacity}
compositeOperation={'screen'}
renderWhileDragging={renderWhileDragging}
aggregation={customMetric ? aggregatorName : undefined}
aggregation={hasCustomMetric ? aggregatorName : null}
lngLatAccessor={(location) => {
const coordinates = location.get('geometry').get('coordinates');
return [coordinates.get(0), coordinates.get(1)];
Expand All @@ -127,7 +127,7 @@ MapBox.defaultProps = defaultProps;
function mapbox(slice, payload, setControlValue) {
const { formData, selector } = slice;
const {
customMetric,
hasCustomMetric,
geoJSON,
bounds,
mapboxApiKey,
Expand Down Expand Up @@ -155,7 +155,7 @@ function mapbox(slice, payload, setControlValue) {
radius: clusteringRadius,
maxZoom: DEFAULT_MAX_ZOOM,
};
if (customMetric) {
if (hasCustomMetric) {
opts.initial = () => ({
sum: 0,
squaredSum: 0,
Expand Down Expand Up @@ -185,7 +185,7 @@ function mapbox(slice, payload, setControlValue) {
<MapBox
width={slice.width()}
height={slice.height()}
customMetric={customMetric}
hasCustomMetric={hasCustomMetric}
aggregatorName={aggregatorName}
clusterer={clusterer}
globalOpacity={globalOpacity}
Expand Down
6 changes: 3 additions & 3 deletions superset/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -1960,9 +1960,9 @@ def get_data(self, df):
return None
fd = self.form_data
label_col = fd.get('mapbox_label')
custom_metric = bool(label_col) and len(label_col) >= 1
has_custom_metric = label_col is not None and len(label_col) > 0
metric_col = [None] * len(df.index)
if custom_metric:
if has_custom_metric:
if label_col[0] == fd.get('all_columns_x'):
metric_col = df[fd.get('all_columns_x')]
elif label_col[0] == fd.get('all_columns_y'):
Expand Down Expand Up @@ -2003,7 +2003,7 @@ def get_data(self, df):

return {
'geoJSON': geo_json,
'customMetric': custom_metric,
'hasCustomMetric': has_custom_metric,
'mapboxApiKey': config.get('MAPBOX_API_KEY'),
'mapStyle': fd.get('mapbox_style'),
'aggregatorName': fd.get('pandas_aggfunc'),
Expand Down

0 comments on commit 55a1955

Please sign in to comment.