fixed cumulative
This commit is contained in:
parent
a213170a8c
commit
46aa9fa2f2
@ -77,10 +77,12 @@
|
||||
dates = (1 + maxDateSlots) * rows.length;
|
||||
}
|
||||
|
||||
var type = this.options.cumulative ? Uint32Array: Uint8Array;
|
||||
|
||||
// reserve memory for all the dates
|
||||
var timeIndex = new Int32Array(maxDateSlots + 1); //index-size
|
||||
var timeCount = new Int32Array(maxDateSlots + 1);
|
||||
var renderData = new (this.options.valueDataType || Uint8Array)(dates);
|
||||
var renderData = new (this.options.valueDataType || type)(dates);
|
||||
var renderDataPos = new Uint32Array(dates);
|
||||
|
||||
prof_mem.inc(
|
||||
@ -108,23 +110,38 @@
|
||||
|
||||
var dates = row.dates__uint16;
|
||||
var vals = row.vals__uint8;
|
||||
var prev_val = 0;
|
||||
for (var j = 0, len = dates.length; j < len; ++j) {
|
||||
var rr = rowsPerSlot[dates[j]] || (rowsPerSlot[dates[j]] = []);
|
||||
if(this.options.cumulative) {
|
||||
vals[j] += prev_val;
|
||||
}
|
||||
prev_val = vals[j];
|
||||
rr.push([r, vals[j]]);
|
||||
}
|
||||
if (!this.options.cumulative) {
|
||||
for (var j = 0, len = dates.length; j < len; ++j) {
|
||||
var rr = rowsPerSlot[dates[j]] || (rowsPerSlot[dates[j]] = []);
|
||||
if(this.options.cumulative) {
|
||||
vals[j] += prev_val;
|
||||
}
|
||||
prev_val = vals[j];
|
||||
rr.push([r, vals[j]]);
|
||||
}
|
||||
} else {
|
||||
var valByDate = {}
|
||||
for (var j = 0, len = dates.length; j < len; ++j) {
|
||||
valByDate[dates[j]] = vals[j];
|
||||
}
|
||||
var accum = 0;
|
||||
|
||||
// extend the latest to the end
|
||||
if(this.options.cumulative) {
|
||||
var lastDateSlot = dates[dates.length - 1];
|
||||
// extend the latest to the end
|
||||
for (var j = dates[0]; j <= maxDateSlots; ++j) {
|
||||
var rr = rowsPerSlot[j] || (rowsPerSlot[j] = []);
|
||||
var v = valByDate[j];
|
||||
if (v) {
|
||||
accum += v;
|
||||
}
|
||||
rr.push([r, accum]);
|
||||
}
|
||||
|
||||
/*var lastDateSlot = dates[dates.length - 1];
|
||||
for (var j = lastDateSlot + 1; j <= maxDateSlots; ++j) {
|
||||
var rr = rowsPerSlot[j] || (rowsPerSlot[j] = []);
|
||||
rr.push([r, prev_val]);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user