首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >调整绘图-虚线表列宽

调整绘图-虚线表列宽
EN

Stack Overflow用户
提问于 2021-01-30 15:18:57
回答 1查看 2.7K关注 0票数 1

我想调整Dash表(从Pandas Dataframe创建)中列的宽度。表中有3列:路径方案步骤

我想将第一列(路径)的列宽设置为10%,将第二列(方案)的列宽设置为40%,将最后一列(步骤)的列宽设置为50%。

我正在运行下面的代码,但是列宽的更改并没有像预期的那样起作用。"Path“列占用了超过50%的宽度,而"Steps”列占用了大约20%的宽度。数据帧名称为dfSteps

代码语言:javascript
运行
复制
                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%'},
                ],
        ),
EN

回答 1

Stack Overflow用户

发布于 2021-02-01 05:50:48

只需按照documentation https://plotly.com/python/table/中的建议重新定义您的表

代码语言:javascript
运行
复制
fig = go.Figure(data=[go.Table(
  columnorder = [1,2],
  columnwidth = [80,400],
  header = dict(
    values = [['<b>EXPENSES</b><br>as of July 2017'],
                  ['<b>DESCRIPTION</b>']],
    line_color='darkslategray',
    fill_color='royalblue',
    align=['left','center'],
    font=dict(color='white', size=12),
    height=40
  ),
  cells=dict(
    values=values,
    line_color='darkslategray',
    fill=dict(color=['paleturquoise', 'white']),
    align=['left', 'center'],
    font_size=12,
    height=30)
    )
])
fig.show()
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65965585

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档