Reputation: 2556
I'm using Dash
by Plotly
to create a dashboard but that would take Date Range as input. But I'm getting TypeError
while trying to imitate the simple example shown in here. I don't understand what am I doing wrong. Below is my code:
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, State
from datetime import datetime as dt
app = dash.Dash(__name__)
app.config['suppress_callback_exceptions'] = True
app.css.config.serve_locally = True
app.scripts.config.serve_locally = True
app.layout = html.Div(children=[
html.H1(children='AE Analytics Dashboard', style={'color': 'gray', 'text-align': 'center'}),
html.Div(
html.Div(
dcc.Input(id='input-box', placeholder='Enter AE Name', type='text',value=''),
dcc.DatePickerRange(
id='date-picker-range',
start_date_placeholder_text= 'Select a date!',
end_date_placeholder_text='Select a date!'
)
),
html.Button('Submit', id='button'),
# html.Div(id='output-container-button', children='Enter a value and press submit')
)
])
if __name__ == "__main__":
app.run_server(debug=True)
Error:
TypeError: unhashable type: 'DatePickerRange'
I'm Having following error while trying to use html.Button
:
TypeError: unsupported format string passed to Button.format
Upvotes: 0
Views: 4814
Reputation: 2556
I solved it. It was a silly mistake. Below is the corrected code for anyone's reference.
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, State
from datetime import datetime as dt
app = dash.Dash(__name__)
app.config['suppress_callback_exceptions'] = True
app.css.config.serve_locally = True
app.scripts.config.serve_locally = True
app.layout = html.Div(children=[
html.H1(children='AE Analytics Dashboard', style={'color': 'gray', 'text-align': 'center'}),
html.Div(
html.Div([
dcc.Input(id='input-1-state', type='text', placeholder='AE Name', style={'text-align': 'center'}, value=''),
dcc.DatePickerRange(
id='date-picker-range',
start_date_placeholder_text= 'Select a date!',
end_date_placeholder_text='Select a date!'
),
html.Button(id='submit-button', n_clicks=0, children='Submit')
]),
),
])
if __name__ == "__main__":
app.run_server(debug=True)
Upvotes: 2