I had a dash app working with an old version but now is not working properly since I updated to Dash 1.0.0
The problem seems to be with the datatable. It is no longer displaying data nor is editable. I’m struggling to work out why because it seems to work when I am debugging it in pycharm by stepping through each line.
But when I run the app the table doesn’t display anything. Any ideas why it is no longer working? or what more info do you need from me to diagnose the problem?
This is how I am initialising it:
import dash
import dash_html_components as html
import dash_table
import dash_core_components as dcc
def serve_layout():
# layout function so that the data refreshes on page load
layout = html.Div([
dash_table.DataTable(
id='sec_table',
columns=[{'name': i, 'id': i} if i != 'Security Type'
else {'name': i, 'id': i, 'presentation': 'dropdown'} for i in fields],
data=[dict(**{field: '' for field in fields})],
dropdown={
'Security Type': {'options': [{'label': i, 'value': i} for i in ['OS', 'CO', 'PO']]}
},
editable=True,
row_deletable=True,
data_timestamp=0,
),
# option payoff chart
dcc.Graph(
id='payoff_graph',
style={'height': 700},
)
])
return layout
# declare global variables
fields = ['Security', 'Security Type', 'Unit Holding', 'Lot Size', 'Expiry Date', 'Market Price', 'Excercise Price',
'Average Cost', 'Total Cost']
app = dash.Dash(__name__)
app.layout = serve_layout
# callback function to display row data on table
@app.callback(
dash.dependencies.Output('sec_table', 'data'),
[dash.dependencies.Input('sec_table', 'data_timestamp')],
[dash.dependencies.State('sec_table', 'data'),
dash.dependencies.State('sec_table', 'columns')]
)
def display_rows(edit_table_time, rows, columns):
pass
# chart callback function breaks the app
@app.callback(
dash.dependencies.Output('payoff_graph', 'figure'),
[dash.dependencies.Input('sec_table', 'data')]
)
def update_chart(drop_down_time):
return {}
if __name__ == '__main__':
app.run_server(debug=True)