Attention une mise à jour du serveur va être effectuée le lundi 17 mai entre 13h et 13h30. Cette mise à jour va générer une interruption du service de quelques minutes.

Commit 6e62b4cc authored by Ryan Herbert's avatar Ryan Herbert

Merge branch 'hotfix-c/fix_generic_axis_sort' into dev

parents 0f294f13 af02c410
......@@ -149,7 +149,8 @@ Axes.prototype = {
label: "locus",
axis: new GenericAxis(),
fct: function(clone){return clone.germline},
pretty: function(system) { return self.m.systemBox(system) }
pretty: function(system) { return self.m.systemBox(system) },
sort: true
},
"Size" : {
doc: "ratio of the number of reads of each clone to the total number of reads in the selected locus",
......
......@@ -58,34 +58,30 @@ GenericAxis.prototype = {
}
}
this.populateLabels(labels);
this.populateLabels(labels, sort);
this.populateValueMapping();
if (sort)
this.labels.sort(this.compareLabels);
return this;
},
compareLabels: function(lab1, lab2) {
var a = lab1.text;
var b = lab2.text;
compareLabels: function(a, b) {
if (typeof a === 'undefined') return (typeof b === 'undefined') ? 0 : -1;
if (typeof b === 'undefined') return (typeof a === 'undefined') ? 0 : 1;
if (a.constructor === String) {
if (b.constructor === String) return va.localeCompare(vb);
if (b.constructor === String) return a.localeCompare(b);
if (b.constructor === Number ) return 1
}
if (a.constructor === Number) return (b.constructor === Number ) ? (a-b) : -1;
},
populateLabels: function(labels) {
populateLabels: function(labels, sort) {
var values = this.values;
var label_mapping = this.label_mapping;
if (typeof labels === 'undefined')
this.computeLabels(values);
this.computeLabels(values, sort);
else {
for (var i=0; i < values.length; i++) {
var value = values[i];
......@@ -181,28 +177,29 @@ GenericAxis.prototype = {
return value;
},
computeLabels: function(values) {
var cursor = 0;
var labels = {};
computeLabels: function(values, sort) {
var label_list = [];
var has_undefined;
for (var i = 0; i < values.length; i++) {
var value = values[i];
var key = this.applyConverter(value);
if (typeof key == 'undefined') {
has_undefined = true;
} else if (typeof labels[key] === 'undefined') {
labels[key] = this.label("line", cursor, key);
cursor++;
} else if (label_list.indexOf(key) == -1) {
label_list.push(key);
}
}
for (var idx in labels) {
var label = labels[idx];
this.addLabel(label.type, label.text, label.pos/cursor, label.text);
if (sort)
label_list.sort(this.compareLabels);
for (var idx = 0; idx < label_list.length; idx++) {
var label = label_list[idx];
this.addLabel("line", label, idx/label_list.length, label);
}
if (has_undefined) {
if (typeof this.label_mapping["?"] === 'undefined')
this.addLabel("line", "?", cursor, "?");
this.addLabel("line", "?", label_list.length + 1, "?");
}
},
......
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