Hi,
Iām trying to display a KDE plot (or distplot) of a live stream of data coming from an MQTT broker using dash and plotly.
For performance reason Iām doing most of the stuff in client_side callback, and so far Iāve managed to plot in āreal timeā my data on a simple scatter graph.
Now Iām trying to use a distplot but I canāt find out the expected format of the trace my callback should return for the extendData property, I donāt even know if distplot support thatā¦ and donāt know where to look to find some info about it.
Here is the python code :
figure = ff.create_distplot([[0,1]], ["A"])
app.layout = html.Div([
dcc.Interval(id="graph_updater", interval=100),
dcc.Graph(id="graph", figure=figure)
])
clientside_callback(
ClientsideFunction(
namespace='clientside',
function_name='graph_updater'
),
Output('graph', 'extendData'),
Input('graph_updater', 'n_intervals')
)
And my client_side callback, do not worry about how I retrieve my SENSORS_DATA this is working fine :
window.dash_clientside = Object.assign({}, window.dash_clientside, {
clientside: {
graph_updater: function(n_interval) {
const sensor_path = "IMU_A";
if(window.SENSORS_DATA == null)
return window.dash_clientside.no_update;
if(!(sensor_path in window.SENSORS_DATA))
return window.dash_clientside.no_update;
if(window.LATEST_INDEX_GRAPHED == null)
window.LATEST_INDEX_GRAPHED = 0;
//Prepare the new data
nx = window.SENSORS_DATA[sensor_path]["timestamp"].slice(window.LATEST_INDEX_GRAPHED);
ny = window.SENSORS_DATA[sensor_path]["roll"].slice(window.LATEST_INDEX_GRAPHED);
window.LATEST_INDEX_GRAPHED = window.SENSORS_DATA[sensor_path]["timestamp"].length + 1; //Don't forget the +1 because the slice method is inclusive.
//Need to return a tuple (dict(graph data to extend), [trace_index], number of data point to keep)
return [{x: [ny]/*, y: [ny]*/}, [0], 5000];
}
}
});
I donāt know what to return in the client_side callbackā¦ for the moment itās not working and nothing change in the visualisation (but no error is thrown either).
Any help is appreciated, thanks !