Can somebody help me complete this demo. Everything is working. I have an interactive map that I populate from a Pandas Dataframe and when clicked it update the hvplot object, but for some reason the title update is visible only if I call on the object in another cell and the update is not displayed in the pn.Row
. This is very hacky and I am open to other approaches. The ultimate goal is to have the hvplot react to the marker selected and display a hvplot from an xarray.Dataset
.
import hvplot.pandas
import pandas as pd
import panel as pn
import pydeck as pdk
from bokeh.sampledata.degrees import data as deg
pd.options.mode.chained_assignment = None
hvplot.extension('plotly')
pn.extension("deckgl", stretch_width_policy="both")
DATA_URL = "https://raw.githubusercontent.com/ajduberstein/geo_datasets/master/biergartens.json"
ICON_URL = (
"https://upload.wikimedia.org/wikipedia/commons/c/c4/Projet_bi%C3%A8re_logo_v2.png"
)
data = pd.read_json(DATA_URL)
INITIAL_HVPLOT = pn.panel(deg.hvplot.line(
x="Year",
y=[
"Art and Performance",
"Business",
"Biology",
"Education",
"Computer Science",
],
value_label="% of Degrees Earned by Women",
legend="top",
height=500,
title="Initial Title",
))
INITIAL_VIEW_STATE = pdk.ViewState(
latitude=51, longitude=7.4, zoom=9, max_zoom=16, pitch=0, bearing=0
)
icon_data = {
"url": ICON_URL,
"width": 242,
"height": 242,
"anchorY": 242,
}
data["icon_data"] = None
for i in data.index:
data["icon_data"][i] = icon_data
view_state = pdk.data_utils.compute_view(data[["lon", "lat"]], 0.1)
icon_layer = pdk.Layer(
type="IconLayer",
data=data,
get_icon="icon_data",
get_size=4,
size_scale=15,
get_position=["lon", "lat"],
pickable=True,
)
deck_gl_obj = pdk.Deck(
layers=[icon_layer],
initial_view_state=INITIAL_VIEW_STATE,
tooltip={"text": "{tags}"},
)
deck_gl = pn.pane.DeckGL(deck_gl_obj, sizing_mode="stretch_width", height=600)
def panel_watcher(events):
INITIAL_HVPLOT.object.opts(title=f"Map Clicked at {events.new.get('coordinate')}")
deck_gl.param.watch(panel_watcher, "click_state")
out_row = pn.Row(deck_gl, INITIAL_HVPLOT)
out_row.servable()
**EDIT :** Until I figure out why this is the case I have hacked around the issue by creating a `pn.Row` that I `clear()` and then `append()` to in my callback that at least works for now.