Displaying regularly updating plotly graphs in Django webapp

I just want to know if this is possible with the free resources from Plotly. I am a student and want to build a project where I…

  1. Call an API for JSON data every 6 seconds.
  2. Work that data into a Dataframe that updates with every API response.
  3. Informs a graph that updates each time the new data is received.
  4. Put that stuff into a Django app and deploy it

So far, I have completed steps 1 and 2, and I was able to put 1 API-response-worth of data into a plotly express graph on google colab. Here is a link where my API data is replaced by random numbers, it runs inside a for loop to simulate the intervalic API call, but it creates new graphs instead of updating the original graph: Google Colab

I’m just hoping for some guidance on:

  • integrating Plotly with Django
  • creating a graph that updates live while I run my loop calling API data (and how this would work on a live website)
  • if I can do all this with the free libraries (again, this is a school project).

Thanks!

Hi,

Does it have to use Django? If not, would you consider this very nice webapp framework, which is very suitable for Plotly charts? :smiley:

Haha, I see your angle here and I respect it. I will certainly be branching out to learning Dash, but for now, I’m need this to be be a plotly graph inside a Django app.

If there is one thing I would really love some help on here (just to narrow the scope of this question), it would be this:
How can I do a live-updating graph in plotly that maintains a 1-hour x-axis, using my API response’s streaming data? Any insight on this would be greatly appreciated!

That’s ok! About your specifc question: if you are doing the front-end with Plotly.js, you can use Plotly.extendTraces to add points to your chart without updating it entirely.

Thank you for this idea. I’m doing everything in python (through Django). I’ll do some more research and see what I can find.

1 Like