- context = canvas.getContext("2d");
- drawplot(data.cold, "blue");
- drawplot(data.hot, "red");
+
+ ctx = canvas.getContext("2d");
+ ww = canvas.width;
+ wh = canvas.height;
+
+ tmin = data.range.lo;
+ tmax = data.range.hi;
+ tfact = (ww - xzero) / (tmax - tmin);
+ /* differetiate() updates hmax */
+ hmax = 0;
+ cold_d = differentiate(data.cold);
+ hot_d = differentiate(data.hot);
+ hfact = (wh - yzero) / hmax;
+
+ //document.getElementById("debug").innerHTML = cold_d + "<br>" + hot_d;
+
+ drawplot(cold_d, "blue");
+ drawplot(hot_d, "red");
+ xaxis();
+ yaxis();
+ }
+
+ function sendquery(lo, hi) {
+ var url = "query.cgi";
+
+ if (lo && hi) url += "?lo=" + lo + "&" + hi;
+ else url = "query.cgi?lo=2015-12-19+00:00:00&hi=2015-12-20+00:00:00"; //FIX
+ xmlhttp.onreadystatechange = function() {
+ if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
+ // dbg.innerHTML = xmlhttp.responseText;
+ var myData = JSON.parse(xmlhttp.responseText);
+ gotdata(myData);
+ }
+ }
+ xmlhttp.open("GET", url, true);
+ xmlhttp.send();
+ }
+
+ function initialize() {
+ dbg = document.getElementById("debug");
+ xmlhttp = new XMLHttpRequest();
+ sendquery();
+ }
+
+ /* Set up */
+ if(window.attachEvent) {
+ window.attachEvent('onload', initialize);
+ } else {
+ window.onload = initialize;