Browse Source

Another significant scalability optimization

newShading
Ludo Stellingwerff 9 years ago
parent
commit
da29bb0aa8
1 changed files with 9 additions and 9 deletions
  1. +9
    -9
      lib/timeline/component/LineGraph.js

+ 9
- 9
lib/timeline/component/LineGraph.js View File

@ -781,17 +781,17 @@ LineGraph.prototype._getRelevantData = function (groupIds, groupsData, minDate,
var itemsData = group.getItems();
// optimization for sorted data
if (group.options.sort == true) {
var max = maxDate.getTime();
var guess = Math.max(0, util.binarySearchValue(itemsData, minDate, 'x', 'before'));
var dataContainer = new Array(itemsData.length-guess);
for (j = guess; j < itemsData.length; j++) {
var first = Math.max(0, util.binarySearchValue(itemsData, minDate, 'x', 'before'));
var last = Math.min(itemsData.length, util.binarySearchValue(itemsData, maxDate, 'x', 'after'));
if (last < 0) {
last = itemsData.length;
}
var dataContainer = new Array(last-first);
for (j = first; j < last; j++) {
item = group.itemsData[j];
dataContainer[j-guess] = item;
if (item.x.getTime() > max) {
groupsData[groupIds[i]] = dataContainer.splice(0,j-guess);
break;
}
dataContainer[j-first] = item;
}
groupsData[groupIds[i]] = dataContainer;
}
else {
// If unsorted data, all data is relevant, just returning entire structure

Loading…
Cancel
Save