always show latest difficulty on hashrate chart

This commit is contained in:
Mononaut 2023-07-12 12:58:48 +09:00
parent 00282b79b8
commit 0dd9867a1f
No known key found for this signature in database
GPG Key ID: A3F058E41374C04E

View File

@ -109,6 +109,14 @@ export class HashrateChartComponent implements OnInit {
tap((response: any) => {
const data = response.body;
// always include the latest difficulty
if (data.difficulty.length && data.difficulty[data.difficulty.length - 1].difficulty !== data.currentDifficulty) {
data.difficulty.push({
timestamp: Date.now() / 1000,
difficulty: data.currentDifficulty
});
}
// We generate duplicated data point so the tooltip works nicely
const diffFixed = [];
let diffIndex = 1;
@ -137,6 +145,14 @@ export class HashrateChartComponent implements OnInit {
++diffIndex;
}
while (diffIndex <= data.difficulty.length) {
diffFixed.push({
timestamp: data.difficulty[diffIndex - 1].time,
difficulty: data.difficulty[diffIndex - 1].difficulty
});
diffIndex++;
}
let maResolution = 15;
const hashrateMa = [];
for (let i = maResolution - 1; i < data.hashrates.length; ++i) {