Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dash Table that can auto scroll

I am wondering if there is a way that you can have a dash table scroll vertically up and down automatically when the scroll bar is available.

This is a simple example (I used the same dataframe 7 times to make it long enough).

import dash
import dash_table
import pandas as pd

df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/solar.csv')
long_data = pd.concat([df,df,df,df,df,df,df])

app = dash.Dash(__name__)

app.layout = dash_table.DataTable(
    id='table',
    columns=[{"name": i, "id": i} for i in long_data.columns],
    data=long_data.to_dict('records'),
)

if __name__ == '__main__':
    app.run_server(debug=False)

Is there a way to make what's on this page go vertically up and down?

like image 858
callawayh Avatar asked Nov 06 '22 10:11

callawayh


1 Answers

I'm not sure if this is what you're looking for, but you can make the table scrollable via style_table (reference):

app.layout = dash_table.DataTable(
    id='table',
    columns=[{"name": i, "id": i} for i in long_data.columns],
    data=long_data.to_dict('records'),
    style_table={
        'overflowY': 'scroll'
    }
)

If you're looking to have the table scroll automatically at a given speed, I doubt dash/plotly has in-built functionality to do that.

like image 116
Jay Mody Avatar answered Nov 12 '22 10:11

Jay Mody