I am building something along the lines of https://github.com/plotly/dash-sample-apps/tree/master/apps/dash-object-detection. As a check i am printing the values to be plotted and they are working perfectly fine.However the graphs are not updating. The current code plots random values as a check of whether graphs update with the current time or not. Following is the snippet of the callback function:
@app.callback(Output(“bar-score-graph”, “figure”),
[Input(“interval-detection-mode”, “n_intervals”)],
[State(“video-display”, “currentTime”)])
def update_bargraphData(n_intervals, current_time):
layout = go.Layout(
showlegend=False,
paper_bgcolor=‘rgb(249,249,249)’,
plot_bgcolor=‘rgb(249,249,249)’,
xaxis={
‘automargin’: True,
},
yaxis={
‘title’: ‘Count’,
‘automargin’: True,
‘range’: [0, 1]
}
)
print(current_time)
if current_time is not None:
#print(current_time)
current_frame = round(current_time * FRAMERATE)
print("Current Time: ", current_frame)
#current_frame= 127628
print()
if n_intervals > 0 and current_frame > 0:
video_info_df = data_dict["video_info_df"]
total_people=video_info_df[video_info_df["frame"]<=current_frame].identity.nunique()
print("People passed: ", total_people)
# Select the subset of the dataset that correspond to the current frame
frame_df = video_info_df[video_info_df["frame"] == current_frame]
x_values = frame_df["identity"]
#(np.ones(len(x_values)).dtypes)
#x_values=x_values.values.tolist()
x_values = [random.randint(1,10) for i in range(10)]
#y_val2=len(x_values)
y_val=[]
for i in range(len(x_values)):
y_val.append(i)
print("Y Values:", y_val)
colors='#fa4f56'
print("X Values:", x_values) #, "Y Values :", y_values)
#figure = go.Figure(go.Bar(x=x_values, y=y_values, name='Trail'))
figure = go.Figure({
'data' : [{'type': 'bar',
'x': x_values,
'marker': {'color': colors},
'y': y_val}],
'layout' : {'title':'TEst'}
})
return figure