Black Lives Matter. Please consider donating to Black Girls Code today.
Learn how to use COVID-19 data in open source Dash apps. Register for the Sept 23rd webinar with IQT!

Live Streaming Plot with Ajax Request not showing data points

I am using the code below to plot a live updating graph. The function ajax function works and is returning the data I need. i used some alert statements in javascript to debug. I dont know why the data is not appearing in the plot. If anyone has insight that would be fantastic!

function data_retrieve(){
$.getJSON($SCRIPT_ROOT + ‘/data_upload’, function(result) {

var time = new Date();
var layout = {

var data = [{
x: [time],
y: [data_retrieve()],
mode: ‘lines’,
line: {color: ‘#80CAF6’}

Plotly.newPlot(‘ph_graph’, data, layout);

var cnt = 0;

var interval = setInterval(function() {

var time = new Date();

var update = {
x: [[time]],
y: [[data_retrieve()]],

Plotly.extendTraces(‘ph_graph’, update, [0])

if(++cnt === 100) clearInterval(interval);
}, 1000*10);