Commit 2dad501a authored by jgould's avatar jgould

No data

parent 8d9b45f4
morpheus.Positions = function() { morpheus.Positions = function () {
this.spaces = undefined; this.spaces = undefined;
this.defaultPositionFunction = function(index) { this.defaultPositionFunction = function (index) {
return (this.size * index); return (this.size * index);
}; };
this.squishedPositionFunction = function(index) { this.squishedPositionFunction = function (index) {
return this.positions[index]; return this.positions[index];
}; };
this.positionFunction = this.defaultPositionFunction; this.positionFunction = this.defaultPositionFunction;
this.squishedIndices = {}; this.squishedIndices = {};
this.isSquished = false; this.isSquished = false;
}; };
morpheus.Positions.getBottom = function(rect, rowPositions) { morpheus.Positions.getBottom = function (rect, rowPositions) {
var bottom = rowPositions.getLength(); var bottom = rowPositions.getLength();
if (rect != null) { if (rect != null) {
bottom = 1 + rowPositions.getIndex(rect.y + rect.height, false); bottom = 1 + rowPositions.getIndex(rect.y + rect.height, false);
...@@ -19,7 +19,7 @@ morpheus.Positions.getBottom = function(rect, rowPositions) { ...@@ -19,7 +19,7 @@ morpheus.Positions.getBottom = function(rect, rowPositions) {
} }
return bottom; return bottom;
}; };
morpheus.Positions.getTop = function(rect, rowPositions) { morpheus.Positions.getTop = function (rect, rowPositions) {
var top = 0; var top = 0;
if (rect != null) { if (rect != null) {
top = rowPositions.getIndex(rect.y, false) - 1; top = rowPositions.getIndex(rect.y, false) - 1;
...@@ -28,7 +28,7 @@ morpheus.Positions.getTop = function(rect, rowPositions) { ...@@ -28,7 +28,7 @@ morpheus.Positions.getTop = function(rect, rowPositions) {
} }
return top; return top;
}; };
morpheus.Positions.getLeft = function(rect, columnPositions) { morpheus.Positions.getLeft = function (rect, columnPositions) {
var left = 0; var left = 0;
if (rect != null) { if (rect != null) {
left = columnPositions.getIndex(rect.x, false) - 1; left = columnPositions.getIndex(rect.x, false) - 1;
...@@ -37,7 +37,7 @@ morpheus.Positions.getLeft = function(rect, columnPositions) { ...@@ -37,7 +37,7 @@ morpheus.Positions.getLeft = function(rect, columnPositions) {
} }
return left; return left;
}; };
morpheus.Positions.getRight = function(rect, columnPositions) { morpheus.Positions.getRight = function (rect, columnPositions) {
var right = columnPositions.getLength(); var right = columnPositions.getLength();
if (rect != null) { if (rect != null) {
right = 1 + columnPositions.getIndex(rect.x + rect.width, false); right = 1 + columnPositions.getIndex(rect.x + rect.width, false);
...@@ -46,11 +46,11 @@ morpheus.Positions.getRight = function(rect, columnPositions) { ...@@ -46,11 +46,11 @@ morpheus.Positions.getRight = function(rect, columnPositions) {
return right; return right;
}; };
morpheus.Positions.prototype = { morpheus.Positions.prototype = {
length : 0, length: 0,
size : 13, size: 13,
squishFactor : 0.1, squishFactor: 0.1,
compress : true, compress: true,
copy : function() { copy: function () {
var copy = new morpheus.Positions(); var copy = new morpheus.Positions();
if (this.spaces) { if (this.spaces) {
copy.spaces = this.spaces.slice(); copy.spaces = this.spaces.slice();
...@@ -66,40 +66,43 @@ morpheus.Positions.prototype = { ...@@ -66,40 +66,43 @@ morpheus.Positions.prototype = {
} }
return copy; return copy;
}, },
getIndex : function(position, exact) { getIndex: function (position, exact) {
if (this.getLength() === 0) {
return -1;
}
if (exact) { if (exact) {
return this.binaryExactSearch(position); return this.binaryExactSearch(position);
} else { } else {
return this.binaryInExactSearch(position); return this.binaryInExactSearch(position);
} }
}, },
getLength : function() { getLength: function () {
return this.length; return this.length;
}, },
getPosition : function(index) { getPosition: function (index) {
return this.positionFunction(index) return this.positionFunction(index)
+ (this.spaces !== undefined ? this.spaces[index] : 0); + (this.spaces !== undefined ? this.spaces[index] : 0);
}, },
getItemSize : function(index) { getItemSize: function (index) {
return this.squishedIndices[index] === true ? this.size return this.squishedIndices[index] === true ? this.size
* this.squishFactor : this.size; * this.squishFactor : this.size;
}, },
getSize : function() { getSize: function () {
return this.size; return this.size;
}, },
setSpaces : function(spaces) { setSpaces: function (spaces) {
this.spaces = spaces; this.spaces = spaces;
}, },
setLength : function(length) { setLength: function (length) {
this.length = length; this.length = length;
}, },
setSize : function(size) { setSize: function (size) {
this.size = size; this.size = size;
if (this.isSquished) { if (this.isSquished) {
this.setSquishedIndices(this.squishedIndices); this.setSquishedIndices(this.squishedIndices);
} }
}, },
setSquishedIndices : function(squishedIndices) { setSquishedIndices: function (squishedIndices) {
if (squishedIndices != null) { if (squishedIndices != null) {
var compress = this.compress; var compress = this.compress;
this.squishedIndices = squishedIndices; this.squishedIndices = squishedIndices;
...@@ -130,7 +133,7 @@ morpheus.Positions.prototype = { ...@@ -130,7 +133,7 @@ morpheus.Positions.prototype = {
this.positionFunction = this.defaultPositionFunction; this.positionFunction = this.defaultPositionFunction;
} }
}, },
setSquishFactor : function(f) { setSquishFactor: function (f) {
if (this.squishFactor !== f) { if (this.squishFactor !== f) {
this.squishFactor = f; this.squishFactor = f;
if (this.isSquished) { if (this.isSquished) {
...@@ -138,10 +141,10 @@ morpheus.Positions.prototype = { ...@@ -138,10 +141,10 @@ morpheus.Positions.prototype = {
} }
} }
}, },
getSquishFactor : function() { getSquishFactor: function () {
return this.squishFactor; return this.squishFactor;
}, },
binaryExactSearch : function(position) { binaryExactSearch: function (position) {
var low = 0; var low = 0;
var high = this.length - 1; var high = this.length - 1;
while (low <= high) { while (low <= high) {
...@@ -163,7 +166,7 @@ morpheus.Positions.prototype = { ...@@ -163,7 +166,7 @@ morpheus.Positions.prototype = {
return -1; return -1;
// key not found // key not found
}, },
binaryInExactSearch : function(position) { binaryInExactSearch: function (position) {
var low = 0; var low = 0;
var high = this.getLength() - 1; var high = this.getLength() - 1;
var maxIndex = this.getLength() - 1; var maxIndex = this.getLength() - 1;
...@@ -175,7 +178,7 @@ morpheus.Positions.prototype = { ...@@ -175,7 +178,7 @@ morpheus.Positions.prototype = {
var midVal = this.getPosition(mid); var midVal = this.getPosition(mid);
var size = this.getItemSize(mid); var size = this.getItemSize(mid);
var nextStart = maxIndex === mid ? midVal + size : this var nextStart = maxIndex === mid ? midVal + size : this
.getPosition(mid + 1); .getPosition(mid + 1);
if (midVal <= position && position < nextStart) { if (midVal <= position && position < nextStart) {
return mid; return mid;
} }
......
...@@ -52,8 +52,8 @@ morpheus.HeatMapElementCanvas.prototype = { ...@@ -52,8 +52,8 @@ morpheus.HeatMapElementCanvas.prototype = {
+ this.rowPositions + this.rowPositions
.getItemSize(this.rowPositions.getLength() - 1)); .getItemSize(this.rowPositions.getLength() - 1));
return { return {
width: w, width: Math.max(12, w),
height: h height: Math.max(12, h)
}; };
}, },
prePaint: function (clip, context) { prePaint: function (clip, context) {
...@@ -169,7 +169,7 @@ morpheus.HeatMapElementCanvas.prototype = { ...@@ -169,7 +169,7 @@ morpheus.HeatMapElementCanvas.prototype = {
var top = morpheus.Positions.getTop(clip, rowPositions); var top = morpheus.Positions.getTop(clip, rowPositions);
var bottom = morpheus.Positions.getBottom(clip, rowPositions); var bottom = morpheus.Positions.getBottom(clip, rowPositions);
if (this.dataset.getRowCount() === 0 || this.dataset.getColumnCount() === 0) { if (this.dataset.getRowCount() === 0 || this.dataset.getColumnCount() === 0) {
return context.fillText("No data", 0, 0); return context.fillText('No data', 0, 6);
} else { } else {
context.translate(-clip.x, -clip.y); context.translate(-clip.x, -clip.y);
this._draw({ this._draw({
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment