Building Dashboards with Dash and Plotly
Alex Scriven
Data Scientist
Some useful applications of user inputs:
number
inputs)search
or text
inputs)password
and email
/text
input)
A user input is a dash core components Input
type (dcc.Input
)
id
is required for callback integrationtype
will default to textplaceholder
shows faded guidance text
dcc.Input(
id='my_input',
type='text',
placeholder="Enter your text")
# @callback()
def update_plot(entered_data):
fig = px.scatter(
data_frame=sales,
y='OrderValue', x='Quantity',
, title=f'{entered_data}')
return fig
'text'
, 'number'
, 'password'
, 'email'
'range'
produces a range slider'tel'
and 'url'
are for telephone numbers and website urls'search'
and 'hidden'
involve advanced browser interaction
The type
argument automatically sets some limitations.
email
type requires [email protected] formatdcc.Input(
id='my_input',
type='email',
placeholder="Enter your email")
number
type only allows numbersmin
and max
set numerical limitminLength
/ maxLength
for text
inputstext
type also has pattern
for regex validation
dcc.Input(
id='my_input',
type='number',
max=250)
disabled
required
$$
dcc.Input()
dcc.Input(id='my_input', disabled=True)
dcc.Input(id='my_input', required=True)
$$
dcc.Input(id='my_input', type='text',
debounce=False)
$$
R
, Re
, Red
, Redd
Building Dashboards with Dash and Plotly