summaryrefslogtreecommitdiff
path: root/jrrd.js
diff options
context:
space:
mode:
authorRichard Wall <richard@aziz>2010-04-18 23:01:08 +0100
committerRichard Wall <richard@aziz>2010-04-18 23:01:08 +0100
commit4d4fa4722b83a726471c39f8313dd157ed3a230b (patch)
treef664a72c4cfcc76e2dda6f551c280e00117ea2d0 /jrrd.js
parent391e8c019e581ac781b189515be41791d147dc31 (diff)
A create charts from recipe dicts
Diffstat (limited to 'jrrd.js')
-rw-r--r--jrrd.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/jrrd.js b/jrrd.js
index d49212a..5e723d3 100644
--- a/jrrd.js
+++ b/jrrd.js
@@ -326,6 +326,26 @@ jrrd.Chart.prototype.draw = function() {
}, this);
};
+
+jrrd.Chart.fromRecipe = function(template, recipe) {
+ template.find('.title').text(recipe['title']);
+ var c = new jrrd.Chart(template.find('.chart'), recipe['options']);
+ var dataDict = {};
+ var ds, label, rrd, unit;
+ for(var i=0; i<recipe['data'].length; i++) {
+ rrd = recipe['data'][i][0];
+ ds = recipe['data'][i][1];
+ label = recipe['data'][i][2];
+ unit = recipe['data'][i][3];
+ if(typeof dataDict[rrd] == 'undefined') {
+ dataDict[rrd] = new jrrd.RrdQueryRemote(rrd);
+ }
+ c.addData(label, new jrrd.RrdQueryDsProxy(dataDict[rrd], ds));
+ }
+ return c;
+}
+
+
jrrd.ChartCoordinator = function(ui) {
this.ui = ui;
this.charts = [];