【问题标题】:Plotly-Dash: How to span a component across two rowsPlotly-Dash:如何跨两行跨越组件
【发布时间】:2021-09-01 08:38:32
【问题描述】:

我正在尝试使用破折号和引导网格创建仪表板。这是我想要实现的目标:

根据文档 (https://dash-bootstrap-components.opensource.faculty.ai/docs/components/layout/) 我可以在行中创建列,但是有没有办法在列中创建行?我需要我的图表跨越先前列的两个“行”。我认为这可以通过以下方式实现:

dbc.Col([dbc.Row([content]),dbc.Row([content]),dbc.Row([content])]),
dbc.Col([dbc.Row([content]),dbc.Row([content]),dbc.Row([content])]),
dbc.Col([dbc.Row([content]),dbc.Row([content])])

但是,这些列只是堆叠在一起。这是我前两列的代码:

    app.layout =   dbc.Col([
    dbc.Col([ html.H1("temp1",style={'textAlign': 'center' ,'height':'5%','margin-top': '30px', 'margin-bottom': '25px','font-family': 'Consolas'}),
                        dbc.Card(
                            [
                                dbc.CardBody(
                                    [
                                        html.H4(id='card_title_1', children=['Sales'], className='card-title'),
                                        html.P(id='card_text_1', children=['Sample text.'])
                                    ], style={'textAlign': 'center','font-family': 'Consolas'}
                                )
                            ], style={'margin-top': '15px', 'margin-bottom': '15px','height':'30%'}
                        ),
                        dbc.Card(
                            [
                                dbc.CardBody(
                                    [
                                        html.H4(id='card_title_2', children=['Eng'], className='card-title'),
                                        html.P(id='card_text_2', children=['Sample text.']),
                                    ], style={'textAlign': 'center','font-family': 'Consolas'}
                                )
                            ], style={'margin-top': '15px', 'margin-bottom': '15px','height': '30%'}
                        ),
                        dbc.Card(
                            [
                                dbc.CardBody(
                                    [
                                        html.H4(id='card_title_3', children=['Diff'], className='card-title'),
                                        html.P(id='card_text_3', children=['Sample text.']),
                                    ], style={'textAlign': 'center','font-family': 'Consolas'}
                                )
                            ], style={'margin-top': '15px', 'margin-bottom': '15px','height': '30%'}
                        ),
                    ], style={'height': '90vh','width':'50vh'}),


    dbc.Col([ html.H1("temp2",style={'textAlign': 'center' ,'height': '5%','margin-top': '30px', 'margin-bottom': '25px','font-family': 'Consolas'}),
                        dbc.Card(
                            [
                                dbc.CardBody(
                                    [
                                        html.H4(id='card_title_4', children=['Card Title 4'], className='card-title'),
                                        html.P(id='card_text_4', children=['Sample text.']),
                                    ], style={'textAlign': 'center','font-family': 'Consolas'}
                                )
                            ], style={'margin-top': '15px', 'margin-bottom': '15px','height': '30%'}
                        ),
                        dbc.Card(
                            [
                                dbc.CardBody(
                                    [
                                        html.H4(id='card_title_5', children=['Card Title 5'], className='card-title'),
                                        html.P(id='card_text_5', children=['Sample text.']),
                                    ], style={'textAlign': 'center','font-family': 'Consolas'}
                                )
                            ], style={'margin-top': '15px', 'margin-bottom': '15px','height': '30%'}
                        ),
                        dbc.Card(
                            [
                                dbc.CardBody(
                                    [
                                        html.H4(id='card_title_6', children=['Card Title 6'], className='card-title'),
                                        html.P(id='card_text_6', children=['Sample text.']),
                                    ], style={'textAlign': 'center','font-family': 'Consolas'}
                                )
                            ], style={'margin-top': '15px', 'margin-bottom': '15px','height': '30%'}
                        ),
                    ], style={'height': '90vh','width':'50vh'}),
], style={'height': '100vh', 'width':'100vh'})

【问题讨论】:

    标签: python python-3.x plotly-dash dashboard


    【解决方案1】:

    我可以通过将 dbc.Col 放置在 html.Div 中然后给每个 dbc.Col 一个 CSS style = 'display : inline-block' 来解决这个问题。

    【讨论】:

    • 能把代码分享给解决方案吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-01-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-23
    相关资源
    最近更新 更多