Hi there,
I have tried to implement the functions included in the dash-table-experiments/usage.py
file and customise it for my purposes.
However, one problem I am experiencing is that the interaction between table and linked chart is only limited to marker color (which I copied from the example). This means that sorting or filtering data in the table does not trigger any action in the chart.
My callbacks are as follows (the objects 'datatable-gapminder'
and 'graph-gapminder'
from the usage.py
example have been replaced by 'acr_table' and 'acr_chart
respectively):
@app.callback(
Output('acr_table', 'selected_row_indices'),
[Input('acr_graph', 'clickData')],
[State('acr_table', 'selected_row_indices')])
def update_selected_row_indices(clickData, selected_row_indices):
if clickData:
for point in clickData['points']:
if point['pointNumber'] in selected_row_indices:
selected_row_indices.remove(point['pointNumber'])
else:
selected_row_indices.append(point['pointNumber'])
return selected_row_indices
@app.callback(
Output('acr_graph', 'figure'),
[Input('acr_table', 'rows'), Input('acr_table', 'selected_row_indices')])
def update_figure(rows, selected_row_indices):
dff = pd.DataFrame(rows)
data=go.Data([])
marker = {'color': ['#0074D9']*len(dff)}
for i in (selected_row_indices or []):
marker['color'][i] = '#FF851B'
data.append(
go.Bar(
x = df_acr['BD1_HA26p_occ'],
y = df_acr['job_id_short'],
orientation='h',
marker = marker,
),
),
figure = go.Figure(
data=data,
# layout=layout,
)
return figure