我想调整由Pandas Dataframe创建的Dash表格中列的宽度。该表格有3列:
Path
Scenario
Step
我想将第一列(Path)的列宽设置为10%,第二列(Scenario)的列宽设置为40%,最后一列(Step)的列宽设置为50%。
我运行以下代码,但是列宽更改效果不如预期。 "Path"列占用了超过50%的宽度,而"Steps"列约占20%。 数据框名称为dfSteps。
我运行以下代码,但是列宽更改效果不如预期。 "Path"列占用了超过50%的宽度,而"Steps"列约占20%。 数据框名称为dfSteps。
columns=[{"name": i, "id": i} for i in dfSteps.columns],
data=dfSteps.to_dict('records'),
style_header={
'backgroundColor': 'rgb(230, 230, 230)',
'fontWeight': 'bold'
},
style_table={
'maxWidth': '2000px',
'overflowX': 'scroll',
'border': 'thin lightgrey solid'
},
style_cell={
'font_family': 'cursive',
'font_size': '16px',
'border': '1px solid grey',
'minWidth': '1px', 'width': 'fixed', 'maxWidth': '1000px',
'textAlign': 'left', 'whiteSpace': 'normal'
},
style_cell_conditional=[
{'if': {'column_id': 'Path'},
'width': '10%'},
{'if': {'column_id': 'Scenario'},
'width': '40%'},
{'if': {'column_id': 'Path'},
'width': '50%'},
],
),