|
@ -327,7 +327,34 @@ Graph3d.prototype.getDistinctValues = function(data, column) { |
|
|
distinctValues.push(data[i][column]); |
|
|
distinctValues.push(data[i][column]); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return distinctValues; |
|
|
|
|
|
|
|
|
return distinctValues.sort(function(a,b) { return a - b; }); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Determine the smallest difference between the values for given |
|
|
|
|
|
* column in the passed data set. |
|
|
|
|
|
* |
|
|
|
|
|
* @returns {Number|null} Smallest difference value or |
|
|
|
|
|
* null, if it can't be determined. |
|
|
|
|
|
*/ |
|
|
|
|
|
Graph3d.prototype.getSmallestDifference = function(data, column) { |
|
|
|
|
|
var values = this.getDistinctValues(data, column); |
|
|
|
|
|
var diffs = []; |
|
|
|
|
|
|
|
|
|
|
|
// Get all the distinct diffs
|
|
|
|
|
|
// Array values is assumed to be sorted here
|
|
|
|
|
|
var smallest_diff = null; |
|
|
|
|
|
|
|
|
|
|
|
for (var i = 1; i < values.length; i++) { |
|
|
|
|
|
var diff = values[i] - values[i - 1]; |
|
|
|
|
|
|
|
|
|
|
|
if (smallest_diff == null || smallest_diff > diff ) { |
|
|
|
|
|
smallest_diff = diff; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return smallest_diff; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -467,16 +494,14 @@ Graph3d.prototype._dataInitialize = function (rawData, style) { |
|
|
this.xBarWidth = this.defaultXBarWidth; |
|
|
this.xBarWidth = this.defaultXBarWidth; |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
var dataX = this.getDistinctValues(data,this.colX); |
|
|
|
|
|
this.xBarWidth = (dataX[1] - dataX[0]) || 1; |
|
|
|
|
|
|
|
|
this.xBarWidth = this.getSmallestDifference(data, this.colX) || 1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (this.defaultYBarWidth !== undefined) { |
|
|
if (this.defaultYBarWidth !== undefined) { |
|
|
this.yBarWidth = this.defaultYBarWidth; |
|
|
this.yBarWidth = this.defaultYBarWidth; |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
var dataY = this.getDistinctValues(data,this.colY); |
|
|
|
|
|
this.yBarWidth = (dataY[1] - dataY[0]) || 1; |
|
|
|
|
|
|
|
|
this.yBarWidth = this.getSmallestDifference(data, this.colY) || 1; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -2449,4 +2474,4 @@ Graph3d.prototype.setSize = function(width, height) { |
|
|
// -----------------------------------------------------------------------------
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = Graph3d; |
|
|
|
|
|
|
|
|
module.exports = Graph3d; |