Hi guys. I have the problem with clientside_callback. clientside_callback doesn’t update dcc.Grpaph. There is a dcc.Store, which get data from the graph.
app.clientside_callback(
"""
function(slider_smooth, log_data) {
console.log(slider_smooth)
if(log_data?.data === undefined) {
return {'data': [], 'layout': {}};
}
let count = 0;
let prevA = 0;
let prevF = 0;
let newF = 0;
let alfa = slider_smooth
for(i=0; i < log_data.data[1].y.length; i++) {
if(log_data.data[1].y[i] == null) {
continue;
} else {
if (count == 0) {
prevA = log_data.data[1].y[i];
prevF = log_data.data[1].y[i];
newF = log_data.data[1].y[i];
} else {
newF = prevF + alfa * (prevA - prevF);
prevF = newF;
prevA = log_data.data[1].y[i];
log_data.data[1].y[i] = newF;
console.log(newF)
}
count++;
}
}
const newObject = Object.assign({}, log_data);
return newObject
}
""",
Output('log_graph', 'figure'),
Input('slider_smooth', 'value'),
Input('clientside_log_store', 'data')
)
dcc.Store(id='clientside_log_store'),
dcc.Graph(id="log_graph",
config={
"modeBarButtonsToAdd": [
"drawline",
"drawcircle",
"drawrect",
"eraseshape",
],
"editable": True,
"watermark": False
},
figure={
"layout": {
"title": "dP/dg",
"height": 700, # px
"width": 1800
},
},
style={
'width': '90vh'
}
),
dcc.Slider(
id='slider_smooth',
step=None,
value=0.1,
marks={
0.001: {'label': '0.001', 'style': {'color': '#77b0b1'}},
0.005: {'label': '0.005'},
0.01: {'label': '0.01'},
0.05: {'label': '0.05'},
0.1: {'label': '0.1'},
0.2: {'label': '0.2'},
0.3: {'label': '0.3'},
0.4: {'label': '0.4'},
0.5: {'label': '0.5'},
0.6: {'label': '0.6'},
0.7: {'label': '0.7'},
0.8: {'label': '0.8'},
0.9: {'label': '0.9'},
1: {'label': '1', 'style': {'color': '#f50'}},
},
min=0.001,
max=1,
included=False
),