corridor_control/fan_control/data/index.html

69 lines
1.7 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>My first Chartist Tests</title>
<link rel="stylesheet" href="chartist.min.css.gz">
<style>
.ct-chart{
width: 100%;
height: 300px;
}
.left{
float: left;
width: 80%;
}
.right{
float: left;
width: 19%;
}
</style>
</head>
<body>
<div class="left">
<h1> Weekly </h1>
<div class="ct-chart chart1"></div>
<h1> Monthly </h1>
<div class="ct-chart chart2"></div>
</div>
<div class="right">
<h1> Log </h1>
<div id="log"></div>
</div>
<script >
var chart;
function load_chart( url , clazz ){
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var series = JSON.parse(this.responseText);
var data = { series: series };
chart = new Chartist.Line(clazz, data , {high: 30 , low: -25});
}
}
xhttp.open("GET", url, true);
xhttp.send();
};
function load_charts(){
load_chart("/weekly" , ".chart1");
load_chart("/monthly" , ".chart2");
}
var log = document.getElementById("log")
function get_log( ){
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
console.log(this.responseText);
log.innerHTML = this.responseText + log.innerHTML;
}
}
xhttp.open("GET", "/log", true);
xhttp.send();
};
var intervalID = window.setInterval(get_log, 1500);
</script>
<script onload="load_charts();" src="/chartist.min.js.gz"> </script>
</body>
</html>