aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzsloan2019-12-11 15:12:01 -0600
committerzsloan2019-12-11 15:12:01 -0600
commitab71bae08b650610bc675b708173eaddc6b4dced (patch)
tree48198c90376785d90f99ddf23748a30eab4859cc
parent242f230101cc0b43e5cf3f910af160aa0d526267 (diff)
downloadgenenetwork2-ab71bae08b650610bc675b708173eaddc6b4dced.tar.gz
Added a parameter indicating how to align case attributes in the sample table on the trait page (so that numbers are aligned right)
-rw-r--r--wqflask/wqflask/show_trait/SampleList.py12
-rw-r--r--wqflask/wqflask/templates/show_trait.html2
2 files changed, 14 insertions, 0 deletions
diff --git a/wqflask/wqflask/show_trait/SampleList.py b/wqflask/wqflask/show_trait/SampleList.py
index dc98eb2b..aa6ada5a 100644
--- a/wqflask/wqflask/show_trait/SampleList.py
+++ b/wqflask/wqflask/show_trait/SampleList.py
@@ -112,6 +112,18 @@ class SampleList(object):
self.attributes[key].distinct_values = [item.Value for item in values]
self.attributes[key].distinct_values.sort(key=natural_sort_key)
+ all_numbers = True
+ for value in self.attributes[key].distinct_values:
+ try:
+ val_as_float = float(value)
+ except:
+ all_numbers = False
+
+ if all_numbers:
+ self.attributes[key].alignment = "right"
+ else:
+ self.attributes[key].alignment = "left"
+
def get_extra_attribute_values(self):
if self.attributes:
query = '''
diff --git a/wqflask/wqflask/templates/show_trait.html b/wqflask/wqflask/templates/show_trait.html
index 0b4618f1..6719485a 100644
--- a/wqflask/wqflask/templates/show_trait.html
+++ b/wqflask/wqflask/templates/show_trait.html
@@ -260,6 +260,7 @@
{% if sample_groups[0].attributes|length > 0 %}
{% for attribute in sample_groups[0].attributes|sort() %}
$('td', row).eq(attribute_start_pos + {{ loop.index }}).addClass("column_name-{{ sample_groups[0].attributes[attribute].name }}")
+ $('td', row).eq(attribute_start_pos + {{ loop.index }}).attr("style", "text-align: {{ sample_groups[0].attributes[attribute].alignment }}; padding-top: 2px; padding-bottom: 0px;")
{% endfor %}
{% endif %}
},
@@ -403,6 +404,7 @@
{% if sample_groups[1].attributes|length > 0 %}
{% for attribute in sample_groups[1].attributes|sort() %}
$('td', row).eq(attribute_start_pos + {{ loop.index }}).addClass("column_name-{{ sample_groups[1].attributes[attribute].name }}")
+ $('td', row).eq(attribute_start_pos + {{ loop.index }}).attr("style", "text-align: {{ sample_groups[1].attributes[attribute].alignment }}; padding-top: 2px; padding-bottom: 0px;")
{% endfor %}
{% endif %}
},