Hi,
I am trying to build a customized dashboard using plotly-dash which needs to get updated (automatically) whenever a new record is inserted into the MongoDB Atlas collection on the cloud. I was looking for examples online but could not find any. For example, lets assume the data that gets inserted into mongoDB (asynchronously at random time intervals) is a time series data like:
I understand that it is possible to set an interval to routinely update charts in dash, but is it possible to use pymongo.change_streams to watch for new insertions into the collection, and then automatically update the plotly charts or dataframe table in the dashboard.
Can anyone show a simple example of a plotly-dash line chart or may be a datatable that gets updated using plotly callbacks and pymongo.change_streams whenever a new record is inserted into a MongoDB collection?
One possible option would be to create a small data routing server (e.g. using Quart) that integrates with pymongo and exposes a websocket endpoint with the data, which is then read by a Websocket component in Dash.
Thanks but seems slightly roundabout task, Perhaps it should be possible with pymongo.change_streams itself. It seems someone has asked a similar question in stackoverflow but no reply from any plotly/mongoDB expert on this issue, so far?
To my knowledge, there is no native integration between Dash and pymongo streams. That’s why I suggested to use a web socket server as an adapter (unlike using e.g. an interval component, the web socket solution would in fact yield instant updates).
If you need a native integration, I believe the best approach would be to create a custom Dash component that takes care of the integration. If you are not too afraid of JavaScript/React it should be doable, but it’s a bit more work that the adapter solution, I would say.
I am trying to build a plotly-dash app that interfaces with a MongoDB collection where data is continuously written at asynchronous time intervals. The dash app needs to plot the equity field on the y-axis and time on the x-axis and also update the live streaming data on dash cards. But I don’t know how to connect this MongoDB ChangeStream websocket to Dash. Should I use quart or quart-motor package or the existing code in this mongodb tutorial would suffice with some minor modifications?
Would be grateful for any guidance or small working example, as information on the internet to setup websocket connection between mongoDB and Dash is very scarce?