首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用1行破折号绘制2张图表时出错

用1行破折号绘制2张图表时出错
EN

Stack Overflow用户
提问于 2022-03-16 06:15:36
回答 1查看 235关注 0票数 0

我正在尝试构建一个仪表板,它显示了同一行的两个图表。我使用dbc.Rowdbc.Col来划分部分,但我不确定代码有什么问题,因为图表是在彼此之上显示,而不是并排显示。我尝试过添加style={"width": "45%", "margin-top": "1%","margin-left": "0%", "margin-right": "0%"},与第二个图表相反,但仍然只是在不同的行上显示图表。

代码语言:javascript
复制
html.Div([
    dbc.Row([
        dbc.Col(
            html.Div([
                dcc.Dropdown(id='dropdown-1', multi=True, value=('EC'),
                             options=[{'label': x, 'value': x}
                                      for x in sorted(dfdate['Campaign'].unique())]),
                dcc.Graph(id='date-graph', figure=fig_cpa_date),
            ]), width={'size': 3}
        ),
        dbc.Col(
            html.Div([
                dcc.Dropdown(id='dropdown-2', multi=True, value=('EC'), style={"margin-top": "1%"},
                             options=[{'label': x, 'value': x}
                                      for x in sorted(dfdate['Campaign'].unique())]),
                dcc.Graph(id='spend-graph', figure=fig_spend),
            ]), width={'size': 3}
        ),
    ]),
])
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-03-16 09:43:21

尝试这样做,只为Col的html.Div([])更改children[]:

代码语言:javascript
复制
dbc.Row([
    dbc.Col(
        children=[
                    dcc.Dropdown(id='dropdown-1', multi=True, value = ('EC'),
                    options= [{'label': x, 'value': x} 
                    for x in sorted (dfdate['Campaign'].unique())]),
                    dcc.Graph(id='date-graph', figure=fig_cpa_date),
                ], width=3
            ),
    dbc.Col(
        children=[
                    dcc.Dropdown(id='dropdown-2', multi=True, value=('EC'), style={"margin-top": "1%"},
                    options=[{'label': x, 'value': x}
                    for x in sorted(dfdate['Campaign'].unique())]),
                    dcc.Graph(id='spend-graph', figure=fig_spend),
                ], width=3
            ),
        ]),
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71492516

复制
相关文章

相似问题

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