Posted in DOM, HTML, Javascript

Accumulating data for charts.js / Dynamic tables

document.getElementById(“categorysummary”).innerHTML = “”;

var newTable = “<table border=’1′ width=’99%’>”;

newTable += “<tr><th width=150px><b>” + cat + “</b></th><th width=200px><b>” + sub + “</b></th><th width=20px><b>” + actual + “</b></th><th width=20px><b>” + max + “</b></th><th width=20px><b>” + weight + “</b></th></tr>”;

 

for(var i=0; i<response.length; i++) {

myLabelarray[i] = response[i]._SUBCATEGORY;

cattofive = response[i]._CATTOFIVE;
myActualarray[i] = response[i]._CATTOFIVE;

catpoints = response[i]._CATPOINTS;
myMaxarray[i] = response[i]._CATPOINTS;

cat = response[i]._CAT;

catcalc = (cattofive / catpoints) * cat / 1;
catcalctot = catcalctot + catcalc;

catcalctot = round(catcalctot, 2);

newTable += “<tr><td>” + response[i]._CATEGORY + “</td><td>” + response[i]._SUBCATEGORY + “</td><td align=’right’>” + response[i]._CATTOFIVE + “</td><td align=’right’>” + response[i]._CATPOINTS + “</td><td align=’right’>” + response[i]._CAT + “</td></tr>”;

$(“#_OVERALLPERCENTAGE”).val(response[i]._OVERALL);
$(“#_WEIGHTEDPERCENTAGE”).val(catcalctot);

}

newTable += “</table>”;

document.getElementById(“categorysummary”).innerHTML = newTable;
myChartjs (myLabelarray, myMaxarray, myActualarray);

$(“#chart1”).hide();
$(“#chart2”).hide();