使列宽适合数据,并在DASH DATATABLE中
我实际上正在使用破折号,但还没有找到任何方法来正确设置适合内容的列宽度。 因为当我将fill_width设置为false时,宽度适合数据,但不适合标题,并且在我的某些列中,标题比数据宽。
有什么正确的解决方法吗?预先感谢
NB:我的代码,即使我认为这没有什么帮助:
# Dashboard
html.Div(id="table", children=[
dash_table.DataTable(
style_header={
'backgroundColor': colors['bg_board'],
'color': colors['text_category'],
'fontWeight': 'bold'
},
style_cell={
'textAlign': 'center'
},
style_cell_conditional=[
{
'if': {'column_id': 'Maturity'},
'backgroundColor': colors['bg_board'],
'color': colors['text_category'],
}
],
style_table={
'overflowY': 'auto',
'overflowX': 'auto'
},
fixed_rows={'headers': True},
fixed_columns={'headers': True},
id='tbl'
)
]),
“数据”是在回调中设置的,但这只是一个简单的数据帧。
I am using Dash actually but havent found any way to properly set column width adapted to the content.
Because when I set fill_width to False, the width fits to the datas but not to the header and on some of my columns the header is wider than the datas.
Any proper way to fix this ? Thank you in advance
NB : my code, even if I think it is not that helpful:
# Dashboard
html.Div(id="table", children=[
dash_table.DataTable(
style_header={
'backgroundColor': colors['bg_board'],
'color': colors['text_category'],
'fontWeight': 'bold'
},
style_cell={
'textAlign': 'center'
},
style_cell_conditional=[
{
'if': {'column_id': 'Maturity'},
'backgroundColor': colors['bg_board'],
'color': colors['text_category'],
}
],
style_table={
'overflowY': 'auto',
'overflowX': 'auto'
},
fixed_rows={'headers': True},
fixed_columns={'headers': True},
id='tbl'
)
]),
'data' is set in a callback but it is just a simple dataframe.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我正在使用以下代码来造型我的冲刺。希望这有所帮助:
I'm using below code to style my dashtable. Hope this help: