Commit 4eb4af43 authored by Penom Nom's avatar Penom Nom
Browse files

Fix bug with scale.

parent be6e35c3
......@@ -33,7 +33,7 @@ $(function () {
*/
$(".length-view-btn").click(function() {
var max_xvalues = 30;
var nb_step = 30;
if ($(":checked[id^=chk_sample_]").size() > 0) {
//Set dialog window
......@@ -56,40 +56,40 @@ $(function () {
if (max < tmax) { max = tmax; }
});
var x_table = new Array();
var x_table_labels = new Array();
var y_table = new Array();
var step = Math.ceil((max-min)/max_xvalues);
for (var i=min; i<=max; i += step) {
x_table.push(String(i));
var step_size = Math.ceil((max-min)/nb_step);
var x_labels = new Array();
for( var i=min ; i<=max ; i += step_size ) {
x_labels.push( String(i) + "-" + String(i + step_size -1) );
}
for (var i=0; i<x_table.length-1; i++) {
x_table_labels.push(x_table[i] + "-" + String(parseInt(x_table[i+1]) -1));
}
var y_table = new Array();
$(":checked[id^=chk_sample_]").each(function(){
var index = $(this).attr("id").split("_")[2];
var c_table = new Array();
for (var i=min; i<=max; i += step) {
c_table.push(0);
}
var index_array = $("#size_extended_"+index).val().split(","),
value_array = $("#nb_size_extended_"+index).val().split(",");
var index_array = $("#size_extended_"+index).val().split(",") ;
var value_array = $("#nb_size_extended_"+index).val().split(",") ;
for (var i=0; i<x_table.length-1; i++) {
var c_val = 0;
for (var j=0; j<index_array.length; j++) {
if (parseInt(index_array[j]) >= x_table[i] && parseInt(index_array[j]) < x_table[i+1]) {
c_table[i] += parseInt(value_array[j]);
// Init values
var y_values = new Array();
for (var i=0; i<x_labels.length; i++) {
y_values.push(0);
}
// For each step
for( var i=0 ; i<x_labels.length ; i++ ) {
for( var j=0 ; j<index_array.length ; j++ ) {
if( parseInt(index_array[j]) >= (min + (i*step_size))
&& parseInt(index_array[j]) < (min + (i*step_size) + step_size) ) {
y_values[i] += parseInt(value_array[j]);
}
}
}
c_table = c_table.slice(0, -1);
y_table.push({
name: $("#sample_id_"+index).html(),
data: c_table
data: y_values
});
});
});
chart = new Highcharts.Chart({
chart: {
......@@ -101,7 +101,7 @@ $(function () {
x: -20 //center
},
xAxis: {
categories: x_table_labels,
categories: x_labels,
title: {
text: "Sequence length (bp)"
},
......
......@@ -29,14 +29,13 @@
$(function () {
/*
* Define functions in charge to visualize venn charts
* Define functions in charge to visualize charts
*/
$(".length-view-btn").click(function() {
var max_xvalues = 30;
var nb_step = 30;
if ($(":checked[id^=chk_sample_]").size() > 0) {
//Set dialog window
// Set dialog window
$("#modal-label-tmpl").html("NG6 <small> " + $("#analyse_name").val() + "</small>");
$("#modal-body-tmpl").html('<div id="highcharts_container"></div>');
$("#modal-foot-tmpl").html('<button class="btn" data-dismiss="modal" aria-hidden="true"><i class="icon-remove"></i> Close</button>');
......@@ -44,7 +43,7 @@ $(function () {
$("#ng6modal").css('width', 'auto');
$("#ng6modal").css('margin-left', '-435px');
//Set graph
// Set graph
var min = 1000000,
max = 0;
$(":checked[id^=chk_sample_]").each(function(){
......@@ -56,41 +55,42 @@ $(function () {
if (max < tmax) { max = tmax; }
});
var step_size = Math.ceil((max-min)/nb_step);
var x_table = new Array();
var x_table_labels = new Array();
var y_table = new Array();
var step = Math.ceil((max-min)/max_xvalues);
for (var i=min; i<=max; i += step) {
x_table.push(String(i));
var x_labels = new Array();
for( var i=min ; i<=max ; i += step_size ) {
x_labels.push( String(i) + "-" + String(i + step_size -1) );
}
for (var i=0; i<x_table.length-1; i++) {
x_table_labels.push(x_table[i] + "-" + String(parseInt(x_table[i+1]) -1));
}
var y_table = new Array();
$(":checked[id^=chk_sample_]").each(function(){
var index = $(this).attr("id").split("_")[2];
var c_table = new Array();
for (var i=min; i<=max; i += step) {
c_table.push(0);
var index = $(this).attr("id").split("_")[2] ;
var index_array = $("#inserts_sizes_" + index).val().split(",") ;
var value_array = $("#nb_inserts_sizes_" + index).val().split(",") ;
// Init values
var y_values = new Array();
for (var i=0; i<x_labels.length; i++) {
y_values.push(0);
}
var index_array = $("#inserts_sizes_"+index).val().split(","),
value_array = $("#nb_inserts_sizes_"+index).val().split(",");
for (var i=0; i<x_table.length-1; i++) {
var c_val = 0;
for (var j=0; j<index_array.length; j++) {
if (parseInt(index_array[j]) >= x_table[i] && parseInt(index_array[j]) < x_table[i+1]) {
c_table[i] += parseInt(value_array[j]);
// For each step
for( var i=0 ; i<x_labels.length ; i++ ) {
for( var j=0 ; j<index_array.length ; j++ ) {
if( parseInt(index_array[j]) >= (min + (i*step_size))
&& parseInt(index_array[j]) < (min + (i*step_size) + step_size) ) {
y_values[i] += parseInt(value_array[j]);
}
}
}
c_table = c_table.slice(0, -1);
y_table.push({
name: $("#sample_id_"+index).html() ? $("#sample_id_"+index).html() + " " + $("#orientation_id_"+index).html() : $("#orientation_id_"+index).html(),
data: c_table
data: y_values
});
});
});
// Draw graph
chart = new Highcharts.Chart({
chart: {
renderTo: 'highcharts_container',
......@@ -101,7 +101,7 @@ $(function () {
x: -20 //center
},
xAxis: {
categories: x_table_labels,
categories: x_labels,
title: {
text: "Insert length (bp)"
},
......
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