英文:
How do we access the value of dcc.store in plotly
问题
I am using dash by plotly to create a dashboard. I want to save a variable from one page so I can use it in another page. I am trying to use dcc.store for the same. But while trying to access it, I am getting the following error: Property "value" was used with component ID: "getComm" in one of the Input items of a callback. This ID is assigned to a dash_core_components. Store component in the layout, which does not support this property.
This is the code in my index file:
dcc.Store(id='getComm')
It's value is being written in page1.py
And I am trying to access it in the callback in page2.py:
@callback(
...
Input('getComm', 'value')
)
How do we access the value in another page?
英文:
I am using dash by plotly to create a dashboard. I want to save a variable from one page so I can use it in another page. I am trying to use dcc.store for the same. But while trying to access it, I am getting the following error: Property "value" was used with component ID: "getComm" in one of the Input items of a callback. This ID is assigned to a dash_core_components. Store component in the layout, which does not support this property.
This is the code in my index file:
dcc.Store(id='getComm')
It's value is being written in page1.py
And I am trying to access it in the callback in page2.py:
@callback(
...
Input('getComm', 'value')
)
How do we access the value in another page?
答案1
得分: 1
You need to use data
instead of value
(see Store Properties) :
@callback(
...
Input('getComm', 'data')
)
Also you might want to be specific about the storage_type
(defaults to 'memory'
), eg.
dcc.Store(id='getComm', storage_type='local')
Nb. You need to declare the dcc.Store
in the main app file (eg. app.py) so that you can refer to it as a callback Input/Output/State in any of the pages within the app. See for example this demo.
英文:
You need to use data
instead of value
(see Store Properties) :
@callback(
...
Input('getComm', 'data')
)
Also you might want to be specific about the storage_type
(defaults to 'memory'
), eg.
dcc.Store(id='getComm', storage_type='local')
Nb. You need to declare the dcc.Store
in the main app file (eg. app.py) so that you can refer to it as a callback Input/Output/State in any of the pages within the app. See for example this demo.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论