JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://people.iola.dk/olau/flot/jquery.flot.js"></script>
<h1>Flot Examples</h1>
<div id="placeholder" style="width:600px;height:300px;"></div>
JavaScript
$(function() {
var options = {
lines: {
show: true
},
points: {
show: true
},
// xaxis: { tickDecimals: 0, tickSize: 1 }
};
var data = [[]];
$.plot($("#placeholder"), data, options);
console.log(data[0]);
function update() {
var val = Math.floor(Math.random() * 11);
var time = new Date().getTime();
var datum = [time, val];
data[0].push(datum);
if(data[0].length>10){
data[0] = data[0].splice(1);
}
console.log(data[0]);
$.plot($("#placeholder"), data, options);
}
setInterval(update, 1000);
});