Skip to content
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

Merged
merged 5 commits into from
Nov 16, 2017
Merged

Conversation

mistercrunch
Copy link
Member

@mistercrunch mistercrunch commented Nov 3, 2017

deck
screen shot 2017-11-03 at 9 28 58 am
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

This is a large PR, so here's an overview of what is in here:

  • a common DeckGLContainer that we'll use to render all deck related visualizations
  • 4 new vizes
  • an example dash loaded as part of superset load_examples
  • a new FixedOrMetricControl allowing to provide a fixed value or binding to a metric
  • ...

@@ -133,9 +133,15 @@ def load_examples(load_test_data):
print("Loading [Misc Charts] dashboard")
data.load_misc_dashboard()

print("Loading DECK.gl demo")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merge resolution mismatch?

Copy link
Member Author

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 @@
{
Copy link
Contributor

@xrmx xrmx Nov 3, 2017

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"""
Copy link
Contributor

@xrmx xrmx Nov 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c&p description :)

@coveralls
Copy link

coveralls commented Nov 3, 2017

Coverage Status

Coverage increased (+0.4%) to 71.648% when pulling afa8443d6992ea822f7b82e0e0ea1c04e34e471c on mistercrunch:deck.gl into 7fd9c82 on apache:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 71.648% when pulling afa8443d6992ea822f7b82e0e0ea1c04e34e471c on mistercrunch:deck.gl into 7fd9c82 on apache:master.

1 similar comment
@coveralls
Copy link

coveralls commented Nov 3, 2017

Coverage Status

Coverage increased (+0.4%) to 71.648% when pulling afa8443d6992ea822f7b82e0e0ea1c04e34e471c on mistercrunch:deck.gl into 7fd9c82 on apache:master.

@coveralls
Copy link

coveralls commented Nov 3, 2017

Coverage Status

Coverage increased (+0.4%) to 71.648% when pulling 6ead867a92d011feef3b6e04629b0a4ca1d03aeb on mistercrunch:deck.gl into 7fd9c82 on apache:master.

@coveralls
Copy link

coveralls commented Nov 5, 2017

Coverage Status

Coverage increased (+0.3%) to 71.566% when pulling 0c49a648d6b4086244d91c4ac200c5d7258fec4b on mistercrunch:deck.gl into 7fd9c82 on apache:master.

@coveralls
Copy link

coveralls commented Nov 5, 2017

Coverage Status

Coverage increased (+0.05%) to 71.317% when pulling 6ba6f9a2f2b9a7caa63f201ace49033ef8c5d130 on mistercrunch:deck.gl into 13c17e1 on apache:master.

@coveralls
Copy link

coveralls commented Nov 5, 2017

Coverage Status

Coverage decreased (-0.09%) to 71.178% when pulling 6ba6f9a2f2b9a7caa63f201ace49033ef8c5d130 on mistercrunch:deck.gl into 13c17e1 on apache:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 71.317% when pulling 7618557b432bf7a169dc1952bcccfdcb24821868 on mistercrunch:deck.gl into 13c17e1 on apache:master.

1 similar comment
@coveralls
Copy link

coveralls commented Nov 5, 2017

Coverage Status

Coverage increased (+0.05%) to 71.317% when pulling 7618557b432bf7a169dc1952bcccfdcb24821868 on mistercrunch:deck.gl into 13c17e1 on apache:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 71.317% when pulling 7618557b432bf7a169dc1952bcccfdcb24821868 on mistercrunch:deck.gl into 13c17e1 on apache:master.

1 similar comment
@coveralls
Copy link

coveralls commented Nov 5, 2017

Coverage Status

Coverage increased (+0.05%) to 71.317% when pulling 7618557b432bf7a169dc1952bcccfdcb24821868 on mistercrunch:deck.gl into 13c17e1 on apache:master.

@coveralls
Copy link

coveralls commented Nov 6, 2017

Coverage Status

Coverage increased (+0.05%) to 71.317% when pulling c8c6628fce6fd0c0b478af1e8538fcd9e21bb60f on mistercrunch:deck.gl into 13c17e1 on apache:master.

@coveralls
Copy link

coveralls commented Nov 6, 2017

Coverage Status

Coverage increased (+0.05%) to 71.317% when pulling 597132fe33216469d8d95529b9108dabb84cd024 on mistercrunch:deck.gl into 13c17e1 on apache:master.

@mistercrunch mistercrunch changed the title [WiP] DECKGL integration [WiP] DECKGL integration - Phase 1 Nov 6, 2017
@coveralls
Copy link

coveralls commented Nov 7, 2017

Coverage Status

Coverage increased (+0.05%) to 71.512% when pulling b9b79683fa71955c297e9fadc5883c2fdb5a2151 on mistercrunch:deck.gl into ccb87d3 on apache:master.

@mistercrunch mistercrunch changed the title [WiP] DECKGL integration - Phase 1 DECKGL integration - Phase 1 Nov 7, 2017
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
@coveralls
Copy link

coveralls commented Nov 7, 2017

Coverage Status

Coverage increased (+0.05%) to 71.512% when pulling 310496ee0f3e59eda29621829db2451dfb0d4e99 on mistercrunch:deck.gl into ccb87d3 on apache:master.

@coveralls
Copy link

coveralls commented Nov 7, 2017

Coverage Status

Coverage increased (+0.05%) to 71.512% when pulling bbe3fca 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';
Copy link
Contributor

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.

Copy link
Contributor

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)

Copy link
Member Author

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,
Copy link
Contributor

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

Copy link
Member Author

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')}
Copy link
Contributor

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.

Copy link
Member Author

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,
Copy link
Contributor

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, {
Copy link
Contributor

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,
}

Copy link
Member Author

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,
Copy link
Contributor

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?

Copy link
Member Author

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

@mistercrunch
Copy link
Member Author

Thanks for the review @fabianmenges ! I addressed all the comments and improved a few other things along the way.

@coveralls
Copy link

coveralls commented Nov 8, 2017

Coverage Status

Coverage increased (+0.05%) to 71.492% when pulling 53c3159f770943d8a0d5cc94cbc566d87d571d86 on mistercrunch:deck.gl into 7453131 on apache:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 71.484% when pulling 53c3159f770943d8a0d5cc94cbc566d87d571d86 on mistercrunch:deck.gl into 7453131 on apache:master.

1 similar comment
@coveralls
Copy link

coveralls commented Nov 8, 2017

Coverage Status

Coverage increased (+0.04%) to 71.484% when pulling 53c3159f770943d8a0d5cc94cbc566d87d571d86 on mistercrunch:deck.gl into 7453131 on apache:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 71.494% when pulling f6ef855 on mistercrunch:deck.gl into 39e502f on apache:master.

1 similar comment
@coveralls
Copy link

coveralls commented Nov 8, 2017

Coverage Status

Coverage increased (+0.05%) to 71.494% when pulling f6ef855 on mistercrunch:deck.gl into 39e502f on apache:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 71.494% when pulling 1dc080789b0ab8d772b45fbad1edc2ed4e86cbcd on mistercrunch:deck.gl into 39e502f on apache:master.

3 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 71.494% when pulling 1dc080789b0ab8d772b45fbad1edc2ed4e86cbcd on mistercrunch:deck.gl into 39e502f on apache:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 71.494% when pulling 1dc080789b0ab8d772b45fbad1edc2ed4e86cbcd on mistercrunch:deck.gl into 39e502f on apache:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 71.494% when pulling 1dc080789b0ab8d772b45fbad1edc2ed4e86cbcd on mistercrunch:deck.gl into 39e502f on apache:master.

@coveralls
Copy link

coveralls commented Nov 9, 2017

Coverage Status

Coverage increased (+0.05%) to 71.494% when pulling 3202b67 on mistercrunch:deck.gl into cbcc00c on apache:master.

Copy link
Contributor

@williaster williaster left a 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,
Copy link
Contributor

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);
Copy link
Contributor

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

Copy link
Member Author

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

Copy link
Member Author

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...

Copy link
Member Author

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);
Copy link
Contributor

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);
Copy link
Contributor

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)}
Copy link
Contributor

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',
Copy link
Contributor

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),
Copy link
Contributor

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',
Copy link
Contributor

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',
Copy link
Contributor

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',
Copy link
Contributor

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?

@mistercrunch
Copy link
Member Author

@williaster I addressed your comments except for setState where I think we should stick with the way it's now, and for the spread operator where I think it's out of scope for this PR but I think we should totally remove Object.assign from our code base.

@graceguo-supercat
Copy link

LGTM

@graceguo-supercat graceguo-supercat merged commit 3a8af5d into apache:master Nov 16, 2017
michellethomas pushed a commit to michellethomas/panoramix that referenced this pull request May 24, 2018
* 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
wenchma pushed a commit to wenchma/incubator-superset that referenced this pull request Nov 16, 2018
* 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
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.21.0 labels Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.21.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants