Hi,
So glad here I can find the solution for flowchart in dash!
I’m trying to make it editable in the webpage.
But I can only see the chart in the first click.
After that, if I modify the text, the ‘flowchart-output’ will print the text.
I don’t know why. Can anyone help? Thank you~
from dash import Dash, dcc, html
from dash.dependencies import Input, Output, State
from dash_extensions import Mermaid
text = """
graph TD;
A-->B;
A-->C;
B-->D;
C-->D;
"""
app = Dash(__name__)
app.layout = html.Div([
dcc.Textarea(
id='textarea-state-example',
value=text,
style={'width': '100%', 'height': 200},
),
html.Button('Submit', id='textarea-state-example-button', n_clicks=0),
html.Div(id='flowchart-output'),
])
@app.callback(
Output('flowchart-output', 'children'),
Input('textarea-state-example-button', 'n_clicks'),
State('textarea-state-example', 'value')
)
def update_output(n_clicks, value):
if n_clicks > 0:
return Mermaid(chart=value)
if __name__ == '__main__':
app.run_server(debug=True)