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!

Extending trace in multiple graphs

 var $graphs=jQuery('#graphs');
var count=2;
socket.once('temp', function(temp){
  for (var i = 0, len = temp.length; i < len; i++) {
    jQuery('<div>', {
      'class': 'myDiv2',
      'id': 'myDiv' + count,
    }).appendTo($graphs);
    var x=document.getElementById('myDiv' + count);
    Plotly.newPlot(x, data, layout);
    count++;
  };
});


 setInterval(function(){
          var currentdate = new Date();
          var time =currentdate.getHours()%12 + ":" + currentdate.getMinutes() + ":" + currentdate.getSeconds() +  ":" + currentdate.getMilliseconds();
          var final=2;
          socket.once('temp', function(temp){
            for (var i = 0, len = temp.length; i < len; i++) {
              var x=document.getElementById('myDiv' + final);
              console.log(x);
              var update = {
                x: [[time]],
                y: [[temp[i]]]
              };
              Plotly.extendTraces(x, update, [0], points);
              final++;
            }
          });
        }, seconds*1000);

I am having a problem. I have a an array called temp which has values that i want to graph. For example if temp = [0,1,2], i want to graph element 0 on graph 1, element 1 on graph 2, and element 2 on graph 3. With the code above, all the elements are being graphed in all the graphs. Any idea??