charts-plugin-streaming #6

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.20.1/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.1/Chart.min.js"></script>
<script src="https://rawgit.com/nagix/nagix.github.io/chartjs/chartjs-plugin-streaming.6.js"></script>
<canvas id="chart"></canvas>

JavaScript

var ctx = document.getElementById('chart').getContext('2d');
var chart = new Chart(ctx, {
  type: 'line',
  data: {
    datasets: [{
      data: []
    }, {
      data: []
    }]
  },
  options: {
    scales: {
      xAxes: [{
        type: 'realtime'
      }]
    },
    plugins: {
      streaming: {
        delay: 2000,
        frameRate: 30,
        onRefresh: onRefresh
      }
    },
    animation: {
      duration: 0
    },
    hover: {
      animationDuration: 0
    },
    responsiveAnimationDuration: 0
  }
});

function onRefresh(chart) {
  chart.data.datasets.forEach(function(dataset) {
    dataset.data.push({
      x: Date.now(),
      y: Math.random()
    });
  });
}