我有一个带按钮的html模板。假设它是非常重要的模板,我们不想重新制作它。它包含一个按钮和一些日期输入。
另一方面,我有破折号应用程序,其布局中仅包含一个图表。
我想要的是根据模板中的外部输入而不是破折号布局更新此图表。
模板:
<!--Template-->
{%config%}
<input type="datetime-local" name="dateTimeLocalStart" id=SelectionFrom/>
<input type="datetime-local" name="dateTimeLocalEnd" id=SelectionTo/>
<button type="button" id="show_new_data">SHOW</button>
{%app_entry%}
{%scripts%}
{%renderer%}
破折号布局:
app.index_string = template_file.read() # is this a way?
# the basic dash layout
app.layout = html.Div(children=[
dcc.Graph(
id='example-graph',
figure={
'data': [
{'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'bar', 'name': 'SF'},
{'x': [1, 2, 3], 'y': [2, 4, 5], 'type': 'bar', 'name': 'Mo'},
],
'layout': {
'title': 'Dash Data Visualization'
}
}
)
])
但是如果我尝试像这样用破折号回调它
@app.callback(
Output(component_id="example-graph", component_property="figure"),
[Input(component_id="show_new_data", component_property="id")]
)
def update_graph():
print("Update graph callback")
return "" # this never happens
我希望回调可以工作,但得到这个:
dash.exceptions.NonExistentIdException:
Attempting to assign a callback to the
component with the id "show_new_data" but no
components with id "show_new_data" exist in the
app's layout.
- 那么,有没有办法让它工作呢?
- 使用Iframe可以吗?
- 或者也许可以以某种方式将此输入链接到破折号布局?
对不起,破折号新手,文档不是那么简单。
据我挖掘出来,在 0.41.0 版中还不可能
达世币需要达世币组件在其回调中使用,尽我所能 知识。如果您尝试使用未专门设置的组件 作为达世币组件,那么它就不会挂接到底层 反应代码。– @coralvanda