|
@ -595,6 +595,9 @@ LineGraph.prototype._updateGraph = function () { |
|
|
var processedGroupData = {}; |
|
|
var processedGroupData = {}; |
|
|
var groupRanges = {}; |
|
|
var groupRanges = {}; |
|
|
var changeCalled = false; |
|
|
var changeCalled = false; |
|
|
|
|
|
// this is the range of the SVG canvas
|
|
|
|
|
|
var minDate = this.body.util.toGlobalTime(-this.body.domProps.root.width); |
|
|
|
|
|
var maxDate = this.body.util.toGlobalTime(2 * this.body.domProps.root.width); |
|
|
|
|
|
|
|
|
// getting group Ids
|
|
|
// getting group Ids
|
|
|
var groupIds = []; |
|
|
var groupIds = []; |
|
@ -607,9 +610,6 @@ LineGraph.prototype._updateGraph = function () { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if (groupIds.length > 0) { |
|
|
if (groupIds.length > 0) { |
|
|
// this is the range of the SVG canvas
|
|
|
|
|
|
var minDate = this.body.util.toGlobalTime(-this.body.domProps.root.width); |
|
|
|
|
|
var maxDate = this.body.util.toGlobalTime(2 * this.body.domProps.root.width); |
|
|
|
|
|
var groupsData = {}; |
|
|
var groupsData = {}; |
|
|
|
|
|
|
|
|
// fill groups data, this only loads the data we require based on the timewindow
|
|
|
// fill groups data, this only loads the data we require based on the timewindow
|
|
@ -778,15 +778,17 @@ LineGraph.prototype._getRelevantData = function (groupIds, groupsData, minDate, |
|
|
if (groupIds.length > 0) { |
|
|
if (groupIds.length > 0) { |
|
|
for (i = 0; i < groupIds.length; i++) { |
|
|
for (i = 0; i < groupIds.length; i++) { |
|
|
group = this.groups[groupIds[i]]; |
|
|
group = this.groups[groupIds[i]]; |
|
|
groupsData[groupIds[i]] = []; |
|
|
|
|
|
|
|
|
var itemsData = group.getItems(); |
|
|
// optimization for sorted data
|
|
|
// optimization for sorted data
|
|
|
if (group.options.sort == true) { |
|
|
if (group.options.sort == true) { |
|
|
var dataContainer = groupsData[groupIds[i]]; |
|
|
|
|
|
var guess = Math.max(0, util.binarySearchValue(group.itemsData, minDate, 'x', 'before')); |
|
|
|
|
|
for (j = guess; j < group.itemsData.length; j++) { |
|
|
|
|
|
|
|
|
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++) { |
|
|
item = group.itemsData[j]; |
|
|
item = group.itemsData[j]; |
|
|
dataContainer.push(item); |
|
|
|
|
|
if (item.x > maxDate) { |
|
|
|
|
|
|
|
|
dataContainer[j-guess] = item; |
|
|
|
|
|
if (item.x.getTime() > max) { |
|
|
|
|
|
groupsData[groupIds[i]] = dataContainer.splice(0,j-guess); |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -823,12 +825,12 @@ LineGraph.prototype._applySampling = function (groupIds, groupsData) { |
|
|
var pointsPerPixel = amountOfPoints / xDistance; |
|
|
var pointsPerPixel = amountOfPoints / xDistance; |
|
|
increment = Math.min(Math.ceil(0.2 * amountOfPoints), Math.max(1, Math.round(pointsPerPixel))); |
|
|
increment = Math.min(Math.ceil(0.2 * amountOfPoints), Math.max(1, Math.round(pointsPerPixel))); |
|
|
|
|
|
|
|
|
var sampledData = []; |
|
|
|
|
|
|
|
|
var sampledData = new Array(amountOfPoints); |
|
|
for (var j = 0; j < amountOfPoints; j += increment) { |
|
|
for (var j = 0; j < amountOfPoints; j += increment) { |
|
|
sampledData.push(dataContainer[j]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var idx = Math.round(j/increment); |
|
|
|
|
|
sampledData[idx]=dataContainer[j]; |
|
|
} |
|
|
} |
|
|
groupsData[groupIds[i]] = sampledData; |
|
|
|
|
|
|
|
|
groupsData[groupIds[i]] = sampledData.splice(0,Math.round(amountOfPoints/increment)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -858,10 +860,10 @@ LineGraph.prototype._getYRanges = function (groupIds, groupsData, groupRanges) { |
|
|
// if bar graphs are stacked, their range need to be handled differently and accumulated over all groups.
|
|
|
// if bar graphs are stacked, their range need to be handled differently and accumulated over all groups.
|
|
|
if (options.stack === true && options.style === 'bar') { |
|
|
if (options.stack === true && options.style === 'bar') { |
|
|
if (options.yAxisOrientation === 'left') { |
|
|
if (options.yAxisOrientation === 'left') { |
|
|
combinedDataLeft = combinedDataLeft.concat(group.getData(groupData)); |
|
|
|
|
|
|
|
|
combinedDataLeft = combinedDataLeft.concat(group.getItems()); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
combinedDataRight = combinedDataRight.concat(group.getData(groupData)); |
|
|
|
|
|
|
|
|
combinedDataRight = combinedDataRight.concat(group.getItems()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
@ -873,10 +875,6 @@ LineGraph.prototype._getYRanges = function (groupIds, groupsData, groupRanges) { |
|
|
// if bar graphs are stacked, their range need to be handled differently and accumulated over all groups.
|
|
|
// if bar graphs are stacked, their range need to be handled differently and accumulated over all groups.
|
|
|
Bars.getStackedYRange(combinedDataLeft, groupRanges, groupIds, '__barStackLeft', 'left'); |
|
|
Bars.getStackedYRange(combinedDataLeft, groupRanges, groupIds, '__barStackLeft', 'left'); |
|
|
Bars.getStackedYRange(combinedDataRight, groupRanges, groupIds, '__barStackRight', 'right'); |
|
|
Bars.getStackedYRange(combinedDataRight, groupRanges, groupIds, '__barStackRight', 'right'); |
|
|
// if line graphs are stacked, their range need to be handled differently and accumulated over all groups.
|
|
|
|
|
|
//LineFunctions.getStackedYRange(combinedDataLeft , groupRanges, groupIds, '__lineStackLeft' , 'left' );
|
|
|
|
|
|
//LineFunctions.getStackedYRange(combinedDataRight, groupRanges, groupIds, '__lineStackRight', 'right');
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
@ -991,7 +989,7 @@ LineGraph.prototype._toggleAxisVisiblity = function (axisUsed, axis) { |
|
|
var changed = false; |
|
|
var changed = false; |
|
|
if (axisUsed == false) { |
|
|
if (axisUsed == false) { |
|
|
if (axis.dom.frame.parentNode && axis.hidden == false) { |
|
|
if (axis.dom.frame.parentNode && axis.hidden == false) { |
|
|
axis.hide() |
|
|
|
|
|
|
|
|
axis.hide(); |
|
|
changed = true; |
|
|
changed = true; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -1015,14 +1013,14 @@ LineGraph.prototype._toggleAxisVisiblity = function (axisUsed, axis) { |
|
|
* @private |
|
|
* @private |
|
|
*/ |
|
|
*/ |
|
|
LineGraph.prototype._convertXcoordinates = function (datapoints) { |
|
|
LineGraph.prototype._convertXcoordinates = function (datapoints) { |
|
|
var extractedData = []; |
|
|
|
|
|
|
|
|
var extractedData = new Array(datapoints.length); |
|
|
var xValue, yValue; |
|
|
var xValue, yValue; |
|
|
var toScreen = this.body.util.toScreen; |
|
|
var toScreen = this.body.util.toScreen; |
|
|
|
|
|
|
|
|
for (var i = 0; i < datapoints.length; i++) { |
|
|
for (var i = 0; i < datapoints.length; i++) { |
|
|
xValue = toScreen(datapoints[i].x) + this.props.width; |
|
|
xValue = toScreen(datapoints[i].x) + this.props.width; |
|
|
yValue = datapoints[i].y; |
|
|
yValue = datapoints[i].y; |
|
|
extractedData.push({x: xValue, y: yValue}); |
|
|
|
|
|
|
|
|
extractedData[i] = {x: xValue, y: yValue}; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return extractedData; |
|
|
return extractedData; |
|
@ -1040,8 +1038,8 @@ LineGraph.prototype._convertXcoordinates = function (datapoints) { |
|
|
* @private |
|
|
* @private |
|
|
*/ |
|
|
*/ |
|
|
LineGraph.prototype._convertYcoordinates = function (datapoints, group) { |
|
|
LineGraph.prototype._convertYcoordinates = function (datapoints, group) { |
|
|
var extractedData = []; |
|
|
|
|
|
var xValue, yValue; |
|
|
|
|
|
|
|
|
var extractedData = new Array(datapoints.length); |
|
|
|
|
|
var xValue, yValue, labelValue; |
|
|
var toScreen = this.body.util.toScreen; |
|
|
var toScreen = this.body.util.toScreen; |
|
|
var axis = this.yAxisLeft; |
|
|
var axis = this.yAxisLeft; |
|
|
var svgHeight = Number(this.svg.style.height.replace('px', '')); |
|
|
var svgHeight = Number(this.svg.style.height.replace('px', '')); |
|
@ -1050,10 +1048,10 @@ LineGraph.prototype._convertYcoordinates = function (datapoints, group) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
for (var i = 0; i < datapoints.length; i++) { |
|
|
for (var i = 0; i < datapoints.length; i++) { |
|
|
var labelValue = datapoints[i].label ? datapoints[i].label : null; |
|
|
|
|
|
|
|
|
labelValue = datapoints[i].label ? datapoints[i].label : null; |
|
|
xValue = toScreen(datapoints[i].x) + this.props.width; |
|
|
xValue = toScreen(datapoints[i].x) + this.props.width; |
|
|
yValue = Math.round(axis.convertValue(datapoints[i].y)); |
|
|
yValue = Math.round(axis.convertValue(datapoints[i].y)); |
|
|
extractedData.push({x: xValue, y: yValue, label: labelValue}); |
|
|
|
|
|
|
|
|
extractedData[i] = {x: xValue, y: yValue, label: labelValue}; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
group.setZeroPosition(Math.min(svgHeight, axis.convertValue(0))); |
|
|
group.setZeroPosition(Math.min(svgHeight, axis.convertValue(0))); |
|
|