Hi, I have contour plot running but I am not able to see the live updates. I also have other line plots and bar charts in the same page which are getting updated as new data comes in. I am reading a json file every 5 seconds. Can anyone please help me with it. I am also having a similar issue with a polar bar chart.
df_updated = pd.DataFrame()
app = dash.Dash(__name__)
app_color = {"graph_bg": "#082255", "graph_line": "#007ACE"}
app.layout = html.Div(
[
html.Div([
html.Div(
[html.H6("Contour Distribution", className="graph__title")]
),
dcc.Graph(id = 'contour-live-graph', animate = True),
dcc.Interval(
id = 'contour-graph-update',
interval = 5000,
n_intervals = 0
),
],
className="one-third column graph__container first" #wind__speed__container,
),
])
@app.callback(Output('contour-live-graph', 'figure'),[ Input('contour-graph-update', 'n_intervals') ])
def update_graph_contour(n):
# if file does not exist write header
# time.sleep(5)
df_json = pd.read_json('sample.json', lines = True)
print(df_json)
global df_updated
df_updated = df_updated.append(df_json,ignore_index = True)
df_updated = df_updated.drop_duplicates()
print("SDASDAD",df_updated)
if(len(df_updated)>1):
date_time_contour=list(df_updated['dateTime'])
df_bins = df_updated.iloc[:,2:26]
df_bins_log = (np.log(df_bins)).replace(-np.inf, np.finfo(float).eps)
list_bins = df_bins_log.values.tolist()
bin_boundries_high = [.46,.66,1,1.3,1.7,2.3,3.0,4.0,5.2,6.5,8,10,12,14,16,18,20,22,25,28,31,34,37,40]
bin_boundries_low = [0.35,.46,.66,1,1.3,1.7,2.3,3.0,4.0,5.2,6.5,8,10,12,14,16,18,20,22,25,28,31,34,37]
bin_boundries_avg_size = list(np.log((np.add(bin_boundries_high , bin_boundries_low))/2))
print("z",list_bins[0][0:5], len(list_bins[0]))
print("date",date_time_contour[0:5])
print("avg",bin_boundries_avg_size[0:2])
fig8 = go.Figure(data =
go.Contour(
z=list_bins,
x=date_time_contour,
y=bin_boundries_avg_size # vertical axis
))
fig8.update_layout(
xaxis_title="Date Time ",
yaxis_title="Size",
#plot_bgcolor=app_color["graph_bg"],
paper_bgcolor=app_color["graph_bg"],
font_color="white",
font=dict(
color="white"
)
)
return fig8