-
Notifications
You must be signed in to change notification settings - Fork 14k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DECKGL integration - Phase 1 #3771
Conversation
@@ -133,9 +133,15 @@ def load_examples(load_test_data): | |||
print("Loading [Misc Charts] dashboard") | |||
data.load_misc_dashboard() | |||
|
|||
print("Loading DECK.gl demo") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merge resolution mismatch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still WiP, I'll ping when ready for review...
package.json
Outdated
@@ -0,0 +1,5 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this file in the right place?
superset/viz.py
Outdated
@@ -1731,6 +1689,112 @@ def get_data(self, df): | |||
} | |||
|
|||
|
|||
class BaseDeckGLViz(BaseViz): | |||
|
|||
"""Rich maps made with Mapbox""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c&p description :)
Coverage increased (+0.4%) to 71.648% when pulling afa8443d6992ea822f7b82e0e0ea1c04e34e471c on mistercrunch:deck.gl into 7fd9c82 on apache:master. |
Coverage increased (+0.4%) to 71.648% when pulling afa8443d6992ea822f7b82e0e0ea1c04e34e471c on mistercrunch:deck.gl into 7fd9c82 on apache:master. |
1 similar comment
Coverage increased (+0.4%) to 71.648% when pulling afa8443d6992ea822f7b82e0e0ea1c04e34e471c on mistercrunch:deck.gl into 7fd9c82 on apache:master. |
Coverage increased (+0.4%) to 71.648% when pulling 6ead867a92d011feef3b6e04629b0a4ca1d03aeb on mistercrunch:deck.gl into 7fd9c82 on apache:master. |
Coverage increased (+0.3%) to 71.566% when pulling 0c49a648d6b4086244d91c4ac200c5d7258fec4b on mistercrunch:deck.gl into 7fd9c82 on apache:master. |
5c3565f
to
6ba6f9a
Compare
Coverage increased (+0.05%) to 71.317% when pulling 6ba6f9a2f2b9a7caa63f201ace49033ef8c5d130 on mistercrunch:deck.gl into 13c17e1 on apache:master. |
Coverage decreased (-0.09%) to 71.178% when pulling 6ba6f9a2f2b9a7caa63f201ace49033ef8c5d130 on mistercrunch:deck.gl into 13c17e1 on apache:master. |
a595c8c
to
7618557
Compare
Coverage increased (+0.05%) to 71.317% when pulling 7618557b432bf7a169dc1952bcccfdcb24821868 on mistercrunch:deck.gl into 13c17e1 on apache:master. |
1 similar comment
Coverage increased (+0.05%) to 71.317% when pulling 7618557b432bf7a169dc1952bcccfdcb24821868 on mistercrunch:deck.gl into 13c17e1 on apache:master. |
Coverage increased (+0.05%) to 71.317% when pulling 7618557b432bf7a169dc1952bcccfdcb24821868 on mistercrunch:deck.gl into 13c17e1 on apache:master. |
1 similar comment
Coverage increased (+0.05%) to 71.317% when pulling 7618557b432bf7a169dc1952bcccfdcb24821868 on mistercrunch:deck.gl into 13c17e1 on apache:master. |
Coverage increased (+0.05%) to 71.317% when pulling c8c6628fce6fd0c0b478af1e8538fcd9e21bb60f on mistercrunch:deck.gl into 13c17e1 on apache:master. |
Coverage increased (+0.05%) to 71.317% when pulling 597132fe33216469d8d95529b9108dabb84cd024 on mistercrunch:deck.gl into 13c17e1 on apache:master. |
Coverage increased (+0.05%) to 71.512% when pulling b9b79683fa71955c297e9fadc5883c2fdb5a2151 on mistercrunch:deck.gl into ccb87d3 on apache:master. |
Adding a new set of geospatial visualizations building on top of the awesome deck.gl library. https://github.com/uber/deck.gl While the end goal it to expose all types of layers and let users bind their data to control most props exposed by the deck.gl API, this PR focusses on a first set of visualizations and props: * ScatterLayer * HexagonLayer * GridLayer * ScreenGridLayer
Coverage increased (+0.05%) to 71.512% when pulling 310496ee0f3e59eda29621829db2451dfb0d4e99 on mistercrunch:deck.gl into ccb87d3 on apache:master. |
constructor(props) { | ||
super(props); | ||
this.onChange = this.onChange.bind(this); | ||
const type = props.value ? props.value.type : props.default.type || 'fix'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'fix' should probably be a global constant that you reference everywhere. e.g. declare VALUE_TYPE_FIX = 'fix'
and use that everywhere. In case you ever want to refactor, this will make it a lot easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think adding parenthesis will make this line easier to read:
const type = props.value ? props.value.type : (props.default.type || 'fix');
vs
const type = (props.value ? props.value.type : props.default.type) || 'fix';
I always get confused about the order of operations in these cases, but maybe thats just me.
another option is to pull out if (props.value)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes like an enum, I'm going with
const controlTypes = {
fixed: 'fix',
metric: 'metric',
};
this.state = { | ||
type, | ||
fixedValue: type === 'fix' ? value : '', | ||
metricValue: type === 'metric' ? value : null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VALUE_TYPE_METRIC
instead of metric
? Also it looks weird that one of them defaults to ''
while the other one defaults to null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one is a string (TextControl) and the other is an unselected SelectControl...
<PopoverSection | ||
title="Fixed" | ||
isSelected={type === 'fix'} | ||
onSelect={this.onChange.bind(this, 'fix')} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a reason you bind this.onChange
here? Afaik calling bind
once in the constructor is recommended and more performant (https://reactjs.org/docs/handling-events.html)
We generally recommend binding in the constructor or using the class fields syntax, to avoid this sort of performance problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well here I'm binding with 'fix' as well, I guess I could bind to this on the constructor and re-bind that to 'fix' here.
onChange: () => {}, | ||
default: { type: 'fix', value: 5 }, | ||
value: { | ||
longitude: 6.85236157047845, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you put in a comment what these coordinate are?
@@ -424,6 +432,12 @@ export const controls = { | |||
}, | |||
|
|||
groupby: groupByControl, | |||
dimension: Object.assign({}, groupByControl, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Further up you are doing
{
...this.props.value,
[ctrl]: value,
}
here you are using Object.assign()
instead of
{
... groupByControl,
label: t('Dimension'),
description: t('Select a dimension'),
multi: false,
default: null,
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah let's move towards spread operator instead of Object.assign
, we should eventually add a linting rule for this
renderTrigger: true, | ||
description: t('Parameters related to the view and perspective on the map'), | ||
default: { | ||
longitude: 6.85236157047845, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These looks like the same numbers that are hardcoded as defaults, do we need them in both locations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moving as defaultViewport
in utils/geo.js
Thanks for the review @fabianmenges ! I addressed all the comments and improved a few other things along the way. |
Coverage increased (+0.05%) to 71.492% when pulling 53c3159f770943d8a0d5cc94cbc566d87d571d86 on mistercrunch:deck.gl into 7453131 on apache:master. |
Coverage increased (+0.04%) to 71.484% when pulling 53c3159f770943d8a0d5cc94cbc566d87d571d86 on mistercrunch:deck.gl into 7453131 on apache:master. |
1 similar comment
Coverage increased (+0.04%) to 71.484% when pulling 53c3159f770943d8a0d5cc94cbc566d87d571d86 on mistercrunch:deck.gl into 7453131 on apache:master. |
1 similar comment
Coverage increased (+0.05%) to 71.494% when pulling 1dc080789b0ab8d772b45fbad1edc2ed4e86cbcd on mistercrunch:deck.gl into 39e502f on apache:master. |
3 similar comments
Coverage increased (+0.05%) to 71.494% when pulling 1dc080789b0ab8d772b45fbad1edc2ed4e86cbcd on mistercrunch:deck.gl into 39e502f on apache:master. |
Coverage increased (+0.05%) to 71.494% when pulling 1dc080789b0ab8d772b45fbad1edc2ed4e86cbcd on mistercrunch:deck.gl into 39e502f on apache:master. |
Coverage increased (+0.05%) to 71.494% when pulling 1dc080789b0ab8d772b45fbad1edc2ed4e86cbcd on mistercrunch:deck.gl into 39e502f on apache:master. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super excited for this! Had a few minor comments 🚀
value: PropTypes.object, | ||
isFloat: PropTypes.bool, | ||
datasource: PropTypes.object, | ||
default: PropTypes.object, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be a shape?
}); | ||
} | ||
setType(type) { | ||
this.setState({ type }, this.onChange); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setState
should be a function now https://reactjs.org/docs/react-component.html#setstate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh interesting I had not seen that change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After reviewing the updated React docs it doesn't sound like the updater
as first arg is a preferred way of calling setState
or that passing an object will get deprecated in the future of anything. Any other rational to change thing over? I'd rather not go and change hundreds of setState calls in the code base to add unneeded brackets...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried briefly to find a related eslint linting rule that would explain why an updater
function is preferred and oculdn't find any...
this.setState({ type }, this.onChange); | ||
} | ||
setFixedValue(fixedValue) { | ||
this.setState({ fixedValue }, this.onChange); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto functional setState
this.setState({ fixedValue }, this.onChange); | ||
} | ||
setMetric(metricValue) { | ||
this.setState({ metricValue }, this.onChange); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto functional setState
> | ||
<TextControl | ||
isFloat | ||
onChange={this.setFixedValue.bind(this)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you shouldn't bind in a render function
})); | ||
|
||
const layer = new GridLayer({ | ||
id: 'screengrid-layer', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this include the something to be unique?
data, | ||
pickable: true, | ||
fp64: true, | ||
// onHover: info => console.log('Hovered:', info), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove?
}); | ||
|
||
const layer = new ScatterplotLayer({ | ||
id: 'scatterplot-layer', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this include the something to be unique?
})); | ||
|
||
const layer = new HexagonLayer({ | ||
id: 'screengrid-layer', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this include the something to be unique?
// Passing a layer creator function instead of a layer since the | ||
// layer needs to be regenerated at each render | ||
const layer = () => new ScreenGridLayer({ | ||
id: 'screengrid-layer', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this include the something to be unique?
@williaster I addressed your comments except for |
LGTM |
* DECKGL integration Adding a new set of geospatial visualizations building on top of the awesome deck.gl library. https://github.com/uber/deck.gl While the end goal it to expose all types of layers and let users bind their data to control most props exposed by the deck.gl API, this PR focusses on a first set of visualizations and props: * ScatterLayer * HexagonLayer * GridLayer * ScreenGridLayer * Addressing comments * lint * Linting * Addressing chri's comments
* DECKGL integration Adding a new set of geospatial visualizations building on top of the awesome deck.gl library. https://github.com/uber/deck.gl While the end goal it to expose all types of layers and let users bind their data to control most props exposed by the deck.gl API, this PR focusses on a first set of visualizations and props: * ScatterLayer * HexagonLayer * GridLayer * ScreenGridLayer * Addressing comments * lint * Linting * Addressing chri's comments
Adding a new set of geospatial visualizations building on top of the
awesome deck.gl library. https://github.com/uber/deck.gl
While the end goal it to expose all types of layers and let users bind
their data to control most props exposed by the deck.gl API, this
PR focusses on a first set of visualizations and props:
This is a large PR, so here's an overview of what is in here:
DeckGLContainer
that we'll use to render all deck related visualizationssuperset load_examples
FixedOrMetricControl
allowing to provide a fixed value or binding to a metric