-
-
Notifications
You must be signed in to change notification settings - Fork 51
Open
Description
This works:
import dash
import dash_html_components as html
from dash.dependencies import Input, Output
import dash_pivottable
app = dash.Dash(__name__)
app.layout = html.Div(
[html.Button("Rfresh", id="button"), html.Div(id="pivottable_div")]
)
@app.callback(Output("pivottable_div", "children"), [Input("button", "n_clicks")])
def refresh_pivottable(n_clicks):
if n_clicks:
print(n_clicks)
return [
html.Div(str(n_clicks)),
dash_pivottable.PivotTable(data=[["a"], [n_clicks]], cols=["a"])
if n_clicks % 2 == 1
else "a",
]
if __name__ == "__main__":
app.run_server(debug=False)This doesn't:
import dash
import dash_html_components as html
from dash.dependencies import Input, Output
import dash_pivottable
app = dash.Dash(__name__)
app.layout = html.Div(
[html.Button("Rfresh", id="button"), html.Div(id="pivottable_div")]
)
@app.callback(Output("pivottable_div", "children"), [Input("button", "n_clicks")])
def refresh_pivottable(n_clicks):
if n_clicks:
print(n_clicks)
return [
html.Div(str(n_clicks)),
dash_pivottable.PivotTable(data=[["a"], [n_clicks]], cols=["a"])
# if n_clicks % 2 == 1
# else "a",
]
if __name__ == "__main__":
app.run_server(debug=False)The only difference of them is the 2 commented lines.
My environment:
windows7 64bit
python3.7 64bit
dash 1.4.1
Please run the cases to see the difference. Many thanks.
Metadata
Metadata
Assignees
Labels
No labels