Skip to content
Snippets Groups Projects
Commit b7a3250b authored by Hervé  MENAGER's avatar Hervé MENAGER
Browse files

avoid crashing PCA and LE-LLE views if no data available

parent 1c95e9d6
No related branches found
No related tags found
1 merge request!13Master
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
{% block pagetitle %}Efficiencies: iPPI-DB biplot LE versus LLE{% endblock%} {% block pagetitle %}Efficiencies: iPPI-DB biplot LE versus LLE{% endblock%}
{% block view_content %} {% block view_content %}
{% if le_lle_biplot_data %}
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<canvas id="le_lle_biplot"></canvas> <canvas id="le_lle_biplot"></canvas>
...@@ -21,4 +21,9 @@ ...@@ -21,4 +21,9 @@
<script> <script>
drawCompoundsBiplotChart('le_lle_biplot', preparePerFamilyBiplotData({{ le_lle_biplot_data | safe }}), 'pharmacology', {'legend':{'position':'right'}}); drawCompoundsBiplotChart('le_lle_biplot', preparePerFamilyBiplotData({{ le_lle_biplot_data | safe }}), 'pharmacology', {'legend':{'position':'right'}});
</script> </script>
{% else %}
<div class="alert alert-danger" role="alert">
The LE-LLE data are not currently available
</div>
{% endif %}
{% endblock %} {% endblock %}
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
{% block pagetitle %}PHYSICOCHEMISTRY{% endblock%} {% block pagetitle %}PHYSICOCHEMISTRY{% endblock%}
{% block view_content %} {% block view_content %}
{% if pca_biplot_data %}
<div class="row"> <div class="row">
<canvas id="pca_biplot"></canvas> <canvas id="pca_biplot"></canvas>
</div> </div>
...@@ -17,4 +18,9 @@ ...@@ -17,4 +18,9 @@
<script> <script>
drawCompoundsBiplotChart('pca_biplot', preparePerFamilyBiplotData({{ pca_biplot_data | safe }}.data), 'physicochemical', { 'legend': { 'position': 'right' } }); drawCompoundsBiplotChart('pca_biplot', preparePerFamilyBiplotData({{ pca_biplot_data | safe }}.data), 'physicochemical', { 'legend': { 'position': 'right' } });
</script> </script>
{% else %}
<div class="alert alert-danger" role="alert">
The PCA data are not currently available
</div>
{% endif %}
{% endblock %} {% endblock %}
\ No newline at end of file
...@@ -149,7 +149,10 @@ def about_pharmacology(request): ...@@ -149,7 +149,10 @@ def about_pharmacology(request):
def about_le_lle(request): def about_le_lle(request):
context = {"le_lle_biplot_data": LeLleBiplotData.objects.get().le_lle_biplot_data} try:
context = {"le_lle_biplot_data": LeLleBiplotData.objects.get().le_lle_biplot_data}
except LeLleBiplotData.DoesNotExist:
context = {}
return render(request, "about-le-lle.html", context=context) return render(request, "about-le-lle.html", context=context)
...@@ -249,7 +252,10 @@ def about_physicochemistry(request): ...@@ -249,7 +252,10 @@ def about_physicochemistry(request):
def about_pca(request): def about_pca(request):
context = {"pca_biplot_data": PcaBiplotData.objects.get().pca_biplot_data} try:
pca_biplot = json.loads(PcaBiplotData.objects.get().pca_biplot_data) context = {"pca_biplot_data": PcaBiplotData.objects.get().pca_biplot_data}
context["pca_biplot_cc"] = pca_biplot["correlation_circle"] pca_biplot = json.loads(PcaBiplotData.objects.get().pca_biplot_data)
context["pca_biplot_cc"] = pca_biplot["correlation_circle"]
except PcaBiplotData.DoesNotExist:
context = {}
return render(request, "about-pca.html", context=context) return render(request, "about-pca.html", context=context)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment