Hello everybody
I’m pleased to announce that Dash 1.21.0 is out
pip install dash==1.21.0
Dash 1.21.0 is a backwards compatible feature release. See the official changelog.
Plotly.js 2.x Series!
Dash 1.21.0 is the first Dash release to use the plotly.js
2.x.xand
plotly.py 5.x.x.
series. In particular, it uses plotly.js 2.2.1 and is compatible with plotly.py 5.1. These features are available in the dcc.Graph
component.
Backwards-Incompatible Changes to dcc.Graph
and plotly.py 5.0
The following features are being dropped or deprecated:
- Support for Python 2.7 and 3.5 as well as for Internet Explorer 9 and 10 has been dropped.
- The long-deprecated and un/under-documented
area
trace type and the legacyscatter.(r|t)
attributes have been removed, meaning that theplotly.graph_objects.Area
class has been removed.- (note the
px.area()
function still works and has never used the legacyarea
trace type, which was a polar trace type)
- (note the
- The
heatmapgl
andpointcloud
trace types are now deprecated, as are thetransforms
attributes in any trace in which they appear
The following changes have been made to library defaults:
- Plotly Express now always takes into account every value in
category_orders
when computing discrete mappings (color, symbol, line-dash, pattern-shapes) as well as facets, even those values which are absent in the data - The font size for legend and colorbar titles is slightly bigger, to match axis titles
- In
bar
traces, the defaulttextposition
is nowauto
rather thannone
- Legend items will no longer include the long-disliked
Aa
text unlessmode
strictly equalstext
- the “modebar” which appears when the mouse cursor is over a plot no longer includes buttons for switching the hovermode between
x
andclosest
(closest
is now the default) and no longer includes a button for toggling “spikelines”
This release of Dash bumps Plotly.js from 1.58.4 to 2.2.1, so we recommend that interested users check out our Plotly.js 2.0 release announcement, which includes more in-depth information to the breaking changes in the underlying library. The Plotly.js 2.0 work was partly funded by Equinor, and we thank them on behalf of the community
Bar Chart Patterns (aka Hatching or Textures)
Bar charts, histograms and polar bar charts have large markers which support not only a fill color, but as of version 5.0, also an optional pattern (also known as “hatching” or “texture”). This can be used for a variety of reasons:
- to double-encode variables (i.e. using both color and pattern) to improve accessibility for visually-impaired end-users
- to encode an additional variable beyond just using color
- to make charts that are easier to print in black and white
This feature was a community contribution from @s417-lama and we thank them on behalf of the community !
Icicle and Flame Charts
Do you like plotly
's sunburst charts but wish they were less circular, but also less nested than treemaps? Then our new icicle charts are for you! They can work in any direction: left to right (or vice versa) for nice text layout, top-down and bluish for the classic icicle look, or bottom up and reddish for the classic flame chart!
This feature was developed by our former colleagues @Kully and @mtwichan of Zyphr and we thank them and their sponsors at Virgin Hyperloop!
Explicit Legend-Item Ordering
A commonly-requested feature is the ability to reorder a figure’s legend items without needing to change the order in which traces appear in the data
object. The new legendrank
attribute addresses this need: the default rank is 1000, meaning that any trace can be sent to the bottom of the list if it is the only one with a rank greater than 1000, and the same goes for moving traces to the top of the list with ranks less than 1000. Ties are broken using the current position-in-data
logic.
This feature was anonymously sponsored, and we thank our sponsors !
Faster JSON serialization with orjson
One core performance bottleneck in Dash is that components and their properties (like dcc.Graph
's figure
) are automatically, internally serialized to a JSON string format for rendering in the browser. This can be quite slow by default for figures containing large numpy
arrays or pandas
data frames. In this release we have made some progress towards speeding this up, using an optional dependency on the excellent orjson
library. When orjson
is installed, Plotly.py will automatically leverage it to perform JSON serialization, which can result in 5x-10x performance improvements when the figure contains large arrays.
dcc.Clipboard
dcc.Clipboard
is a new component that copies text to the clipboard. This was graciously contributed by community member @AnnMarieW
The easiest way to trigger the copy is by using the the target_id
property. No callback is required!
Place dcc.Clipboard()
in the layout where you would like the copy icon located. Specify the target_id
of the component with text to copy.
In this example, the content of the value
prop of the dcc.Textarea() is copied to the clipboard.
app.layout = html.Div(
[
dcc.Textarea(
id="textarea_id",
value="Copy and paste here",
style={ "height": 100},
),
dcc.Clipboard(
target_id="textarea_id",
title="copy",
style={
"display": "inline-block",
"fontSize": 20,
"verticalAlign": "top",
},
),
],
)
When target_id
is not specified, the content of the text
prop is copied to the clipboard. This works well with components like the DataTable where you may want to customized the text in a callback.
In this example, the dataframe is converted to text with pandas to_string()
. See the pandas documentation for other formatting options such as including or excluding headers.
df = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/solar.csv")
app.layout = html.Div(
[
dcc.Clipboard(
id="DataTable_copy",
style={"fontSize": 30, "color": "white", "backgroundColor": "grey", "height":38},
className="button",
),
dcc.RadioItems(
id="copy_selected",
options=[
{"label": "Copy All", "value": "all"},
{"label": "Copy Selected", "value": "some"},
],
value="all",
style={"display": "inline-block"},
),
dash_table.DataTable(
id="DataTable",
columns=[{"name": i, "id": i} for i in df.columns],
data=df.to_dict("records"),
sort_action="native",
page_size=10,
),
]
)
@app.callback(
Output("DataTable_copy", "text"),
Input("DataTable_copy", "n_clicks"),
State("DataTable", "start_cell"),
State("DataTable", "end_cell"),
State("DataTable", "derived_virtual_data"),
State("copy_selected", "value")
)
def custom_copy(_, start, end, data, copy_selected):
dff = pd.DataFrame(data)
if start and (copy_selected == 'some'):
copy_cells = dff.loc[
start["row"]: end["row"], start["column_id"]: end["column_id"]
]
return copy_cells.to_string(header=False)
else:
return dff.to_string() # includes headers
This component uses the Clipboard API, which is not supported by older browsers like Internet Explorer. When the Clipboard API is unavailable, the icon will not appear in the app and a warning message is written to the console.
Currently dcc.Clipboard only supports copying text to the clipboard.
Various Improvements
-
#916
html
option tomarkdown_options
prop inDataTable
. This enables the use of html tags in markdown text. -
#545. Case insensitive filtering to
DataTable
. This feature anonymously sponsored (thank you!)- New props:
filter_options
- to control case of all filters,columns.filter_options
- to control filter case for each column - New operators:
i=
,ieq
,i>=
,ige
,i>
,igt
,i<=
,ile
,i<
,ilt
,i!=
,ine
,icontains
- for case-insensitive filtering,s=
,seq
,s>=
,sge
,s>
,sgt
,s<=
,sle
,s<
,slt
,s!=
,sne
,scontains
- to force case-sensitive filtering on case-insensitive columns
- New props:
-
#948
disabled_days
prop toDatePickerRange
andDatePickerSingle
components. With this prop you can specify days that should be made unselectable in the date picker, in addition to those that fall outside of the range specified bymin_date_allowed
andmax_date_allowed
. Thank you @tcbegley for the contribution! -
#1675 Remove the constraint that
requests_pathname_prefix
ends withroutes_pathname_prefix
. When you are serving your app behind a reverse proxy that rewrites URLs that constraint needs to be violated. -
#1664 Fix #1649, makes the devtools readable with a dark theme. Thank you @AnnMarieW for the contribution!
-
#1640 Fix #1475, missing
timing_information
after certain modifications to Flask behavior. Thank you@remibaar
for the contribution! -
#907 Fixed DataTable pagination bugs. Thank you @AnnMarieW for the contribution!
Previous Releases
- đź“Ł Dash 1.20.0 - `dcc.Download` component & various community contributed bug fixes
- Dash 1.19.0 - Circular Callbacks,
drag_value
indcc.Slider
, Close Button in Dev Tools, dcc.Graph Bug Fixes - Dash 1.18.1 Release - Faceted and Animated Images and Heatmaps, DataTable Bootstrap Support, Inside Tick Labels, Better Axis Type Detection
- Dash 1.17.0 Released - DataTable Header Tooltips, dcc.Graph Subplot images, shapes, and annotations, and several bug fixes
- Dash 1.16.3 Released - Fixes Performance Degradation from Flask-Compress Dependency
- Dash 1.16.2 Released - Devtools & Callbacks Bug Fixes
- Dash 1.16.1 Released - dcc.Graph prependData & Bug Fixes
- Dash 1.16.0 - Brand New Debugging & Performance Tools, Improved Callback Graph, Date-Axis & Timeline Improvements, Faster Images, Content Security Policy, and Community Contributions
- Dash v1.15.0 Released - Julia Components, Simplified Callback Syntax, Fixed Table Tooltips and Copy & Paste, fixed dcc.Loading styling
- Dash v1.14.0 Released - Update the Tab’s Title, Removing the “Updating…” Messages, Updated DataTable Link Behavior
- Dash v1.13.4 Release: Fixes regression with loading states from callbacks with multiple outputs
- Dash v1.13.3 Release: Improved performance, clientside callback_context, many dcc.Graph & DataTable bug fixes
- Dash v1.12.0 Release - Pattern-Matching Callbacks Fixes, Shape-drawing, new DataTable conditional formatting options, prevent_initial_call, and more
- Dash v1.11.0 Release - Introducing Pattern-Matching Callbacks
- Dash v1.10.0 Release - New dcc.Graph features, updated dcc.Link, React upgrade and bug fixes
- Dash v1.9.0 release - Bug fixes
- Dash v1.8.0 release - dcc.Graph updates, markdown & link support in DataTable, and more
- Dash v1.7.0 released - Async component fixes, inline clientside callbacks, and bug fixes
- Dash 1.6.0 released - dcc.Graph updates, async performance improvements, improved caching