Skip to content
Browse files

Fixed axis on PCoA plot when min == max. The axis had no range and th…

…us was being displayed incorrectly in this case.
  • Loading branch information...
1 parent ff76a21 commit d8f73dc7f68837a3bf75770072aa1a137d72eaed @jaredbischof jaredbischof committed Mar 13, 2013
Showing with 11 additions and 1 deletion.
  1. +11 −1 src/MGRAST/html/js/pca.js
View
12 src/MGRAST/html/js/pca.js
@@ -177,7 +177,17 @@ function min_max(items, c1, c2){
c1_max = (c1_max && c1_max > items[i][c1]) ? c1_max : items[i][c1];
c2_min = (c2_min && c2_min < items[i][c2]) ? c2_min : items[i][c2];
c2_max = (c2_max && c2_max > items[i][c2]) ? c2_max : items[i][c2];
- }
+ }
+ // If min == max for either axis, we want to artificially create a gap between
+ // them so that the axis has some span, otherwise the plot is messed up.
+ if(c1_min == c1_max) {
+ c1_min = c1_min - 0.5;
+ c1_max = c1_max + 0.5;
+ }
+ if(c2_min == c2_max) {
+ c2_min = c2_min - 0.5;
+ c2_max = c2_max + 0.5;
+ }
var c1_diff = Math.abs(c1_min - c1_max);
var c2_diff = Math.abs(c2_min - c2_max);
return [(c1_min-(c1_diff*0.1)),(c1_max+(c1_diff*0.1)), Math.abs((c1_max+(c1_diff*0.1))-(c1_min-(c1_diff*0.1))),(c2_min-(c2_diff*0.1)),(c2_max+(c2_diff*0.1)), Math.abs((c2_max+(c2_diff*0.1))-(c2_min-(c2_diff*0.1)))];

0 comments on commit d8f73dc

Please sign in to comment.
Something went wrong with that request. Please try again.