Button to show all datasets

Also #46
This commit is contained in:
Danielv123 committed 2017-03-17 10:55:34 +01:00
1 parent 8967189fd2
commit 3186fa8fb7
1 file changed
+14 -2
+14 -2
View File
@@ -23,6 +23,7 @@ setTimeout(function() {
HTML += "<h2>ID: " + slaveData[key].unique + "</h2><p>Last seen: "+seenDate+"</p><p>IP: "+slaveData[key].publicIP +":"+ slaveData[key].serverPort+"</p>"
HTML += "<p>Host: "+slaveData[key].mac+"</p>";
HTML += "<button onclick='hideAllDatasets(\"" + slaveData[key].unique + "\")\'>Hide all</button>";
HTML += "<button onclick='showAllDatasets(\"" + slaveData[key].unique + "\")\'>Show all</button>";
HTML += "</div>";
}
}
@@ -46,8 +47,8 @@ setTimeout(function() {
// ID of slave, ID of canvasjs div without #
function makeGraph(slaveID, selector) {
post("api/getStats", {slaveID: slaveID}, function(data){
console.log("Building chart " + slaveID + " with this data:")
console.log(data)
//console.log("Building chart " + slaveID + " with this data:")
//console.log(data)
if(data.length > 0) {
// find keys
let itemNames = [];
@@ -156,6 +157,17 @@ function hideAllDatasets(chartID) {
return false;
}
}
function showAllDatasets(chartID) {
if(chartsByID[chartID]) {
let chart = chartsByID[chartID];
for(let i = 0; i < chart.options.data.length; i++) {
chart.options.data[i].visible = true;
}
chart.render();
} else {
return false;
}
}
// function to sort arrays of objects after a keys value
function sortByKey(array, key) {