// Initial value for the position; center of the container
const angle = Ola(0, 1000);
// Double size and scale for better resolution
const canvas = document.querySelector("#graph");
canvas.width = window.innerWidth * 2;
const graph = new SmoothieChart({
grid: { strokeStyle: '#fff', fillStyle: '#fff' },
maxValue: 1,
minValue: 0,
// This makes it render a bit worse, but otherwise it's cheating
interpolation: 'step'
});
graph.streamTo(canvas, 1200);
const control = new TimeSeries();
const output = new TimeSeries();
// Add to SmoothieChart
graph.addTimeSeries(control, { strokeStyle: 'rgba(0, 0, 255, 0.3)' });
graph.addTimeSeries(output, { strokeStyle: 'rgba(255, 0, 0, 0.6)', lineWidth: 2 });
control.append(new Date(), 0);
(function tick() {
output.append(new Date(), angle.value);
requestAnimationFrame(tick);
})();
// Add a random value to each line every 1-2 seconds
(function update() {
const to = Math.random();
angle.value = to;
control.append(new Date(), to);
setTimeout(update, 1200);
})();
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Get Fiddle Pages with PRO
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.