✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🐇 Announcing Dash VTK for 3d simulation graphics. Check out the March webinar.

Updating App Callback from Auto Zoom Feature in Graphs

Hello

New to the forum, somewhat new to Dash, not new to Python. First, great library overall. Second, I built a relatively basic app that plots points and an average over time. Along with the graph, it outputs a DataTable of rows and columns built from a Pandas dataframe. I really like that built into Dash you can zoom into any given section of the graph. Is there a way that when you zoom in to particular section that the table can be updated to just the section zoomed in on?

Without the graph stuff, my code is as follows:

app.layout = html.Div([        
        html.Div(children=[
        html.H2('Text Input'),
        dcc.Textarea(id='searchId', value='Enter Search Term'),
        html.Button('Submit', id='button', n_clicks=0),
        dcc.Graph(id='time', figure='fig'),
        dash_table.DataTable(style_cell={
                'whiteSpace': 'normal',
                'height': 'auto',
                'textAlign': 'left'
                }, id='outTable')
        ]),
])


@app.callback(
    [Output(component_id='outTable', component_property='data'),
     Output(component_id='outTable', component_property='columns'),
     Output(component_id='time', component_property='figure')],        
    [Input(component_id='button', component_property='n_clicks')],
    [State('searchId', 'value')]
)    
        
def update_output(n_clicks, value):
    if n_clicks > 0:
        with index.searcher() as searcher:
            parser = QueryParser("content", index.schema)
            myquery = parser.parse(value)
            results = searcher.search(myquery, limit=None)
            #print(results[0:10])
            print("Documents Containing ", value, ": ", len(results), "\n")
            
            df = pd.DataFrame([i['date'], i['site'], i['ticket'], i.score, i['docId'],i['content']] for i in results)
            df.columns=['Reported Date', 'Site','Ticket ID', 'Score', 'Document ID', 'Content']
            
###################### Table ##############################################
            columns = [{'name': col, 'id': col} for col in df.columns]
            data = df.to_dict(orient='records')    

Thank you