From adaf91ec9d58073d42cd1e8c962b186f49ecec69 Mon Sep 17 00:00:00 2001 From: Beto Dealmeida Date: Thu, 25 Oct 2018 14:18:14 -0700 Subject: [PATCH] ZIP codes based on Polygon (cherry picked from commit 0dbaaf9d293d2f08e542491ba484a91596a6c4b6) (cherry picked from commit 046736cbd429c01d673b6fc75fb9eb2e21b1077b) (cherry picked from commit 49a33981c23dbefbe7420cd8828b78140b46e961) (cherry picked from commit 9c10547f19b628e81cbcd6e1fbac86a70ea510be) --- .../components/controls/SpatialControl.jsx | 25 +++++++ superset/assets/src/explore/controls.jsx | 1 + .../deckgl/layers/Polygon/Polygon.jsx | 1 - superset/viz.py | 72 ++++++++++++++++++- 4 files changed, 97 insertions(+), 2 deletions(-) diff --git a/superset/assets/src/explore/components/controls/SpatialControl.jsx b/superset/assets/src/explore/components/controls/SpatialControl.jsx index 592f12a780ca1..9d38fca36a151 100644 --- a/superset/assets/src/explore/components/controls/SpatialControl.jsx +++ b/superset/assets/src/explore/components/controls/SpatialControl.jsx @@ -32,6 +32,7 @@ const spatialTypes = { latlong: 'latlong', delimited: 'delimited', geohash: 'geohash', + zipcode: 'zipcode', }; const propTypes = { @@ -63,6 +64,7 @@ export default class SpatialControl extends React.Component { lonlatCol: v.lonlatCol || defaultCol, reverseCheckbox: v.reverseCheckbox || false, geohashCol: v.geohashCol || defaultCol, + zipcodeCol: v.zipcodeCol || defaultCol, value: null, errors: [], }; @@ -97,6 +99,12 @@ export default class SpatialControl extends React.Component { if (!value.geohashCol) { errors.push(errMsg); } + } else if (type === spatialTypes.zipcode) { + value.zipcodeCol = this.state.zipcodeCol; + value.reverseCheckbox = this.state.reverseCheckbox; + if (!value.zipcodeCol) { + errors.push(errMsg); + } } this.setState({ value, errors }); this.props.onChange(value, errors); @@ -120,6 +128,8 @@ export default class SpatialControl extends React.Component { return `${this.state.lonlatCol}`; } else if (this.state.type === spatialTypes.geohash) { return `${this.state.geohashCol}`; + } else if (this.state.type === spatialTypes.zipcode) { + return `${this.state.zipcodeCol}`; } return null; } @@ -199,6 +209,21 @@ export default class SpatialControl extends React.Component { + + + + Column + {this.renderSelect('zipcodeCol', spatialTypes.zipcode)} + + + {this.renderReverseCheckbox()} + + +