【问题标题】:Plotly-Dash not showing list of graph elementsPlotly-Dash 未显示图形元素列表
【发布时间】:2021-11-14 14:34:15
【问题描述】:

如果我将dcc.Graph 元素硬编码在布局中:

app.layout = html.Div(
    html.Div([
        dcc.Graph(id='graph-hammer'),
        dcc.Graph(id='graph-saw'),
        dcc.Interval(id='interval-component', interval=1000, n_intervals=0)]))

我得到了我想要的 2 个没有问题的图表的结果。

但如果我使用append 创建一个dcc.Graph 元素列表:

list_graphs = []
for t in tools:
    list_graphs.append(html.Div(dcc.Graph(id='graph-' + t)))

app.layout = html.Div(
    html.Div([
        list_graphs,
        dcc.Interval(id='interval-component', interval=1000, n_intervals=0)]))

我得到一个空白屏幕,没有抛出任何错误。

将列表传递给布局时我做错了什么?

【问题讨论】:

    标签: python html arrays plotly plotly-dash


    【解决方案1】:

    解决方法是在列表前面添加*。例如:

    app.layout = html.Div(
        html.Div([
            *list_graphs,
            dcc.Interval(id='interval-component', interval=1000, n_intervals=0)]))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-06-25
      • 2022-07-30
      • 1970-01-01
      • 2022-08-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-16
      相关资源
      最近更新 更多