Public
Edited
Oct 24, 2022
Fork of waffle chart
1 fork
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function render () {
const sel = d3.select(vis)
let now = new Date()
// render time labels
let hours = now.getHours()
let minutes = now.getMinutes()
let seconds = now.getSeconds()
sel.select('.time-hour').text(hours + ' hrs')
sel.select('.time-minutes').text(minutes + ' mins')
sel.select('.time-seconds').text(seconds + ' secs')
// render percent labels
let hoursPercent = Math.floor((100 / 24) * hours)
let minutesPercent = Math.floor((100 / 60) * minutes)
let secondsPercent = Math.floor((100 / 60) * seconds)
sel.select('.percent-hour').text(hoursPercent + ' %')
sel.select('.percent-minutes').text(minutesPercent + ' %')
sel.select('.percent-seconds').text(secondsPercent + ' %')
// render charts
waffle(hoursPercent, {
bind: sel.select('.chart-hours'),
squareCol: '#a6d40d'
})
waffle(minutesPercent, {
bind: sel.select('.chart-minutes'),
squareCol: '#a6d40d'
})
waffle(secondsPercent, {
bind: sel.select('.chart-seconds'),
squareCol: '#ff5ec4'
})
}


Insert cell
Insert cell
Insert cell
<hr>
<link href="https://fonts.googleapis.com/css?family=Space+Mono" rel="stylesheet">
<link href="https://unpkg.com/basscss@8.0.2/css/basscss.min.css" rel="stylesheet">
<style>
.charts, .digits {
width: 800px;
font-family:'Space Mono',monospace;
}
.colon {
color:#e0e5db;
font-size: 72px;
right: -2px;
}
.charts .colon {
top: 60px
}
.digits .colon {
top: -50px;
}
.digit {
color: #454545;
font-weight: normal;
}
</style>
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more