Cleanup hashrate/difficulty widget

This commit is contained in:
nymkappa
2022-03-14 20:00:19 +01:00
parent 3fd42e9f26
commit 5dfc272bed
5 changed files with 119 additions and 63 deletions

View File

@@ -109,21 +109,10 @@ export class HashrateChartComponent implements OnInit {
(new Date().getTime() / 1000) - (data.oldestIndexedBlockTimestamp)
) / 3600 / 24;
const tableData = [];
for (let i = data.difficulty.length - 1; i > 0; --i) {
const selectedPowerOfTen: any = selectPowerOfTen(data.difficulty[i].difficulty);
const change = (data.difficulty[i].difficulty / data.difficulty[i - 1].difficulty - 1) * 100;
tableData.push(Object.assign(data.difficulty[i], {
change: change,
difficultyShorten: formatNumber(
data.difficulty[i].difficulty / selectedPowerOfTen.divider,
this.locale, '1.2-2') + selectedPowerOfTen.unit
}));
}
return {
availableTimespanDay: availableTimespanDay,
difficulty: this.tableOnly ? tableData.slice(0, 5) : tableData,
currentDifficulty: Math.round(data.difficulty[data.difficulty.length - 1].difficulty * 100) / 100,
currentHashrate: data.hashrates[data.hashrates.length - 1].avgHashrate,
};
}),
retryWhen((errors) => errors.pipe(
@@ -166,6 +155,7 @@ export class HashrateChartComponent implements OnInit {
'#D81B60',
],
grid: {
top: 30,
right: this.right,
left: this.left,
bottom: this.widget ? 30 : 60,
@@ -209,7 +199,7 @@ export class HashrateChartComponent implements OnInit {
type: 'time',
splitNumber: (this.isMobile() || this.widget) ? 5 : 10,
},
legend: data.hashrates.length === 0 ? undefined : {
legend: (this.widget || data.hashrates.length === 0) ? undefined : {
data: [
{
name: 'Hashrate',
@@ -241,7 +231,6 @@ export class HashrateChartComponent implements OnInit {
return value.min * 0.9;
},
type: 'value',
name: 'Hashrate',
axisLabel: {
color: 'rgb(110, 112, 121)',
formatter: (val) => {
@@ -259,7 +248,6 @@ export class HashrateChartComponent implements OnInit {
return value.min * 0.9;
},
type: 'value',
name: 'Difficulty',
position: 'right',
axisLabel: {
color: 'rgb(110, 112, 121)',