mirror of
https://github.com/mempool/mempool.git
synced 2025-02-23 22:46:54 +01:00
Merge pull request #2085 from mempool/nymkappa/bugfix/hashrate-no-difficulty
[Hashrate chart] Fix javascript error if difficulty array is empty
This commit is contained in:
commit
57e033a32c
1 changed files with 9 additions and 5 deletions
|
@ -109,7 +109,7 @@ export class HashrateChartComponent implements OnInit {
|
||||||
while (hashIndex < data.hashrates.length) {
|
while (hashIndex < data.hashrates.length) {
|
||||||
diffFixed.push({
|
diffFixed.push({
|
||||||
timestamp: data.hashrates[hashIndex].timestamp,
|
timestamp: data.hashrates[hashIndex].timestamp,
|
||||||
difficulty: data.difficulty[data.difficulty.length - 1].difficulty
|
difficulty: data.difficulty.length > 0 ? data.difficulty[data.difficulty.length - 1].difficulty : null
|
||||||
});
|
});
|
||||||
++hashIndex;
|
++hashIndex;
|
||||||
}
|
}
|
||||||
|
@ -231,11 +231,15 @@ export class HashrateChartComponent implements OnInit {
|
||||||
} else if (tick.seriesIndex === 1) { // Difficulty
|
} else if (tick.seriesIndex === 1) { // Difficulty
|
||||||
let difficultyPowerOfTen = hashratePowerOfTen;
|
let difficultyPowerOfTen = hashratePowerOfTen;
|
||||||
let difficulty = tick.data[1];
|
let difficulty = tick.data[1];
|
||||||
if (this.isMobile()) {
|
if (difficulty === null) {
|
||||||
difficultyPowerOfTen = selectPowerOfTen(tick.data[1]);
|
difficultyString = `${tick.marker} ${tick.seriesName}: No data<br>`;
|
||||||
difficulty = Math.round(tick.data[1] / difficultyPowerOfTen.divider);
|
} else {
|
||||||
|
if (this.isMobile()) {
|
||||||
|
difficultyPowerOfTen = selectPowerOfTen(tick.data[1]);
|
||||||
|
difficulty = Math.round(tick.data[1] / difficultyPowerOfTen.divider);
|
||||||
|
}
|
||||||
|
difficultyString = `${tick.marker} ${tick.seriesName}: ${formatNumber(difficulty, this.locale, '1.2-2')} ${difficultyPowerOfTen.unit}<br>`;
|
||||||
}
|
}
|
||||||
difficultyString = `${tick.marker} ${tick.seriesName}: ${formatNumber(difficulty, this.locale, '1.2-2')} ${difficultyPowerOfTen.unit}<br>`;
|
|
||||||
} else if (tick.seriesIndex === 2) { // Hashrate MA
|
} else if (tick.seriesIndex === 2) { // Hashrate MA
|
||||||
let hashrate = tick.data[1];
|
let hashrate = tick.data[1];
|
||||||
if (this.isMobile()) {
|
if (this.isMobile()) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue