2023-03-05 01:01:20 -07:00
|
|
|
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()
|
2023-03-11 08:54:24 -07:00
|
|
|
this.areaChart = new WebStat.AreaChart(document.querySelector("#chart"), this.stat)
|
|
|
|
this.pieChart = new WebStat.PieChart(document.querySelector("#pie"), this.stat)
|
2023-03-05 01:01:20 -07:00
|
|
|
|
|
|
|
setInterval(()=>this.update(), 2 * Second)
|
|
|
|
}
|
|
|
|
|
|
|
|
async update() {
|
|
|
|
this.stat.update()
|
2023-03-11 08:54:24 -07:00
|
|
|
this.areaChart.update()
|
|
|
|
this.pieChart.update()
|
2023-03-05 01:01:20 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function init() {
|
|
|
|
new App()
|
|
|
|
}
|
|
|
|
|
|
|
|
if (document.readyState === "loading") {
|
|
|
|
document.addEventListener("DOMContentLoaded", init)
|
|
|
|
} else {
|
|
|
|
init()
|
|
|
|
}
|