Commit 1adf555b authored by Claire Kuchly's avatar Claire Kuchly
Browse files

add barcode data management

parent 4d29116d
......@@ -39,13 +39,7 @@ $(function () {
updateTableStatus($(this));
});
$(':checkbox#view_all_metrics').change(function(e) {
var state = $(this)[0].checked;
$(':checkbox.toogle-vis').each(function(e){
$(this).prop('checked', state);
$(this).change();
});
});
/*Check all metrics*/
$('#check_all_metrics').click(function(){
......@@ -56,9 +50,10 @@ $(function () {
});
/* Opens a window with all the element in the selected column */
$("#columns_extract").click(function() {
var samples = new Array() ;
/* Opens a graph will all the element in the selected column */
$("#create_graph").click(function(){
var samples = new Array() ;
$("input[id^='chk_sample_']:checked").each( function() {
samples.push( parseInt($(this).attr("id").split('_')[2]) ) ;
}) ;
......@@ -73,59 +68,132 @@ $(function () {
}
columns.sort(function(a,b){return a-b}) ;
samples.sort(function(a,b){return a-b}) ;
//Build thead
var thead = '<tr>' ;
for ( var int = 0; int < columns.length; int++) {
var id = columns[int];
if( jQuery.inArray( id, columns) != -1 && id == 1 ) {
thead += '<th>Samples</th>' ;
}
else {
thead += '<th><center>'+$("#th_id_"+id).text()+'</center></th>' ;
}
// which columns are checked
var column_id = new Array();
if (columns.length == 2) {
column_id.push($('#th_id_' + columns[1]).html());
} else if (columns.length == 3) {
column_id.push($('#th_id_' + columns[1]).html());
column_id.push($('#th_id_' + columns[2]).html());
}
thead += '</tr>' ;
thead = '<thead>' + thead + '</thead>' ;
//Build tbody
var tbody = "" ;
var pattern_regexp = new RegExp( '<a[^>]+class="[^"]*imglink[^"]*"[^>]+href="(fileadmin\/data\/analyze\/[^"]+)' ) ;
for( var i = 0 ; i < samples.length ; i++ ) {
tbody += '<tr>' ;
for( var j = 0 ; j < columns.length ; j++ ) {
var new_html = $('#sample_' + samples[i] + '_col_' + columns[j]).html() ;
var inner_exp = pattern_regexp.exec( new_html ) ;
// If the cell match the pattern
if( inner_exp != null )
// 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 btn-default" data-dismiss="modal" aria-hidden="true"><i class="glyphicon glyphicon-remove"></i> Close</button>');
$("#highcharts_container").css({'width' : '1045px','height' : '545px'});
// Set graph
var description = new Array();
var valeur1 = new Array();
var valeur2 = new Array();
$(":checked[id^=chk_sample_]").each(function(){
var index = $(this).attr("id").split("_")[2] ;
var index_description = $("#sample_" + index+"_col_1").html() ;
description.push(index_description);
var value = $("#sample_" + index+"_col_"+columns[1]+"").html();
valeur1.push(parseInt(value.replace(/ /g,"")));
var value = $("#sample_" + index+"_col_"+columns[2]+"").html();
if (value){
valeur2.push(parseInt(value.replace(/ /g,"")));
}
});
if (columns.length == 3) {
var options = {
chart: {
renderTo: 'highcharts_container',
type: 'column',
margin: [80, 80, 150, 100]
},
title: {
text: 'Barcode number values :'
},
xAxis: [{
categories: description,
labels: {
rotation: -45,
align: 'right',
x: 5,
y: 5,
style: { fontSize: '13px', fontFamily: 'Verdana, sans-serif' }
}
}],
yAxis: [
{ min: 0, title: { text: '# '+column_id[0] } },
{ min: 0, title: { text: '# '+column_id[1] }, opposite: true}
],
legend: { enabled: false },
tooltip: { shared: true },
series: [
{
name: column_id[0],
data: valeur1,
dataLabels: {
enabled: false,
}
},
{
if( inner_exp[1] === undefined ) {
inner_exp[1] = "" ;
name: column_id[1],
data: valeur2,
yAxis: 1,
dataLabels: {
enabled: false,
}
new_html = '<img src="' + inner_exp[1] + '" onload="resize(this, 0.5)">' ;
}
tbody += '<td>' + new_html + '</td>' ;
}
tbody += '</tr>' ;
}],
};
} else {
var options = {
chart: {
renderTo: 'highcharts_container',
type: 'column',
margin: [60, 60, 150, 80]
},
title: { text: 'Barcode number values :' },
xAxis: [{
categories: description,
labels: {
rotation: -45,
align: 'right',
x: 5,
y: 5,
style: { fontSize: '13px', fontFamily: 'Verdana, sans-serif' }
}
}],
yAxis: [
{ min: 0, title: { text: '# '+column_id[0] } }
],
legend: { enabled: false },
tooltip: { shared: true },
series: [
{
name: column_id[0],
data: valeur1,
dataLabels: {
enabled: false,
}
}]
};
}
tbody = '<tbody>' + tbody + '</tbody>' ;
// Display images table
$("#modal-label-tmpl").html("NG6 <small> " + $("#analyse_name").val() + "</small>");
$("#modal-body-tmpl").html('<div id="table_container"></div>');
$("#modal-foot-tmpl").html('<button class="btn btn-default" data-dismiss="modal" aria-hidden="true"><i class="glyphicon glyphicon-remove"></i> Close</button>');
$("#table_container ").css({
'max-height' : modal_height(300, 50)+'px',
'overflow-x' : 'auto',
'overflow-y' : 'auto'
});
$("#ng6modal .modal-content").css('width', '870px');
$("#ng6modal").css('margin-left', '-135px');
$("#table_container").append( '<table class="table table-striped table-bordered ">' + thead + tbody + '</table>' );
// Draw graph
var chart = new Highcharts.Chart(options);
resize_center_btmodal('#ng6modal', chart.chartWidth + 50);
//Display
$("#ng6modal").modal();
}
}) ;
}
}) ;
$(':checkbox.toogle-vis').each(function(e){
updateTableStatus($(this));
......
This diff is collapsed.
Supports Markdown
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