mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-25 00:23:12 +09:00
Import/export line on same graph on storage page to save space
This commit is contained in:
1 parent
0735aa2db4
commit
7046ba58d3
1 file changed
+23
-6
+23
-6
@@ -100,8 +100,6 @@ function getItemStatData(item, callback){
|
|||||||
});
|
});
|
||||||
xhr.send(data);
|
xhr.send(data);
|
||||||
}
|
}
|
||||||
////// drawChart("contentGraph", /api/getStats)
|
|
||||||
|
|
||||||
|
|
||||||
function makeItemGraphs(itemName){
|
function makeItemGraphs(itemName){
|
||||||
getJSON("/api/slaves", function(err, slaves){
|
getJSON("/api/slaves", function(err, slaves){
|
||||||
@@ -115,9 +113,9 @@ function makeItemGraphs(itemName){
|
|||||||
slaveIDs.unshift("unknown");
|
slaveIDs.unshift("unknown");
|
||||||
slaveIDs.forEach(function(slaveID){
|
slaveIDs.forEach(function(slaveID){
|
||||||
if(slaveID == "unknown" || Date.now() - slaves[slaveID].time < 120000 || JSON.parse(localStorage.settings)["Display offline slaves"]){
|
if(slaveID == "unknown" || Date.now() - slaves[slaveID].time < 120000 || JSON.parse(localStorage.settings)["Display offline slaves"]){
|
||||||
|
HTML += '<div id="contentGraph'+slaveID+'" class="storageGraph" style="width: 100%;"></div>';
|
||||||
["place", "remove"].forEach(statistic => {
|
["place", "remove"].forEach(statistic => {
|
||||||
console.log("Making chart for "+slaveID+"'s "+statistic+" statistic");
|
console.log("Making chart for "+slaveID+"'s "+statistic+" statistic");
|
||||||
HTML += '<div id="'+statistic+'contentGraph'+slaveID+'" class="storageGraph" style="width: 100%;"></div>';
|
|
||||||
|
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
let xmlhttp = new XMLHttpRequest(); // new HttpRequest instance
|
let xmlhttp = new XMLHttpRequest(); // new HttpRequest instance
|
||||||
@@ -133,8 +131,19 @@ function makeItemGraphs(itemName){
|
|||||||
slaveDisplayName = slaves[slaveID].instanceName;
|
slaveDisplayName = slaves[slaveID].instanceName;
|
||||||
} catch(e) {}
|
} catch(e) {}
|
||||||
let whatGraphIsIt = "Items sent to cluster from";
|
let whatGraphIsIt = "Items sent to cluster from";
|
||||||
if(statistic == "remove") whatGraphIsIt = "Items taken from cluster by"
|
if(statistic == "remove") whatGraphIsIt = "Items taken from cluster by";
|
||||||
drawChart(statistic+"contentGraph"+slaveID, [JSON.parse(xmlhttp.response).data], `${whatGraphIsIt} ${slaveDisplayName} (${slaveID}) ${itemName}`);
|
|
||||||
|
let chartData = JSON.parse(xmlhttp.response).data;
|
||||||
|
switch(statistic){
|
||||||
|
case "place":
|
||||||
|
chartData.name = "Items exported:";
|
||||||
|
break;
|
||||||
|
case "remove":
|
||||||
|
chartData.name = "Items imported:";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
drawChartWhenCalledTwice(chartData, whatGraphIsIt + " " + slaveDisplayName);
|
||||||
|
//drawChart(statistic+"contentGraph"+slaveID, [JSON.parse(xmlhttp.response).data], `${whatGraphIsIt} ${slaveDisplayName} (${slaveID}) ${itemName}`);
|
||||||
// console.log(JSON.parse(xmlhttp.response).data);
|
// console.log(JSON.parse(xmlhttp.response).data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -142,6 +151,13 @@ function makeItemGraphs(itemName){
|
|||||||
xmlhttp.send(JSON.stringify({statistic:statistic, itemName:itemName, slaveID:slaveID}));
|
xmlhttp.send(JSON.stringify({statistic:statistic, itemName:itemName, slaveID:slaveID}));
|
||||||
},1);
|
},1);
|
||||||
});
|
});
|
||||||
|
let chartLines = [];
|
||||||
|
function drawChartWhenCalledTwice(data, slaveDisplayName){
|
||||||
|
chartLines.push(data);
|
||||||
|
if(chartLines.length >= 2){
|
||||||
|
drawChart("contentGraph"+slaveID, chartLines, `${slaveDisplayName} (${slaveID}) ${itemName}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
document.querySelector("#graphDisplay > #storageGraphContainer").innerHTML = HTML;
|
document.querySelector("#graphDisplay > #storageGraphContainer").innerHTML = HTML;
|
||||||
@@ -156,7 +172,8 @@ function drawChart(selector, chartData, title) {
|
|||||||
text: title || "Production graph"
|
text: title || "Production graph"
|
||||||
},
|
},
|
||||||
toolTip:{
|
toolTip:{
|
||||||
content: "{name}: {y}"
|
shared: true,
|
||||||
|
// content: "{name}: {y}",
|
||||||
},
|
},
|
||||||
zoomEnabled: true,
|
zoomEnabled: true,
|
||||||
axisY:{
|
axisY:{
|
||||||
|
|||||||
Reference in new issue
Block a user