dev-docs/RFCs/proposals/pydeck-interactive-api-rfc.md
References:
This RFC proposes direction, APIs and extensions for handling interactive events in pydeck.
pydeck in deck.gl v8.0 has the potential to be a building block for rich interactive python applications, but the interactive facilities are limited:
ipywidgets.observe())ipywidgets has an observe() API.
pydeck is based on ipywidgets
Question: Should we use ipywidgets style API, or deck.gl API, or transport API or all of the above?
Hover Tooltip
tooltip prop.Hover
Click
PickInfo
ViewStateChange
Other events?
Selections
deck.gl offers powerful picking feature (deep picking, area picking), but it is not possible to use these features declaratively.
The current version of pydeck has some custom handling to support selections, it does call picking and stores the selected data on r.deck_widget.selected_data (although no indication of when the change happens).
pd.DataFrame([r.deck_widget.selected_data])
It would be good to have a declarative API for this.
nebula.gl has started to offer a selection of measurement tools and it would be incredibly cool to offer these in pydeck.
So far there are measurement tools for:
Currently not clear:
With the right callback system in place, it would be great to expose nebula.gl's editable layers, e.g. EditableGeojsonLayer) in pydeck.
Python could pass in GeoJSON and get an edited version back...
It would be good to base the interaction events on the transport protocol.
Specifying user data for a global event handler:
{
"@@type": 'ScatterplotLayer',
"onClick": <user_data> // This object will be serialized and passed back with the event.
}
Transport back-channel event
{
"@@type": 'event'
"data": <user_data>
"info": <pick info object>
}
Python specifying a "callable"
import pydeck as pdk
layer = pdk.Layer(
'ScreenGridLayer',
df,
cell_size_pixels=20,
color_range=COLOR_RANGE,
get_position='[lng, lat]',
pickable=True,
auto_highlight=True,
on_click=<callable>,<user_data>)
r = pdk.Deck(layers=[layer], initial_view_state=viewport)
TBD: Add new userData prop?