Show current indexing progress in charts without data

This commit is contained in:
nymkappa 2022-03-09 20:10:51 +01:00
parent ba3a737ab9
commit 18f3018170
No known key found for this signature in database
GPG Key ID: E155910B16E8BD04
2 changed files with 29 additions and 19 deletions

View File

@ -92,7 +92,8 @@ export class HashrateChartComponent implements OnInit {
this.prepareChartOptions({ this.prepareChartOptions({
hashrates: data.hashrates.map(val => [val.timestamp * 1000, val.avgHashrate]), hashrates: data.hashrates.map(val => [val.timestamp * 1000, val.avgHashrate]),
difficulty: diffFixed.map(val => [val.timestamp * 1000, val.difficulty]) difficulty: diffFixed.map(val => [val.timestamp * 1000, val.difficulty]),
timestamp: data.oldestIndexedBlockTimestamp,
}); });
this.isLoading = false; this.isLoading = false;
}), }),
@ -125,16 +126,20 @@ export class HashrateChartComponent implements OnInit {
} }
prepareChartOptions(data) { prepareChartOptions(data) {
let title = undefined; let title: object;
if (data.hashrates.length === 0) { if (data.hashrates.length === 0) {
const lastBlock = new Date(data.timestamp * 1000);
const dd = String(lastBlock.getDate()).padStart(2, '0');
const mm = String(lastBlock.getMonth() + 1).padStart(2, '0'); // January is 0!
const yyyy = lastBlock.getFullYear();
title = { title = {
textStyle: { textStyle: {
color: "grey", color: 'grey',
fontSize: 15 fontSize: 15
}, },
text: "Indexing in progress...", text: `Indexing in progess - ${yyyy}-${mm}-${dd}`,
left: "center", left: 'center',
top: "center" top: 'center'
}; };
} }
@ -190,11 +195,11 @@ export class HashrateChartComponent implements OnInit {
`; `;
}.bind(this) }.bind(this)
}, },
xAxis: { xAxis: data.hashrates.length === 0 ? undefined : {
type: 'time', type: 'time',
splitNumber: (this.isMobile() || this.widget) ? 5 : 10, splitNumber: (this.isMobile() || this.widget) ? 5 : 10,
}, },
legend: { legend: data.hashrates.length === 0 ? undefined : {
data: [ data: [
{ {
name: 'Hashrate', name: 'Hashrate',
@ -220,7 +225,7 @@ export class HashrateChartComponent implements OnInit {
}, },
], ],
}, },
yAxis: [ yAxis: data.hashrates.length === 0 ? undefined : [
{ {
min: function (value) { min: function (value) {
return value.min * 0.9; return value.min * 0.9;
@ -259,7 +264,7 @@ export class HashrateChartComponent implements OnInit {
} }
} }
], ],
series: [ series: data.hashrates.length === 0 ? [] : [
{ {
name: 'Hashrate', name: 'Hashrate',
showSymbol: false, showSymbol: false,

View File

@ -105,7 +105,8 @@ export class HashrateChartPoolsComponent implements OnInit {
this.prepareChartOptions({ this.prepareChartOptions({
legends: legends, legends: legends,
series: series series: series,
timestamp: data.oldestIndexedBlockTimestamp,
}); });
this.isLoading = false; this.isLoading = false;
}), }),
@ -124,16 +125,20 @@ export class HashrateChartPoolsComponent implements OnInit {
} }
prepareChartOptions(data) { prepareChartOptions(data) {
let title = undefined; let title: object;
if (data.series.length === 0) { if (data.series.length === 0) {
const lastBlock = new Date(data.timestamp * 1000);
const dd = String(lastBlock.getDate()).padStart(2, '0');
const mm = String(lastBlock.getMonth() + 1).padStart(2, '0'); // January is 0!
const yyyy = lastBlock.getFullYear();
title = { title = {
textStyle: { textStyle: {
color: "grey", color: 'grey',
fontSize: 15 fontSize: 15
}, },
text: "Indexing in progress...", text: `Indexing in progess - ${yyyy}-${mm}-${dd}`,
left: "center", left: 'center',
top: this.widget ? 115 : this.isMobile() ? 'center' : 225, top: 'center',
}; };
} }
@ -171,14 +176,14 @@ export class HashrateChartPoolsComponent implements OnInit {
return tooltip; return tooltip;
}.bind(this) }.bind(this)
}, },
xAxis: { xAxis: data.series.length === 0 ? undefined : {
type: 'time', type: 'time',
splitNumber: (this.isMobile() || this.widget) ? 5 : 10, splitNumber: (this.isMobile() || this.widget) ? 5 : 10,
}, },
legend: (this.isMobile() || this.widget) ? undefined : { legend: (this.isMobile() || this.widget || data.series.length === 0) ? undefined : {
data: data.legends data: data.legends
}, },
yAxis: { yAxis: data.series.length === 0 ? undefined : {
position: 'right', position: 'right',
axisLabel: { axisLabel: {
color: 'rgb(110, 112, 121)', color: 'rgb(110, 112, 121)',