Hi @Emmanuelle, thank you for your answer. Sorry, I was not very clear.
The problem is that I need something more general but effectively in the spirit of
go.Figure(json_dict), that is, a method that receives a
json_dict as input to generate html components. I am using tabs, so my goal is two solve the issue of changing tabs and keeping the generated content. Below an simple example of what I want to do:
import dash_bootstrap_components as dbc
import dash_html_components as html
from dash.dependencies import Input, Output
tab1_content = Div("simple content")
result = big_computation_here()
# Result looks like this: [P("result line 1"), P(["result line 2", Mark("highlighted token")])]
tabs = html.Div(
dbc.Tab(label="Tab 1", tab_id="tab-1"),
dbc.Tab(label="Tab 2", tab_id="tab-2"),
@app.callback(Output("content", "children"), [Input("tabs", "active_tab")])
if at == "tab-1":
elif at == "tab-2":
tab2_content = some_big_computation()
return html.P("This shouldn't ever be displayed...")
I would like to store
tab2_content, which is a list of Paragraphs (
P objects) with Markers sometimes. I could indeed store the content of these objects but it would be very cumbersome as they themselves come from a list of complex objects (list of FlairNLP Sentences). So I could try to serialize the content of this
Sentence list but it would be more cumbersome I believe.
In any case, I thought the
Component method would have some sort of inverse function (such as
from_plotly_json) but I could not find it.
So in the end, I am building a pair of functions to serialize and de-serialize a component. I would like to know if it is good practice, as maybe there is a more appropriate way of doing what I want (given that I could not find a lot of resources about the topic. This comes very close Serialising/Deserialising Dash components).
Thank you again!