@ -411,8 +411,6 @@ LineGraph.prototype._updateGroup = function (group, groupId) {
LineGraph . prototype . _updateAllGroupData = function ( ) {
if ( this . itemsData != null ) {
// ~450 ms @ 500k
var groupsContent = { } ;
for ( var groupId in this . groups ) {
if ( this . groups . hasOwnProperty ( groupId ) ) {
@ -431,16 +429,6 @@ LineGraph.prototype._updateAllGroupData = function () {
this . groups [ groupId ] . setItems ( groupsContent [ groupId ] ) ;
}
}
// // ~4500ms @ 500k
// for (var groupId in this.groups) {
// if (this.groups.hasOwnProperty(groupId)) {
// this.groups[groupId].setItems(this.itemsData.get({filter:
// function (item) {
// return (item.group == groupId);
// }, type:{x:"Date"}}
// ));
// }
// }
}
} ;
@ -556,13 +544,6 @@ LineGraph.prototype.redraw = function() {
LineGraph . prototype . _updateGraph = function ( ) {
// reset the svg elements
DOMutil . prepareElements ( this . svgElements ) ;
// // very slow...
// groupData = group.itemsData.get({filter:
// function (item) {
// return (item.x > minDate && item.x < maxDate);
// }}
// );
if ( this . width != 0 && this . itemsData != null ) {
var group , groupData , preprocessedGroup , i ;
@ -591,38 +572,44 @@ LineGraph.prototype._updateGraph = function () {
if ( groupIds . length > 0 ) {
for ( i = 0 ; i < groupIds . length ; i ++ ) {
group = this . groups [ groupIds [ i ] ] ;
groupData = [ ] ;
// optimization for sorted data
if ( group . options . sort == true ) {
var guess = Math . max ( 0 , util . binarySearchGeneric ( group . itemsData , minDate , 'x' , 'before' ) ) ;
for ( var j = guess ; j < group . itemsData . length ; j ++ ) {
var item = group . itemsData [ j ] ;
if ( item !== undefined ) {
if ( item . x > maxDate ) {
groupData . push ( item ) ;
break ;
}
else {
groupData . push ( item ) ;
if ( group . visible == true ) {
groupData = [ ] ;
// optimization for sorted data
if ( group . options . sort == true ) {
var guess = Math . max ( 0 , util . binarySearchGeneric ( group . itemsData , minDate , 'x' , 'before' ) ) ;
for ( var j = guess ; j < group . itemsData . length ; j ++ ) {
var item = group . itemsData [ j ] ;
if ( item !== undefined ) {
if ( item . x > maxDate ) {
groupData . push ( item ) ;
break ;
}
else {
groupData . push ( item ) ;
}
}
}
}
}
else {
for ( var j = 0 ; j < group . itemsData . length ; j ++ ) {
var item = group . itemsData [ j ] ;
if ( item !== undefined ) {
if ( item . x > minDate && item . x < maxDate ) {
groupData . push ( item ) ;
else {
for ( var j = 0 ; j < group . it emsData . l ength ; j ++ ) {
var item = group . itemsData [ j ] ;
if ( item !== undefined ) {
if ( item . x > minDate && item . x < maxDate ) {
groupData . push ( item ) ;
}
}
}
}
// preprocess, split into ranges and data
preprocessedGroup = this . _preprocessData ( groupData , group ) ;
groupRanges . push ( { min : preprocessedGroup . min , max : preprocessedGroup . max } ) ;
preprocessedGroupData . push ( preprocessedGroup . data ) ;
}
else {
groupRanges . push ( { } ) ;
preprocessedGroupData . push ( [ ] ) ;
}
// preprocess, split into ranges and data
preprocessedGroup = this . _preprocessData ( groupData , group ) ;
groupRanges . push ( { min : preprocessedGroup . min , max : preprocessedGroup . max } ) ;
preprocessedGroupData . push ( preprocessedGroup . data ) ;
}
// update the Y axis first, we use this data to draw at the correct Y points
@ -643,11 +630,13 @@ LineGraph.prototype._updateGraph = function () {
// draw the groups
for ( i = 0 ; i < groupIds . length ; i ++ ) {
group = this . groups [ groupIds [ i ] ] ;
if ( group . options . style == 'line' ) {
this . _drawLineGraph ( processedGroupData [ i ] , group ) ;
}
else {
this . _drawBarGraph ( processedGroupData [ i ] , group ) ;
if ( group . visible == true ) {
if ( group . options . style == 'line' ) {
this . _drawLineGraph ( processedGroupData [ i ] , group ) ;
}
else {
this . _drawBarGraph ( processedGroupData [ i ] , group ) ;
}
}
}
}
@ -674,24 +663,27 @@ LineGraph.prototype._updateYAxis = function (groupIds, groupRanges) {
for ( var i = 0 ; i < groupIds . length ; i ++ ) {
orientation = 'left' ;
var group = this . groups [ groupIds [ i ] ] ;
if ( group . options . yAxisOrientation == 'right' ) {
orientation = 'right' ;
}
if ( group . visible == true ) {
if ( group . options . yAxisOrientation == 'right' ) {
orientation = 'right' ;
}
minVal = groupRanges [ i ] . min ;
maxVal = groupRanges [ i ] . max ;
minVal = groupRanges [ i ] . min ;
maxVal = groupRanges [ i ] . max ;
if ( orientation == 'left' ) {
yAxisLeftUsed = true ;
minLeft = minLeft > minVal ? minVal : minLeft ;
maxLeft = maxLeft < maxVal ? maxVal : maxLeft ;
}
else {
yAxisRightUsed = true ;
minRight = minRight > minVal ? minVal : minRight ;
maxRight = maxRight < maxVal ? maxVal : maxRight ;
if ( orientation == 'left' ) {
yAxisLeftUsed = true ;
minLeft = minLeft > minVal ? minVal : minLeft ;
maxLeft = maxLeft < maxVal ? maxVal : maxLeft ;
}
else {
yAxisRightUsed = true ;
minRight = minRight > minVal ? minVal : minRight ;
maxRight = maxRight < maxVal ? maxVal : maxRight ;
}
}
}
console . log ( yAxisRightUsed )
if ( yAxisLeftUsed == true ) {
this . yAxisLeft . setRange ( minLeft , maxLeft ) ;
}
@ -715,9 +707,9 @@ LineGraph.prototype._updateYAxis = function (groupIds, groupRanges) {
this . yAxisRight . master = ! yAxisLeftUsed ;
if ( this . yAxisRight . master == false ) {
if ( yAxisRightUsed == true ) {
this . yAxisLeft . lineOffset = this . yAxisRight . width ;
}
if ( yAxisRightUsed == true ) { this . yAxisLeft . lineOffset = this . yAxisRight . width ; }
else { this . yAxisLeft . lineOffset = 0 ; }
changeCalled = this . yAxisLeft . redraw ( ) || changeCalled ;
this . yAxisRight . stepPixelsForced = this . yAxisLeft . stepPixels ;
changeCalled = this . yAxisRight . redraw ( ) || changeCalled ;