Răsfoiți Sursa

Add code to display recipe averages for analytics strand.

Lee Morgan 5 ani în urmă
părinte
comite
a8081e6159
2 a modificat fișierele cu 16 adăugiri și 2 ștergeri
  1. 8 1
      views/dashboardPage/bundle.js
  2. 8 1
      views/dashboardPage/js/strands/analytics2.js

+ 8 - 1
views/dashboardPage/bundle.js

@@ -3055,8 +3055,15 @@ let analytics = {
 
 
         Plotly.newPlot("recipeSalesGraph", [trace], layout);
         Plotly.newPlot("recipeSalesGraph", [trace], layout);
 
 
-        //display the boxes at the bottom
+        //Display the boxes at the bottom
+        let avg = 0;
+        for(let i = 0; i < quantities.length; i++){
+            avg += quantities[i];
+        }
+        avg = avg / quantities.length;
 
 
+        document.getElementById("recipeAvgUse").innerText = avg.toFixed(2);
+        document.getElementById("recipeAvgRevenue").innerText = `$${(avg * recipe.price).toFixed(2)}`
     },
     },
 
 
     switchDisplay: function(){
     switchDisplay: function(){

+ 8 - 1
views/dashboardPage/js/strands/analytics2.js

@@ -195,8 +195,15 @@ let analytics = {
 
 
         Plotly.newPlot("recipeSalesGraph", [trace], layout);
         Plotly.newPlot("recipeSalesGraph", [trace], layout);
 
 
-        //display the boxes at the bottom
+        //Display the boxes at the bottom
+        let avg = 0;
+        for(let i = 0; i < quantities.length; i++){
+            avg += quantities[i];
+        }
+        avg = avg / quantities.length;
 
 
+        document.getElementById("recipeAvgUse").innerText = avg.toFixed(2);
+        document.getElementById("recipeAvgRevenue").innerText = `$${(avg * recipe.price).toFixed(2)}`
     },
     },
 
 
     switchDisplay: function(){
     switchDisplay: function(){