in riff-raff/public/javascripts/rickshaw.js [2823:2869]
initialize: function (data, palette, options) {
options = options || {};
if (typeof(options.timeInterval) === 'undefined') {
throw new Error('FixedDuration series requires timeInterval');
}
if (typeof(options.maxDataPoints) === 'undefined') {
throw new Error('FixedDuration series requires maxDataPoints');
}
this.palette = new Rickshaw.Color.Palette(palette);
this.timeBase = typeof(options.timeBase) === 'undefined' ? Math.floor(new Date().getTime() / 1000) : options.timeBase;
this.setTimeInterval(options.timeInterval);
if (this[0] && this[0].data && this[0].data.length) {
this.currentSize = this[0].data.length;
this.currentIndex = this[0].data.length;
} else {
this.currentSize = 0;
this.currentIndex = 0;
}
this.maxDataPoints = options.maxDataPoints;
if (data && (typeof(data) == "object") && (data instanceof Array)) {
data.forEach( function (item) { this.addItem(item) }, this );
this.currentSize += 1;
this.currentIndex += 1;
}
// reset timeBase for zero-filled values if needed
this.timeBase -= (this.maxDataPoints - this.currentSize) * this.timeInterval;
// zero-fill up to maxDataPoints size if we don't have that much data yet
if ((typeof(this.maxDataPoints) !== 'undefined') && (this.currentSize < this.maxDataPoints)) {
for (var i = this.maxDataPoints - this.currentSize - 1; i > 0; i--) {
this.currentSize += 1;
this.currentIndex += 1;
this.forEach( function (item) {
item.data.unshift({ x: ((i-1) * this.timeInterval || 1) + this.timeBase, y: 0, i: i });
}, this );
}
}
},