X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;ds=sidebyside;f=testing%2FMCTXWeb%2Fpublic_html%2Fstatic%2Fmctx.graph.js;h=de5ecb3fb3a291abf252dabb3c5b4839eb0a5223;hb=dd5ae3e50b2d77cf0cc1a2805c91d518270c8537;hp=22d14d787db5d11a14b5444aa64827a68363c25c;hpb=2132221a67036e32aee10d882a4d391466498f9d;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 22d14d7..de5ecb3 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;
@@ -69,6 +71,7 @@ $.fn.deployDevices = function(input_type, check_first, group) {
'class' : prefix, 'name' : group,
'id' : prefix + '_' + val //Unique id (name mangling)
};
+
var entry = $("", attributes);
var label = $("", {'for' : prefix + '_' + val, 'text' : val});
entry.prop("checked", check_first);
@@ -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);
}