Changelogs
dash
dash-renderer
dash-core-components
Highlights
- Added Clientside Callbacks
- Updated React from 15.4.2 to 16.8.6
- Multi-output partial update
- Updated Plotly.js to 1.47.0. More details in the Plotly.js release notes
- Updated dcc
react-dates
from 12.3.0 to 20.1.0 - Improvements to the dcc
Graph
component extendData, config defaults
In Depth
Clientside Callbacks
Clientside JS code defined in the assets
folder
if(!window.dash_clientside) {window.dash_clientside = {};}
window.dash_clientside.clientside = {
display: function (value) {
return 'Client says "' + value + '"';
}
}
Example Dash App
import dash
import dash_html_components as html
import dash_core_components as dcc
from dash.dependencies import ClientsideFunction, Input, Output
app = dash.Dash(__name__)
app.layout = html.Div([
dcc.Input(id='input'),
html.Div(id='output-clientside'),
html.Div(id='output-serverside')
])
@app.callback(
Output('output-serverside', 'children'),
[Input('input', 'value')])
def update_output(value):
return 'Server says "{}"'.format(value)
app.clientside_callback(
ClientsideFunction(
namespace='clientside',
function_name='display'
),
Output('output-clientside', 'children'),
[Input('input', 'value')]
)
if __name__ == "__main__":
app.run_server(port=8070)
Partial Multi-output
no_update
prevents updates for individual outputs:
from dash import Dash, no_update
from dash.dependencies import Input, Output
import dash_html_components as html
app = Dash(__name__)
app.scripts.config.serve_locally = True
app.layout = html.Div([
html.Button('B', 'btn'),
html.P('initial1', 'n1'),
html.P('initial2', 'n2'),
html.P('initial3', 'n3')
])
@app.callback([Output('n1', 'children'),
Output('n2', 'children'),
Output('n3', 'children')],
[Input('btn', 'n_clicks')])
def show_clicks(n):
# partial or complete cancelation of updates via no_update
return [
no_update if n and n > 4 else n,
no_update if n and n > 2 else n,
no_update
]
if __name__ == "__main__":
app.run_server(port=8070)
React 16
Updating to React 16 will enable the use of newer React functionalities like the in progress dev-tools feature.
The upgrade has two immediate side-effects:
- Any component still using
React.PropTypes
needs to use theprop-types
library instead as it’s been removed entirely - Components relying on thrown / uncaught exceptions for control flow will stop working correctly. Unhandled exceptions now causes the component or the entire app to not render