33 lines
711 B
JavaScript
33 lines
711 B
JavaScript
import * as WebStat from "./webstat.mjs"
|
|
|
|
const Millisecond = 1
|
|
const Second = 1000 * Millisecond
|
|
const Minute = 60 * Second
|
|
|
|
class App {
|
|
constructor() {
|
|
this.stat = new WebStat.Stat()
|
|
this.areaChart = new WebStat.AreaChart(document.querySelector("#chart"), this.stat)
|
|
this.pieChart = new WebStat.PieChart(document.querySelector("#pie"), this.stat)
|
|
|
|
setInterval(()=>this.update(), 2 * Second)
|
|
}
|
|
|
|
async update() {
|
|
this.stat.update()
|
|
this.areaChart.update()
|
|
this.pieChart.update()
|
|
}
|
|
|
|
}
|
|
|
|
function init() {
|
|
new App()
|
|
}
|
|
|
|
if (document.readyState === "loading") {
|
|
document.addEventListener("DOMContentLoaded", init)
|
|
} else {
|
|
init()
|
|
}
|