Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fun random LED chart
var columns = 200;
var ticker = document.getElementById("ticker");
for (var i = 0; i < columns; i++) {
addTickerColumn();
}
function addTickerColumn() {
var value = Math.floor(Math.random() * 5);
var column = document.createElement("div");
column.className = "ticker-column";
for (var j = 0; j < 6; j++) {
var cell = document.createElement("div");
if (j < value) {
cell.className = "ticker-cell dark";
} else {
cell.className = "ticker-cell";
}
column.appendChild(cell);
}
ticker.appendChild(column);
}
setInterval(function () {
addTickerColumn();
while (ticker.children.length > columns) {
ticker.removeChild(ticker.firstElementChild);
}
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment