Skip to content

Commit

Permalink
bottom margin adjusted based on longest treatment name
Browse files Browse the repository at this point in the history
  • Loading branch information
MingChen0919 committed Jul 26, 2016
1 parent afe1c32 commit aa28947
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
10 changes: 10 additions & 0 deletions includes/feature_heatmap_form.inc
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,18 @@ function feature_heatmap_form_submit($form, &$form_state){
$text[] = $descriptions;
}

// obtain max length of treatment names
$max_treatment_name = 0;
foreach($x as $name){
if(strlen($name)>$max_treatment_name){
$max_treatment_name = strlen($name);
}
}

// use the max id length times 8 to get an appropriate pixel number for left margin
$_SESSION['left_margin'] = $max_id_len * 8;
// use the max length of treatment name times 7 to get an appropriate pixel number of bottom margin
$_SESSION['bottom_margin'] = $max_treatment_name * 7;

// Build variable for plotly function in js file.
// Note that this variable requires that the x, y, z and type are not within double quotations
Expand Down
7 changes: 5 additions & 2 deletions js/heatmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
var heatmap_data = eval(settings.tripal_analysis_expression.heatmap_data);
//var layout = eval(settings.tripal_analysis_expression.heatmap_layout);
var left_margin = settings.tripal_analysis_expression.left_margin;
var bottom_margin = settings.tripal_analysis_expression.bottom_margin;
var layout = {
title: 'Expression Heatmap',
/*
xaxis: {
title: 'Treatment'
title: bottom_margin
},
*/
margin: {
b: 100,
b: bottom_margin,
l: left_margin
}
}
Expand Down
1 change: 1 addition & 0 deletions tripal_analysis_expression.module
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,7 @@ function tripal_analysis_expression_block_view($delta = ''){
$block['content'] = '<div id="vis_expression"></div>';
drupal_add_js(array('tripal_analysis_expression' => array('heatmap_data' => $_SESSION['heatmap_data'])), array('type' => 'setting'));
drupal_add_js(array('tripal_analysis_expression' => array('left_margin' => $_SESSION['left_margin'])), array('type' => 'setting'));
drupal_add_js(array('tripal_analysis_expression' => array('bottom_margin' => $_SESSION['bottom_margin'])), array('type' => 'setting'));
} else {
$block['subject'] = '';
$block['content'] = t('<b><span style="color:red">Either you have not entered any features or no expression data available for the features you entered.</span></b>');
Expand Down

0 comments on commit aa28947

Please sign in to comment.