I’ve created a customized react component to visualize a special chart(invention for a client), then i use it in the dash app.
This component asks an array of dictionaries, then visualizes the desired chart.
In some cases, the flask argues to send the response to the client side, but when you check in the browser there are no responses and the page is always in loading.
in the react js code, the component works well and I test it and it doesn’t matter.
Now the question is why does Flask serve responses partially, it sends json files to the browser and there is no js file to elaborate the data?
Yes, nothing error, here i send the call back an other codes i use.
Of course i skip all the codes.
def fetch_radiant_data(client):
return get_products(config, client)
layout = html.Div([
dbc.Spinner(
[
dcc.Loading(
id='radiant-chart-loading',
children=[
html.Div(id='radiant-chart-content')
]
)
],
color="primary",
type="grow",
id="loading-spinner",
)
])
def get_radiant_chart(client, products_data):
try:
return html.Div(
style={'display': 'flex', 'justifyContent': 'center'},
children=[
rcc.CitsComponent(
size=1000,
id='cits-'+client.replace(' ', '-'),
title='Radiant Chart',
domains=domains,
arcs=arcs,
products=products_data
),
],
)
except Exception as e:
print(f"Error in get_radiant_chart for client {client}: {e}")
return html.Div("Error in rendering the Radiant Chart.")
@app.callback(
Output('radiant-chart-content', 'children'),
Input('tabs-example-graph', 'value'),
)
def render_radiant_chart(tab):
if 'radiant' in tab:
client = tab
products_data = fetch_radiant_data(client)
return get_radiant_chart(client, products_data)
else:
raise PreventUpdate```
When the code passes from ```return get_radiant_chart(client, products_data)```
always in loading nothing to show in the browser.
But in some cases are OK, some of them no. there is no response from flask!!!!
However in all time the react js visualize the chart perfectly.
Thanks.