added custom TH/s formatting to graphs

This commit is contained in:
UpstreamData
2022-03-04 13:39:23 -07:00
parent 97a9b59acc
commit 4534b09532
3 changed files with 36 additions and 6 deletions

View File

@@ -46,7 +46,7 @@ async def dashboard_websocket(websocket: WebSocket):
all_miner_data.sort(key=lambda x: x["ip"]) all_miner_data.sort(key=lambda x: x["ip"])
await websocket.send_json({"datetime": datetime.datetime.now().isoformat(), await websocket.send_json({"datetime": datetime.datetime.now().isoformat(),
"miners": all_miner_data}) "miners": all_miner_data})
await asyncio.sleep(5) await asyncio.sleep(.1)
except WebSocketDisconnect: except WebSocketDisconnect:
print("Websocket disconnected.") print("Websocket disconnected.")
pass pass

View File

@@ -27,7 +27,6 @@ ws.onmessage = function(event) {
document.getElementById(new_data["miners"][i]["ip"] + "_error").remove() document.getElementById(new_data["miners"][i]["ip"] + "_error").remove()
} }
total_hashrate += parseFloat(new_data["miners"][i]["hashrate"]) total_hashrate += parseFloat(new_data["miners"][i]["hashrate"])
console.log(total_hashrate)
} }
}; };
var chart = document.getElementById("line-chart") var chart = document.getElementById("line-chart")
@@ -85,17 +84,34 @@ var minerDataChart = new Chart(document.getElementById("line-chart"), {
borderColor: chartGradient, borderColor: chartGradient,
borderWidth: 1 borderWidth: 1
}, },
legend: {
labels: {
color: chartGradient
}
},
tooltip: {
callbacks: {
label: function(data) {
return data.dataset.data[data.dataIndex] + " TH/s";
}
}
}
}, },
scales: { scales: {
y: { y: {
min: 0, // minimum value min: 0, // minimum value
suggestedMax: 100, suggestedMax: 100,
stepSize: 10 stepSize: 10,
ticks: {
callback: function(value, index, ticks) {
return value + " TH/s";
}
}
}, },
x: { x: {
ticks: { ticks: {
maxTicksLimit: 6, maxTicksLimit: 6,
maxRotation: 0 maxRotation: 0,
} }
} }
} }

View File

@@ -121,14 +121,28 @@ var minerDataChart = new Chart(document.getElementById("line-chart"), {
borderWidth: 1 borderWidth: 1
}, },
legend: { legend: {
display: false labels: {
color: chartGradient
}
},
tooltip: {
callbacks: {
label: function(data) {
return data.dataset.data[data.dataIndex] + " TH/s";
}
}
} }
}, },
scales: { scales: {
y: { y: {
min: 0, // minimum value min: 0, // minimum value
suggestedMax: 10, suggestedMax: 10,
stepSize: 1 stepSize: 1,
ticks: {
callback: function(value, index, ticks) {
return value + " TH/s";
}
}
}, },
x: { x: {
ticks: { ticks: {