diff options
author | zsloan | 2018-04-04 17:51:13 +0000 |
---|---|---|
committer | zsloan | 2018-04-04 17:51:13 +0000 |
commit | e246822f359938be6af7e3f5587dea635ff5f9df (patch) | |
tree | 8c83868657f35c3dcabaa2f3106b73f45da05012 /wqflask | |
parent | 57e6d490cf8c7acb326552456a597f1e1cdecc2c (diff) | |
download | genenetwork2-e246822f359938be6af7e3f5587dea635ff5f9df.tar.gz |
Changed bar chart y axis range to avoid situation where all variation is clustered at the top or bottom
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/wqflask/static/new/javascript/show_trait.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/wqflask/wqflask/static/new/javascript/show_trait.js b/wqflask/wqflask/static/new/javascript/show_trait.js index 117d8f12..dfdafaf0 100644 --- a/wqflask/wqflask/static/new/javascript/show_trait.js +++ b/wqflask/wqflask/static/new/javascript/show_trait.js @@ -789,7 +789,41 @@ type: 'bar' }; root.bar_data = [bar_trace] + + positive_error_vals = [] + negative_error_vals = [] + for (i = 0;i < get_sample_vals(sample_lists[0]).length; i++){ + if (get_sample_errors(sample_lists[0])[i] != undefined) { + positive_error_vals.push(get_sample_vals(sample_lists[0])[i] + get_sample_errors(sample_lists[0])[i]) + negative_error_vals.push(get_sample_vals(sample_lists[0])[i] - get_sample_errors(sample_lists[0])[i]) + } else { + positive_error_vals.push(get_sample_vals(sample_lists[0])[i]) + negative_error_vals.push(get_sample_vals(sample_lists[0])[i]) + } + } + + // Calculate the y axis cutoff to avoid a situation where all bar variation is clustered at the top of the chart + min_y_val = Math.min(...negative_error_vals) + max_y_val = Math.max(...positive_error_vals) + + if (min_y_val == 0) { + range_bottom = 0; + } else { + range_top = max_y_val + Math.abs(max_y_val)*0.1 + range_bottom = min_y_val - Math.abs(min_y_val)*0.1 + if (min_y_val > 0) { + range_bottom = min_y_val - 0.1*Math.abs(min_y_val) + } else if (min_y_val < 0) { + range_bottom = min_y_val + 0.1*min_y_val + } else { + range_bottom = 0 + } + } + var layout = { + yaxis: { + range: [range_bottom, range_top] + }, width: 1200, height: 500, margin: { |