Update : version 2.2 has been released since this was posted.
Hi Everyone,
Itās a pleasure to announce that Dash 2.1.0 is out!
pip install dash==2.1.0
Official Changelog Dash v2.1.0
Highlights
1. Auto-generated IDs for Components Inside Callbacks:
Input
, State
, Output
- now accept components instead of ID strings, and Dash callback
will auto-generate the componentās ID under-the-hood if not supplied. This allows usage like:
my_input = dcc.Input()
my_output = html.Div()
app.layout = html.Div([my_input, my_output])
@callback(Output(my_output, 'children'), Input(my_input, 'value'))
def update(value):
return f'You have entered {value}'
Or, if using Python >=3.8 you can use the :=
walrus operator inside the Layout:
app.layout = html.Div([
my_input := dcc.Input(),
my_output := html.Div()
])
@callback(Output(my_output, 'children'), Input(my_input, 'value'))
def update(value):
return f'You have entered {value}'
Note:
- Since callbacks need to be defined in advance, you canāt use this if you are defining chunks of layouts with a callback that updates a
children
property. For example, if you create and return a dropdown component inside a callback, you must provide an ID to that dropdown. Otherwise, you will not be able to use that dropdown in other callbacks. - These random IDs are defined in the order that the callbacks are defined, which is why itās stable when running across multiple processes or servers. However, if you refactor your code, the underlying IDs will change. Because of this ID fragility, you cannot use this with persistence or Dash Enterprise Snapshot or Report Engine and Dash will raise an exception if you try to do so.
2. Rearranged Keyword Arguments & Flexible Types:
Dropdown
, RadioItem
, and Checklist
- Rearranged Keyword Arguments -
options
&value
are now the first two keywords inside some components, which means they can be supplied as positional arguments without the keyword. (Supplying the keywordsoptions=
andvalue=
is still supported.) - Flexible Types -
options
can be supplied in two new forms:- An array of
string|number|bool
wherelabel
andvalue
are equal to the items in the list. - A dictionary where the keys and values set as
value
andlabel
respectively.
- An array of
Before:
dcc.Dropdown(
options=[
{'label': 'New York', 'value': 'New York'},
{'label': 'Montreal', 'value': 'Montreal'},
],
value='New York'
)
After, with Dash 2.1.0 or higher:
dcc.Dropdown(['New York', 'Montreal'], 'New York')
Before:
dcc.Dropdown(
options=[
{'label': 'New York', 'value': 'NYC'},
{'label': 'Montreal', 'value': 'MTL'},
],
value='New York'
)
After, with Dash 2.1.0 or higher:
dcc.Dropdown({'NYC': 'New York', 'MTL': 'Montreal'}, 'New York')
RangeSlider
& Slider
- Rearranged Keyword Arugments -
min
,max
, andstep
are now the first three keyword arguments which means they can be supplied as positional arguments without the keyword. - Flexible Types:
step
will be calculated implicitly if not given.
Before
dcc.Slider(marks={1: 2, 2: 2, 3: 3})
After, with Dash 2.1.0 or higher:
dcc.Slider(min=1, max=3, step=1)
Or equivalently:
dcc.Slider(1, 3, 1)
Step can also be omitted and the Slider will attempt to create a nice, human readable step with SI units and around 5 marks:
dcc.Slider(0, 100)
marks
will be auto-generated if not given. It will usemin
andmax
and will respectstep
if supplied. Auto generated marks labels are SI unit formatted. Around 5 human-readable marks will be created. For example, the code above would generate this Slider:
- To remove the Sliderās marks, set
marks=None
.
dcc.Slider(0, 100, marks=None)
The SI units and ranges supported in marks
are:
Āµ
- micro, 10ā»ā¶m
- milli, 10ā»Ā³ā
(none) - 10ā°k
- kilo, 10Ā³M
- mega, 10ā¶G
- giga, 10ā¹T
- tera, 10Ā¹Ā²P
- peta, 10Ā¹āµE
- exa, 10Ā¹āø
DataTable
- Rearranged Keyword Arguments -
data
andcolumns
are the first two keyword arguments which means they can be supplied as positional arguments without the keyword. - Inferred Properties - If
columns
isnāt supplied then it is extracted from the the first row indata
Before:
dash_table.DataTable(data=df.to_dict('records'), columns=[{'name': i, 'id': i} for i in df.columns])
After, with Dash 2.1.0 or higher:
dash_table.DataTable(data=df.to_dict('records'))
3. New Component Prop:
Checklist
& RadioItems
- A new property
inline
appendsdisplay: inline-block
tolabelStyle
.
dcc.Checklist(inline=True)
4. New dcc.Graph Options:
- Feature release 2.5.0:
- 3D traces are now compatible with
no-unsafe-eval
CSP rules.
- 3D traces are now compatible with
- Feature release 2.6.0:
- Add
smith
subplots andscattersmith
traces, for drawing Smith charts.
- Add
import plotly.graph_objects as go
fig = go.Figure(go.Scattersmith(imag=[0.5, 1, 2, 3], real=[0.5, 1, 2, 3]))
fig.show()
- Feature release 2.7.0:
- Add text data for
histogram
traces. - Fix an interaction between
uirevision
andautorange
that pops up in some cases of mixed clientside / serverside figure generation.
- Add text data for
- Feature release 2.8.0:
- Control legend group title fonts.
- Add text data on
heatmap
and related trace types.
import plotly.graph_objects as go
fig = go.Figure(data=go.Heatmap(
z=[[1, 20, 30],
[20, 1, 60],
[30, 60, 1]],
text=[['one', 'twenty', 'thirty'],
['twenty', 'one', 'sixty'],
['thirty', 'sixty', 'one']],
texttemplate="%{text}",
textfont={"size":20}))
fig.show()
- Add horizontal colorbars.
fig.update_traces(colorbar_orientation='h')
- Patch releases 2.5.1, 2.6.1, 2.6.2, 2.6.3, 2.6.4, 2.8.1, 2.8.2, and 2.8.3 containing bugfixes.
- This PR also upgrades various other dependencies of dash renderer and component suites.
5. Notable Fixes:
- #1879: Deletes redundancy in pattern-matching callback implementation, specifically when
ALL
andMATCH
wildcards are used together. This fix vastly improves the performance of PMC callbacks as noted by several community members. Many thanks! - Thank you @urig for reporting the bug about the DataTable page number not being persistent. This has now been fixed.
6. Future Dash Releases:
Dash Multi-page App
Exciting work continues in dash-labs on the popular pages feature which will offer a better way to make multi-page Dash apps. The newly released dash-labs 1.0.2 includes the new feature of āvariables in the pathā, as requested by @benn0. Thank you Ben.
MarkdownAIO
Although this new feature is not available yet, here is a āsuper secret feature previewā MarkdownAIO: Markdown that runs code! See the live demo.
MarkdownAIO
is a Dash feature that will allow you to write Dash Apps as Markdown files. Simply pass in a Markdown file and MarkdownAIO
will return a set of components with the option to display and/or execute code blocks. MarkdownAIO
could be used for multiple purposes, such as:
- Documentation helper
- Markdown / Text authoring tool
- Makes it easy way to bring a Markdown file into an app without doing open(āfile.mdā)
- Itās also compatible with the
pages/
api. The live demo is a multi-page app made withpages/
, and each page is a Markdown file displayed usingMarkdownAIO
.
We would like to say thank you to our community member, @AnnMarieW, for all the time she has been dedicating to contribute to open source Dash, for creating the MarkdownAIO PR as well as creating and hosting the online dash-labs docs.
7. Previous Releases:
Dash 2.0 Prerelease Candidate Available!
Dash v1.21.0 - Plotly.js 2.0, Icicle Charts, Bar Chart Patterns, Clipboard Component, Bug Fixes
Dash 1.20.0 - dcc.Download
component & various community contributed bug fixes