summaryrefslogtreecommitdiff
path: root/jrrd.js
diff options
context:
space:
mode:
authorRichard Wall <richard@aziz>2010-04-10 11:07:08 +0100
committerRichard Wall <richard@aziz>2010-04-10 11:07:08 +0100
commit32e03133f5364ffb25b55d8b8dd34ed2962f392a (patch)
tree5342b130c01df29cdb26cb707e81217d9d76d4bf /jrrd.js
parentd6a57318678671ad85972a6d69ebeedabd5eefea (diff)
A chart class with multiple RRD data sources and an example of stacked chart
Diffstat (limited to 'jrrd.js')
-rw-r--r--jrrd.js27
1 files changed, 15 insertions, 12 deletions
diff --git a/jrrd.js b/jrrd.js
index f811223..44fdb95 100644
--- a/jrrd.js
+++ b/jrrd.js
@@ -43,10 +43,15 @@ jrrd.RrdQuery = function(rrd) {
this.rrd = rrd;
};
-jrrd.RrdQuery.prototype.getData = function(startTime, endTime) {
+jrrd.RrdQuery.prototype.getData = function(startTime, endTime, dsId) {
var startTimestamp = startTime.getTime()/1000;
var endTimestamp = endTime.getTime()/1000;
+ if(dsId == null) {
+ dsId = 0;
+ }
+ var ds = this.rrd.getDS(dsId);
+
var consolidationFunc = 'AVERAGE';
var lastUpdated = this.rrd.getLastUpdate();
@@ -74,18 +79,16 @@ jrrd.RrdQuery.prototype.getData = function(startTime, endTime) {
startRow = rraRowCount - parseInt((lastUpdated - startTimestamp)/step);
endRow = rraRowCount - parseInt((lastUpdated - endTimestamp)/step);
- returnData = [];
- for(var d=this.rrd.getNrDSs()-1; d>=0; d--) {
- flotData = [];
- timestamp = firstUpdated + (startRow - 1) * step;
- for (var i=startRow; i<=endRow; i++) {
- var val = bestRRA.getEl(i, d);
- flotData.push([timestamp*1000.0, val]);
- timestamp += step;
- }
- returnData.push({label: this.rrd.getDS(d).getName(), data: flotData});
+
+ flotData = [];
+ timestamp = firstUpdated + (startRow - 1) * step;
+ dsIndex = ds.getIdx();
+ for (var i=startRow; i<=endRow; i++) {
+ var val = bestRRA.getEl(i, dsIndex);
+ flotData.push([timestamp*1000.0, val]);
+ timestamp += step;
}
- return returnData;
+ return {label: ds.getName(), data: flotData};
};