Hi everyone, first post here. I’m just getting started with Dash, and I’ve got stuck while attempting to make a simple slider based on the example from the documentation - I’ll use it, as both codes result in the same outcome:
from dash import Dash
from dash.dependencies import Input, Output
from dash import html
from dash import dcc
import pandas as pd
import plotly_express as px
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/gapminderDataFiveYear.csv')
app = Dash(__name__)
app.layout = html.Div([
dcc.Graph(id='graph-with-slider'),
dcc.Slider(
df['year'].min(),
df['year'].max(),
step=None,
marks={str(year): str(year) for year in df['year'].unique()},
value=df['year'].min(),
id='year-slider'
)
])
@app.callback(
Output('graph-with-slider', 'figure'),
Input('year-slider', 'value'))
def update_figure(selected_year):
filtered_df = df[df.year == selected_year]
fig = px.scatter(filtered_df, x="gdpPercap", y="lifeExp",
size="pop", color="continent", hover_name="country",
log_x=True, size_max=55)
fig.update_layout(transition_duration=500)
return fig
if __name__ == '__main__':
app.run_server(debug=True)
Traceback (most recent call last):
File "c:\Users\~\app.py", line 14, in <module>
dcc.Slider(
File "C:\Users\~\anaconda3\envs\Dash\lib\site-packages\dash\development\base_component.py", line 366, in wrapper
return func(*args, **kwargs)
TypeError: __init__() got multiple values for argument 'marks'
I dont’t have a clue about what can be done. If anyone could help me, I’d be immensely grateful!