How can I speed up the rendering for choropleth map? Any parameter or anything do you recommend? I just need a simple map colored by zip code. Thanks
@st.cache_data(ttl=60*60, show_spinner=False)
def load_geo_json():
file_contents = open('assets/ct_geo.json', 'r')
return json.loads(file_contents.read())
zipcodes = load_geo_json()
fig = px.choropleth(df_active_num_dynamic,
geojson=zipcodes,
locations="postalcode",
color="Active",
color_continuous_scale="Sunset",
range_color=(0, df_active_num_dynamic['Active'].max()),
featureidkey="properties.ZCTA5CE10",
scope="usa",
custom_data=["postalcode", "Active", "city",]
# labels={'Active':'# of Active Listings'}
)
fig.update_geos(fitbounds="locations")
fig.update_traces(
hovertemplate="<br>".join([
"Zip Code: %{customdata[0]}",
"# of Actives: %{customdata[1]}",
"City: %{customdata[2]}",
])
)
fig.update_layout(height=500, margin={"r":0,"t":0,"l":0,"b":0})
st.plotly_chart(fig, use_container_width=True)