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

PyDeck tooltip not working #4501

Closed
MarcSkovMadsen opened this issue Mar 4, 2023 · 3 comments · Fixed by #4693
Closed

PyDeck tooltip not working #4501

MarcSkovMadsen opened this issue Mar 4, 2023 · 3 comments · Fixed by #4693
Labels
type: bug Something isn't correct or isn't working
Milestone

Comments

@MarcSkovMadsen
Copy link
Collaborator

Panel=0.14.4, PyDeck=0.8.0

Diehl reports in https://discourse.holoviz.org/t/custom-pydeck-tooltip-in-panel-application-fails-to-access-data/5016 that PyDeck tooltips are not working for him.

After working with his example I believe this is a bug.

Reproducible Example

import pydeck as pdk
import panel as pn
pn.extension('deckgl')

INITIAL_VIEW_STATE = pdk.ViewState(
  latitude=38,
  longitude=-97,
  zoom=3,
  min_zoom=3,
  max_zoom=16,
  pitch=0,
  bearing=0
)

ACCESS_TOKEN = "pk.eyJ1IjoicGFuZWxvcmciLCJhIjoiY2s1enA3ejhyMWhmZjNobjM1NXhtbWRrMyJ9.B_frQsAVepGIe-HiOJeqvQ"

layer = pdk.Layer(
    "MVTLayer",
    'https://api.mapbox.com/v4/diehl.6baso3o2/{z}/{x}/{y}.mvt?access_token='+ACCESS_TOKEN,
    get_line_color = [0, 255, 0],
    line_width_min_pixels = 1,
    pickable=True
)

TOOLTIP_HTML = ('<b>{ALLOT_NAME}</b><br />'
                '<b>Allotment #</b>: {ALLOT_NO}<br />'
                '<b>Acres</b>: {GIS_ACRES}<br />')

r = pdk.Deck(
    layers=[layer],
    initial_view_state=INITIAL_VIEW_STATE,
    map_style='dark',
    tooltip={'html': TOOLTIP_HTML}
)

map = pn.pane.DeckGL(r, sizing_mode='stretch_both') 
map.servable()

image

As you can see in the above example the parameters {ALLOT_NAME}, {ALLOT} and {GIS_ACRES} are not being replaced.

Works without Panel in the notebook

image

Here parameters are replaced with their values.

@MarcSkovMadsen MarcSkovMadsen added the type: bug Something isn't correct or isn't working label Mar 4, 2023
@MarcSkovMadsen MarcSkovMadsen added this to the next milestone Mar 4, 2023
@diehl
Copy link

diehl commented Mar 21, 2023

@MarcSkovMadsen It turns out this issue is resolved by using {properties.<DATA_FIELD_NAME>} as opposed to {<DATA_FIELD_NAME>}.

@MarcSkovMadsen
Copy link
Collaborator Author

Thanks for sharing. I keep this open as I Think we should document this.

@diehl
Copy link

diehl commented Mar 21, 2023

My pleasure @MarcSkovMadsen - I totally agree with documenting this to make it clear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't correct or isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants