diff options
author | Richard Wall <richard@aziz> | 2010-04-18 23:01:08 +0100 |
---|---|---|
committer | Richard Wall <richard@aziz> | 2010-04-18 23:01:08 +0100 |
commit | 4d4fa4722b83a726471c39f8313dd157ed3a230b (patch) | |
tree | f664a72c4cfcc76e2dda6f551c280e00117ea2d0 /jrrd.js | |
parent | 391e8c019e581ac781b189515be41791d147dc31 (diff) |
A create charts from recipe dicts
Diffstat (limited to 'jrrd.js')
-rw-r--r-- | jrrd.js | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -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 = []; |