Hello, I am creating an dash app that is interactive displaying information about my data. I have a table uploaded from different instruments but now I want to display information for each instrument like say we 10 rows for given instrument. how can I display that text
Initial response was posted before it was complete…hence the delete…
This is a good resource: https://dash.plot.ly/datatable
Dash datatables have the following properties. The style header
lets you alter the headers style differently than the table body. The merge_duplicate_headers
collapses (Excel’s merge cell equivalent) columns with equal content into one so it appears as one cell (explained below).
html.Div(children=[dash_table.DataTable(
...,
style_header={ 'backgroundColor': 'white',
'fontWeight': 'bold', 'fontSize':16,
'font-family':'sans-serif', },
merge_duplicate_headers=True,
...]
)
Within a callback, set the column names (via the columns
DataTable parameter) to the same value. In the example below, the data column ids are a
, b
, c
, etc hence the chr(97+c)
- change this to your column id. Also, this example has a table with 14 columns as indicated in range(0,14)
. For multiple rows in the header, just modify the name
component accordingly.
@app.callback(output=[Output('your-datatable', 'columns')],
inputs=...)
def create_datatable(arg1, arg2, ...):
...your code..
# Populate all 14 rows of the header with the same info...which will be merged into one by Dash
columns_headers = [{'id': chr(97+c), 'name': [title_row_1, title_row_2]} for c in range(0,14)]
return column_headers
Hope this helps!
I don’t understand what you mean by column ids, what are they in this case that you are using ch(97+c)
The resource I provided shows examples of the datatable
id’s. In my case, they are lower case letters of the alphabet, starting with a
(which is chr(97+c)
) (see https://docs.python.org/3/library/functions.html#chr)