title: How draw an ECG wave with a static range in real time?
body: <p>I´m drawing an real time ECG Wave with CanvasJs ,all works good if I use the size of the array, but when I try to set that size for example 478 points this doesn't show the new data who is coming, the chart is static but I´m sending new data. </p>
  
  <p><a href="https://i.stack.imgur.com/woFp7.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/woFp7.jpg" alt="ECG wave"></a></p>
  
  <p>The code for that chart is the next one : </p>
  
  <pre><code> maxDataLength = 478;
   dataLenght = 0;
  
     if (result.length !== maxDataLength) {
          for (var i = dataLength; i &lt; result.length; i++)
              {
                  data.push({
                      x: parseInt(result[i].valorx),
                      y: parseFloat(result[i].valory)
                  });
                 if (data.length &gt; maxDataLength) {
                 data.shift()}
              }
              dataLength = result.length;
              chart.render();
          }
    });
  </code></pre>
  
  <p>The problem is that the chart is not loading the new data.</p>
  
  <p>The next code works for me : </p>
  
  <pre><code>dataLength = 0;
  
  if (dataLength !== result.length) {
    for (var i = dataLength; i &lt; result.length; i++) 
          {
              data.push({
                  x: parseInt(result[i].valorx),
                  y: parseFloat(result[i].valory)
              });
             if (data.length &gt; result.length) {
             data.shift()}
          }
          dataLength = result.length;
          chart.render();
      }
  });
  </code></pre>
  
  <p>But this graph show all the data of the array and looks awful, If you know how solve this task, please let me know.</p>