Hello community,
I have created a plotly choroplethmapbox graph that actually works when I display it in a new window of the localhost of the Rstudio client. However, when I use the same graph in a pretty simple dash app, it just show the layout and the colorbar.
The data can be downloaded easily from:
about the data:
-“pib_total” is a dataframe where each column represent an income level per county and it is indexed by ‘id’’ of the county.
-‘counties’ is the geojson file with an id, features and geometry for each county
Here I attach the code:
mapbox_access_token <- "pk.eyJ1Ijoiamhvbi1sb2Nhcm5vIiwiYSI6ImNrcmUwczAwaDVpaXIycG1mejM0MXBsZ2wifQ.rF9ppwqseH8IOaNdzbcu8Q"
mapbox_style <- "mapbox://styles/jhon-locarno/ckre1rhl910d717q3rpbsp3zt"
counties <- RJSONIO::fromJSON("county.geojson")
load("pib_total.Rda")
fig <- plot_ly()
fig <- fig %>% add_trace(
type="choroplethmapbox",
geojson=counties,
locations=pib_total$id,
z=pib_total$`2019`,
colorscale="Viridis",
#featureidkey="properties.MPIOS",
zmin=0,
zmax=16000,
#hovertext=df_lat_lon$Nombre...4,
marker=list(line=list(
width=0),
opacity=0.5
)
)
fig <- fig %>% layout(
mapbox=list(
style=mapbox_style,
accesstoken=mapbox_access_token,
zoom =4.5,
center=list(lon= -74, lat=6)),
autosize = TRUE)
app <- Dash$new()
app$layout(
htmlDiv(
list(
dccGraph(figure=fig)
)
)
)
app$run_server(debug=TRUE, dev_tools_hot_reload=FALSE)
dash, plotly and R are updated to the last version and I have tried in other browsers and its the sema
Thank you in advance.