我一直试图用巧妙的破折号进行可视化,并希望尝试第一个应用程序的例子,从网站文档。我复制并粘贴了大部分代码,并确保了正确的缩进,但似乎始终在括号中出现错误。有什么建议吗?
import dash
import dash_core_components as dcc
import dash_html_components as html
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
app.layout = html.Div(children=[
html.H1(children='Hello Dash'),
html.Div(children='''
Dash: A web application framework for Python.
'''),
dcc.Graph(
id='example-graph',
figure={
'data': [
{'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'bar', 'name':
{'x': [1, 2, 3], 'y': [2, 4, 5], 'type': 'bar', 'name':
],
'layout': {
'title': 'Dash Data Visualization'
}
}
)
])
if __name__ == '__main__':
app.run_server(debug=True)
发布于 2022-03-26 09:02:43
我已就括号没有关闭的地方发表意见。另外,您还缺少了"name"
的值。我也对此发表了意见。P
指括号()
,C
指圆括号{}
,S
指方括号[]
。
import dash
import dash_core_components as dcc
import dash_html_components as html
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
app.layout = html.Div(children=[ #P1 open, S1 open
html.H1(children='Hello Dash'), # P2 open, P2 closed
html.Div(children='''
Dash: A web application framework for Python.
'''), # P3 open, P3 closed
dcc.Graph( #P4 open
id='example-graph',
figure={ #C1 open
'data': [ # S2 open
{'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'bar', 'name':# You are missing name parameter here; Also C2 open; You are not closing this curly braces
{'x': [1, 2, 3], 'y': [2, 4, 5], 'type': 'bar', 'name':# You are missing name parameter here; Also C3 open; You are not closing this curly braces
], #S2 closed
'layout': { #C4 open
'title': 'Dash Data Visualization'
} # C4 closed
} # C1 closed
) # P4 closed
])#S1 closed, P1 closed
if __name__ == '__main__':
app.run_server(debug=True) # this need to be indented
https://stackoverflow.com/questions/71626452
复制相似问题