app.layout = html.Div([
dcc.Location(id="url"),
html.Div(style=SLIDER_STYLE, children=[
dcc.Slider(
id='my_slider',
min=2010,
max=2017,
step=1,
value=2014,
marks={
2010: '2010',
2011: '2011',
2012: '2012',
2013: '2013',
2014: '2014',
2015: '2015',
2016: '2016',
2017: '2017'
},
included=False
)]),
dcc.Dropdown(
id='dropdown',
options=[
{'label': 'Degree', 'value': 'DEGREE'},
# {'label': 'Average Income', 'value': 'AVGINCOME'},
# {'label': 'Median Income', 'value': 'MEDINCOME'},
{'label': 'Rooms per Household', 'value': 'ROOMS'},
{'label': 'Home Ownership', 'value': 'OWN'},
{'label': 'Vehicle Ownership', 'value': 'VEHICLES'}
],
value='DEGREE',
placeholder="Select a variable to display on the map",
style=CONTENT_STYLE
),
# html.Div(id='output_container', children=[], style=CONTENT_STYLE),
# html.Div(id='output_container_two', children=[], style=CONTENT_STYLE),
html.Br(),
dcc.Graph(id='map', figure={}, style=MAP_STYLE),
sidebar
])
@cc.cached_callback(
Output("map", "figure"),
[Input("url", "pathname"),
Input(component_id='my_slider', component_property='value'),
Input(component_id='dropdown', component_property='value')]
)
def render_page_content(pathname, my_slider, dropdown):
year = my_slider
variable = dropdown
finaldf = load_data(year)
counties = load_counties()
if pathname == "/":
finaldf['GEOID'] = finaldf['GEOID'].str.zfill(5)
min_value = finaldf[variable].min()
max_value = finaldf[variable].max()
fig = px.choropleth(
data_frame=finaldf,
geojson=counties,
locations=finaldf["GEOID"],
scope="usa",
color=variable,
hover_data=['County Name', variable],
color_continuous_scale="Viridis",
labels={str(variable): variable},
range_color = [min_value, max_value]
)
fig.update_layout(geo=dict(bgcolor= 'rgba(189, 222, 240, 1)', lakecolor='#BDDEF0'))
fig.update_traces(marker_line_width=0)
fig.update_geos(visible=False, resolution=110, scope="usa")
# print(fig)
return fig
I’ve been trying to use cc.cached_callback instead of app.callback, and this error arises. Is there some error in my syntax (missing commas) or what