I came across a plotly.js example for a mapbox heatmap (densitymapbox - https://github.com/plotly/plotly.js/pull/3993)
Is there a way I can achieve the same on my dash app in python? It’s currently a dynamic scatter mapbox plot which I’m looking to convert to a dynamic heatmap.
There will be! This isn’t yet published in
dash-core-components yet, but we’ll keep this thread updated when it is published. Next week or two.
The densitymapbox and scattermapbox have been added in the 4.1.0 version, released on the August 6th. Both work perfectly in jupyter lab but the densitymapbox does not in Dash. When returning the figure to a graph component, it displays a blank figure. Scattermapbox displays correctly however. Am I missing something ?
you’ll need to upgrade dash.
That was it indeed…! The Dash version installed on my machine was really outdated. Many thanks !
Does anyone have an example using the density mapbox plot in a calback?
Here’s my example. I can’t recall how I landed on the radius calculation. I would not consider it the best approach, as I’m sure there’s a more elegant way to calculate it.
def reporting_trip_heat_map(pool, start_date, end_date):
sql_conn = pyodbc.connect(...)
cursor = sql_conn.cursor()
"SELECT ... "
"FROM ... "
"WHERE ... ? "
"AND ... ?",
rows = cursor.fetchall()
radius = 2 + (6000 / len(rows))
lon = 
lat = 
for row in rows:
fig = go.Figure()
margin=dict(l=10, r=10, t=80, b=0),
thank you for this. it helps out.