Commit 6f2e7466 authored by Marc Duez's avatar Marc Duez
Browse files

scatterplot.js/axis.js : add custom function to create more axis

parent 247e4dde
...@@ -205,10 +205,51 @@ Axis.prototype = { ...@@ -205,10 +205,51 @@ Axis.prototype = {
} }
}, },
custom: function(fct){
var self = this;
this.fct = fct;
var min,
max;
for (var i in this.m.clones){
var tmp;
try{
tmp = fct(i);
}catch(e){}
if ( typeof tmp != "undefined" ){
if ( tmp > max || typeof max == "undefined") max = tmp;
if ( tmp < min || typeof min == "undefined") min = tmp;
}
}
this.sizeScale = d3.scale.linear()
.domain([min, max+1])
.range([1, 0]);
this.min = min;
this.max = max;
this.pos = function(cloneID) {
var value;
try{
value = self.fct(cloneID);
}catch(e){}
if (typeof value != "undefined"){
return self.sizeScale(value)
}else{
return self.min
}
}
this.computeCustomLabels(min, max+1, true, false, true);
},
/* /*
* TODO linear/log percent/value parameter * TODO linear/log percent/value parameter
* */ * */
custom: function(min, max, reverse, percent, linear){ computeCustomLabels: function(min, max, reverse, percent, linear){
this.labels = []; this.labels = [];
var h = (max-min)/5 var h = (max-min)/5
......
...@@ -106,7 +106,8 @@ function ScatterPlot(id, model) { ...@@ -106,7 +106,8 @@ function ScatterPlot(id, model) {
["allele_j", "allele J"], ["allele_j", "allele J"],
["Size", "abundance"], ["Size", "abundance"],
["sequenceLength", "clone length"], ["sequenceLength", "clone length"],
["n", "N length"] ["n", "N length"],
["lengthCDR3", "CDR3 length"]
]; ];
//Menu with graph distrib' (see initMenu function) //Menu with graph distrib' (see initMenu function)
...@@ -1627,6 +1628,9 @@ ScatterPlot.prototype = { ...@@ -1627,6 +1628,9 @@ ScatterPlot.prototype = {
if (splitMethod == "n") { if (splitMethod == "n") {
axis.useNlength() axis.useNlength()
} }
if (splitMethod == "lengthCDR3") {
axis.custom(function(cloneID){ return m.clone(cloneID).seg["cdr3"].length})
}
}, },
/* Fonction permettant de mettre à jour le menu /* Fonction permettant de mettre à jour le menu
......
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