1 回答
TA贡献1872条经验 获得超3个赞
该children属性基本上是一个列表,您可以先在通用循环中生成列表,然后将其添加到 Div 中。
这是工作片段,
import dash
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
import plotly.graph_objs as go
df1 = pd.DataFrame({"xaxis":["thing","otherthing","anotherthing"],"yaxis":[64,14,62]})
df2 = pd.DataFrame({"xaxis":["newthing","newotherthing","newanotherthing"],"yaxis":[344,554,112]})
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
output = []
#here you can define your logic on how many times you want to loop
for i in range(0,2):
output.append(dcc.Graph(id='example-graph'+str(i),figure={'data': [go.Bar(x=df1['xaxis'],y=df1[("yaxis")],name="yaxis")]}))
app.layout = html.Div(children=output)
if __name__ == '__main__':
app.run_server(debug=True)
添加回答
举报