Commit 5cd12f2c authored by Thonier Florian's avatar Thonier Florian
Browse files

axis.js : change preset 3 to gave not an axis for undefined values.)

parent 5993d6b6
......@@ -62,7 +62,7 @@ Axes.prototype = {
"sequenceLength" : {
doc: "length of the consensus sequence",
label: "clone consensus length",
axis: new NumericalAxis(this.m, false, true),
axis: new NumericalAxis(this.m, false, false),
fct: function(clone) {return clone.getSequenceLength()},
pretty: function(len) { return createClassedSpan('threeDigits', len) }
},
......
......@@ -184,8 +184,12 @@ NumericalAxis.prototype = Object.create(GenericAxis.prototype);
}else{
var nb_steps = this.NB_STEPS_IN_AXIS-1
undefined_min = min
nb_step = this.computeSteps(max, nb_steps);
nb_step = this.computeSteps(min, max, nb_steps);
if (has_undefined) {
nb_steps = nb_steps -1
}
h = (max-min)/nb_steps
// Computed so that pos <= 1 (in the loop below)
var delta = (min - max)/((min - undefined_min)/(max-undefined_min) - 1)
......@@ -193,7 +197,7 @@ NumericalAxis.prototype = Object.create(GenericAxis.prototype);
this.labels.push(this.label("line", (this.reverse) ? 0 : 1, "?"))
// Shift the start when there is an undefined value
var start_shift = (min - undefined_min)/(max-undefined_min)
for (var j = 0; j <= nb_steps-1; j++) {
for (var j = 0; j <= nb_steps; j++) {
pos = (h*j)*(1/delta);
text = this.getLabelText(min + h*j);
......
......@@ -105,13 +105,25 @@ QUnit.test("axis", function(assert) {
assert.equal(axis.pos(m.clone(0)).pos.toPrecision(3), 0.0325, "custom 2 : clone 0 (sequenceLength = 21) position -> 0.0325")
assert.equal(axis.pos(m.clone(1)).pos.toPrecision(3), 0.0236, "custom 2 : clone 1 (sequenceLength = 18) position -> 0.0236")
assert.equal(axis.pos(m.clone(3)).pos.toPrecision(3), 0.683, "custom 2 : clone 3 (sequenceLength = 241) position -> 0.683")
assert.equal(axis.label_mapping.hasOwnProperty('0'), false, "axis have not label 0")
assert.equal(axis.label_mapping.hasOwnProperty('0'), false, "axis have not label 0")
assert.equal(axis.label_mapping.hasOwnProperty('10'), true, "axis have label 10")
assert.equal(axis.label_mapping.hasOwnProperty('281'), true, "axis have label 281")
assert.equal(axis.label_mapping.hasOwnProperty('264'), true, "axis have label 264")
assert.equal(axis.label_mapping['10'].pos.toPrecision(3), 0, "pos of axis.label 10 is 0")
assert.equal(axis.label_mapping['281'].pos.toPrecision(3), 0.8000, "pos of axis.label 281 is 0.8")
assert.equal(axis.label_mapping['264'].pos.toPrecision(3), 0.750, "pos of axis.label 264 is 0.750")
assert.equal(axis.labels[0].pos, 1, "pos of axis label 0 ('?' value) is 1")
assert.notEqual(axis.labels[axis.labels.length-1-1].pos, 1, "pos of last axis label is not 1")
assert.equal(axis.labels[axis.labels.length-1].pos, 1, "pos of last axis label is 1")
assert.equal( (axis.labels.length != axis.label_mapping.length), true, "axis.labels length != axis.label_mapping length (du to '?')")
// sequenceLength with undefined
axis = new NumericalAxis(m)
axis.init(m.clones,
function(clone) {
return clone.getSequenceLength();
},
undefined,
true)
assert.notEqual(axis.labels[axis.labels.length-2].pos, 1, "pos of last axis label is not 1")
assert.equal( (axis.labels.length != axis.label_mapping.length), true, "axis.labels length != axis.label_mapping length (du to '?')")
//gc
axis = new PercentAxis(m, false, false);
......
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