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

Using user-defined Javascript to customize geospatial visualization #4173

Merged
merged 4 commits into from
Jan 11, 2018

Conversation

mistercrunch
Copy link
Member

@mistercrunch mistercrunch commented Jan 8, 2018

screen shot 2018-01-08 at 10 09 46 am

Proof of concept on custom user-provided JS on deck_path an deck_scatter visualizations. Users can pick extra data columns that become available in their javascript functions' scope.

Users can pass 3 javascript snippet to respectively:

  • intercept the object corresponding to the data point and mutate it. This enables them to do things like controlling the stroke-color, stroke-width, fill-color, fill-opacity either in a fixed way or to bind it to related data
  • write a JS function that returns an HTML tooltip, allowing user to craft rich tooltips that expose many attributes of the data
  • write a JS function that returns a url that defines the onclick event

@mistercrunch mistercrunch force-pushed the js_spatial branch 3 times, most recently from 78b267a to df22f29 Compare January 9, 2018 17:01
const fd = formData;
const fc = fd.fill_color_picker;
const sc = fd.stroke_color_picker;
const data = payload.data.geojson.features.map(d => ({
let data = payload.data.geojson.features.map(d => ({
...d,
Copy link
Member

Choose a reason for hiding this comment

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

Why let instead of const?

Copy link
Member

Choose a reason for hiding this comment

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

Because now data can be mutated (see below, line 44).

superset/viz.py Outdated
@@ -1876,8 +1882,12 @@ def get_data(self, df):

features = []
for d in df.to_dict(orient='records'):
d = dict(position=self.get_position(d), **self.get_properties(d))
features.append(d)
print(d)
Copy link
Member

Choose a reason for hiding this comment

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

remove print

Copy link
Member Author

Choose a reason for hiding this comment

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

oops

@hughhhh
Copy link
Member

hughhhh commented Jan 11, 2018

🚢

Copy link
Member

@betodealmeida betodealmeida left a comment

Choose a reason for hiding this comment

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

<3 this

superset/viz.py Outdated
d['columns'] = [self.form_data.get('line_column')]
line_col = self.form_data.get('line_column')
if d['metrics']:
d['groupby'] += [line_col]
Copy link
Member

Choose a reason for hiding this comment

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

No love for .append()?

Copy link
Member

Choose a reason for hiding this comment

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

shorthand all day 💯 @betodealmeida

@mistercrunch mistercrunch merged commit 87c3e83 into apache:master Jan 11, 2018
@mistercrunch mistercrunch deleted the js_spatial branch January 11, 2018 23:42
michellethomas pushed a commit to michellethomas/panoramix that referenced this pull request May 24, 2018
…pache#4173)

* Using JS to customize spatial viz and tooltips

* Add missing deck_multi.png

* Improve GeoJSON layer with JS support and extra controls

* Addressing comments
wenchma pushed a commit to wenchma/incubator-superset that referenced this pull request Nov 16, 2018
…pache#4173)

* Using JS to customize spatial viz and tooltips

* Add missing deck_multi.png

* Improve GeoJSON layer with JS support and extra controls

* Addressing comments
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.23.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.23.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants