X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=testing%2FMCTXWeb%2Fpublic_html%2Fstatic%2Fmctx.graph.js;h=fd475ad876d540ddec3eac497e0618361dabd548;hb=7e9d726ccd53626251e56b92c8eec47772bfe0f9;hp=57c884122718ba101d2843ef9b90452fb0f61f7a;hpb=8c9214a60db100a206496d1c417c08a20ea2693e;p=matches%2FMCTX3420.git
diff --git a/testing/MCTXWeb/public_html/static/mctx.graph.js b/testing/MCTXWeb/public_html/static/mctx.graph.js
index 57c8841..fd475ad 100644
--- a/testing/MCTXWeb/public_html/static/mctx.graph.js
+++ b/testing/MCTXWeb/public_html/static/mctx.graph.js
@@ -11,6 +11,8 @@ mctx.graph.api.sensors = mctx.api + "sensors";
mctx.graph.api.actuators = mctx.api + "actuators";
mctx.sensors = {};
mctx.actuators = {};
+
+mctx.graph.devices = {};
mctx.graph.dependent = null;
mctx.graph.independent = null;
mctx.graph.timer = null;
@@ -65,12 +67,13 @@ $.fn.deployDevices = function(input_type, check_first, group) {
var apply = function(dict, prefix) {
$.each(dict, function(key, val) {
var attributes = {
- 'type' : input_type, 'value' : key, 'alt' : val,
+ 'type' : input_type, 'value' : key, 'alt' : val.name,
'class' : prefix, 'name' : group,
- 'id' : prefix + '_' + val //Unique id (name mangling)
+ 'id' : prefix + '_' + val.name //Unique id (name mangling)
};
+
var entry = $("", attributes);
- var label = $("", {'for' : prefix + '_' + val, 'text' : val});
+ var label = $("", {'for' : prefix + '_' + val.name, 'text' : val.name});
entry.prop("checked", check_first);
check_first = false;
container.append(entry).append(label);
@@ -156,7 +159,7 @@ function graphUpdater() {
.done(function(json) {
//alert("Hi from " + json.name);
if (!$("#status-text").checkStatus(json)) {
- setGraphStatus(false, null, true);
+ setGraphStatus(false, null, true); //Don't reset text, checkstatus just set it.
return;
}
@@ -178,16 +181,20 @@ function graphUpdater() {
var plot_data = [];
yaxis.each(function() {
+ var series = {};
+ series.label = $(this).attr("alt");
+
//alert("Add " + $(this).val() + " to plot");
if (xaxis.attr("alt") === "time") {
//alert("Against time");
- plot_data.push(devices[$(this).attr("alt")].data);
+ series.data = devices[$(this).attr("alt")].data;
} else {
var result = []
dataMerge(devices[xaxis.attr("alt")].data,
devices[$(this).attr("alt")].data, result);
- plot_data.push(result);
+ series.data = result;
}
+ plot_data.push(series);
});
if (mctx.graph.chart !== null) {
@@ -195,7 +202,12 @@ function graphUpdater() {
mctx.graph.chart.setupGrid();
mctx.graph.chart.draw();
} else {
- mctx.graph.chart = $.plot("#graph", plot_data);
+ var options = {
+ legend : {
+ container : "#graph-legend"
+ }
+ };
+ mctx.graph.chart = $.plot("#graph", plot_data, options);
}
mctx.graph.timer = setTimeout(updater, 1000);
}