Improve hashrate chart and mining dashboard design

This commit is contained in:
nymkappa 2022-02-22 20:15:15 +09:00
parent dcd84680fc
commit 3f0bf81726
No known key found for this signature in database
GPG Key ID: E155910B16E8BD04
8 changed files with 81 additions and 37 deletions

View File

@ -25,13 +25,14 @@
</form> </form>
</div> </div>
<div *ngIf="hashrateObservable$ | async" [class]="widget === false ? 'chart' : ''" echarts [initOpts]="chartInitOptions" [options]="chartOptions"></div> <div *ngIf="hashrateObservable$ | async" [class]="!widget ? 'chart' : 'chart-widget'"
echarts [initOpts]="chartInitOptions" [options]="chartOptions"></div>
<div class="text-center loadingGraphs" *ngIf="isLoading"> <div class="text-center loadingGraphs" *ngIf="isLoading">
<div class="spinner-border text-light"></div> <div class="spinner-border text-light"></div>
</div> </div>
<div class="container-xl mt-3"> <div class="mt-3" *ngIf="!widget">
<table class="table table-borderless table-sm text-center" *ngIf="!widget"> <table class="table table-borderless table-sm text-center">
<thead> <thead>
<tr> <tr>
<th i18n="mining.rank">Block</th> <th i18n="mining.rank">Block</th>

View File

@ -26,6 +26,11 @@
padding-bottom: 20px; padding-bottom: 20px;
padding-right: 20px; padding-right: 20px;
} }
.chart-widget {
width: 100%;
height: 100%;
max-height: 275px;
}
.formRadioGroup { .formRadioGroup {
margin-top: 6px; margin-top: 6px;

View File

@ -133,6 +133,7 @@ export class HashrateChartComponent implements OnInit {
grid: { grid: {
right: this.right, right: this.right,
left: this.left, left: this.left,
bottom: 30,
}, },
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
@ -146,6 +147,25 @@ export class HashrateChartComponent implements OnInit {
color: '#b1b1b1', color: '#b1b1b1',
}, },
borderColor: '#000', borderColor: '#000',
formatter: function (data) {
let hashratePowerOfTen: any = selectPowerOfTen(1);
let hashrate = data[0].data[1];
let difficultyPowerOfTen = hashratePowerOfTen;
let difficulty = data[1].data[1];
if (this.isMobile()) {
hashratePowerOfTen = selectPowerOfTen(data[0].data[1]);
hashrate = Math.round(data[0].data[1] / hashratePowerOfTen.divider);
difficultyPowerOfTen = selectPowerOfTen(data[1].data[1]);
difficulty = Math.round(data[1].data[1] / difficultyPowerOfTen.divider);
}
return `
<b style="color: white; margin-left: 18px">${data[0].axisValueLabel}</b><br>
<span>${data[0].marker} ${data[0].seriesName}: ${formatNumber(hashrate, this.locale, '1.0-0')} ${hashratePowerOfTen.unit}H/s</span><br>
<span>${data[1].marker} ${data[1].seriesName}: ${formatNumber(difficulty, this.locale, '1.0-0')} ${difficultyPowerOfTen.unit}</span>
`;
}.bind(this)
}, },
xAxis: { xAxis: {
type: 'time', type: 'time',
@ -179,13 +199,16 @@ export class HashrateChartComponent implements OnInit {
}, },
yAxis: [ yAxis: [
{ {
min: function (value) {
return value.min * 0.9;
},
type: 'value', type: 'value',
name: 'Hashrate', name: 'Hashrate',
axisLabel: { axisLabel: {
color: 'rgb(110, 112, 121)', color: 'rgb(110, 112, 121)',
formatter: (val) => { formatter: (val) => {
const selectedPowerOfTen: any = selectPowerOfTen(val); const selectedPowerOfTen: any = selectPowerOfTen(val);
const newVal = val / selectedPowerOfTen.divider; const newVal = Math.round(val / selectedPowerOfTen.divider);
return `${newVal} ${selectedPowerOfTen.unit}H/s` return `${newVal} ${selectedPowerOfTen.unit}H/s`
} }
}, },
@ -194,6 +217,9 @@ export class HashrateChartComponent implements OnInit {
} }
}, },
{ {
min: function (value) {
return value.min * 0.9;
},
type: 'value', type: 'value',
name: 'Difficulty', name: 'Difficulty',
position: 'right', position: 'right',
@ -201,7 +227,7 @@ export class HashrateChartComponent implements OnInit {
color: 'rgb(110, 112, 121)', color: 'rgb(110, 112, 121)',
formatter: (val) => { formatter: (val) => {
const selectedPowerOfTen: any = selectPowerOfTen(val); const selectedPowerOfTen: any = selectPowerOfTen(val);
const newVal = val / selectedPowerOfTen.divider; const newVal = Math.round(val / selectedPowerOfTen.divider);
return `${newVal} ${selectedPowerOfTen.unit}` return `${newVal} ${selectedPowerOfTen.unit}`
} }
}, },

View File

@ -5,11 +5,13 @@
<!-- pool distribution --> <!-- pool distribution -->
<div class="col"> <div class="col">
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body pool-ranking">
<h5 class="card-title" i18n="mining.pool-share">Mining Pools Share (1w)</h5> <h5 class="card-title">
<a href="" [routerLink]="['/mining/pools' | relativeUrl]" i18n="mining.pool-share">
Mining Pools Share (1w)
</a>
</h5>
<app-pool-ranking [widget]=true></app-pool-ranking> <app-pool-ranking [widget]=true></app-pool-ranking>
<div class="text-center"><a href="" [routerLink]="['/mining/pools' | relativeUrl]" i18n="dashboard.view-more">View more
&raquo;</a></div>
</div> </div>
</div> </div>
</div> </div>
@ -18,10 +20,12 @@
<div class="col"> <div class="col">
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
<h5 class="card-title" i18n="mining.hashrate">Hashrate (1y)</h5> <h5 class="card-title">
<a class="link" href="" [routerLink]="['/mining/hashrate' | relativeUrl]" i18n="mining.hashrate">
Hashrate (1y)
</a>
</h5>
<app-hashrate-chart [widget]=true></app-hashrate-chart> <app-hashrate-chart [widget]=true></app-hashrate-chart>
<div class="text-center"><a href="" [routerLink]="['/mining/hashrate' | relativeUrl]" i18n="dashboard.view-more">View more
&raquo;</a></div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -16,22 +16,17 @@
} }
.card-title { .card-title {
color: #4a68b9;
font-size: 1rem; font-size: 1rem;
} }
.card-title > a {
color: #4a68b9;
}
.card-wrapper {
.card {
height: auto !important;
}
.card-body { .card-body {
display: flex; padding: 1.25rem 1rem 0.75rem 1rem;
flex: inherit;
text-align: center;
flex-direction: column;
justify-content: space-around;
padding: 22px 20px;
} }
.card-body.pool-ranking {
padding: 1.25rem 0.25rem 0.75rem 0.25rem;
} }
#blockchain-container { #blockchain-container {

View File

@ -1,11 +1,12 @@
<div [class]="widget === false ? 'container-xl' : ''"> <div [class]="widget === false ? 'container-xl' : ''">
<div class="hashrate-pie" echarts [initOpts]="chartInitOptions" [options]="chartOptions" (chartInit)="onChartInit($event)"></div> <div [class]="widget ? 'chart-widget' : 'chart'"
echarts [initOpts]="chartInitOptions" [options]="chartOptions" (chartInit)="onChartInit($event)"></div>
<div class="text-center loadingGraphs" *ngIf="isLoading"> <div class="text-center loadingGraphs" *ngIf="isLoading">
<div class="spinner-border text-light"></div> <div class="spinner-border text-light"></div>
</div> </div>
<div class="card-header mb-0 mb-lg-4" [style]="widget === true ? 'display:none' : ''"> <div class="card-header mb-0 mb-lg-4 mt-md-3" [style]="widget ? 'display:none' : ''">
<form [formGroup]="radioGroupForm" class="formRadioGroup" *ngIf="(miningStatsObservable$ | async) as miningStats"> <form [formGroup]="radioGroupForm" class="formRadioGroup" *ngIf="(miningStatsObservable$ | async) as miningStats">
<div class="btn-group btn-group-toggle" ngbRadioGroup name="radioBasic" formControlName="dateSpan"> <div class="btn-group btn-group-toggle" ngbRadioGroup name="radioBasic" formControlName="dateSpan">
<label ngbButtonLabel class="btn-primary btn-sm" *ngIf="miningStats.availableTimespanDay >= 1"> <label ngbButtonLabel class="btn-primary btn-sm" *ngIf="miningStats.availableTimespanDay >= 1">

View File

@ -1,10 +1,14 @@
.hashrate-pie { .chart {
height: 100%; max-height: 400px;
min-height: 400px;
@media (max-width: 767.98px) { @media (max-width: 767.98px) {
min-height: 300px; max-height: 300px;
} }
} }
.chart-widget {
width: 100%;
height: 100%;
max-height: 275px;
}
.formRadioGroup { .formRadioGroup {
margin-top: 6px; margin-top: 6px;

View File

@ -33,7 +33,9 @@ export class PoolRankingComponent implements OnInit {
isLoading = true; isLoading = true;
chartOptions: EChartsOption = {}; chartOptions: EChartsOption = {};
chartInitOptions = { chartInitOptions = {
renderer: 'svg' renderer: 'svg',
width: 'auto',
height: 'auto',
}; };
chartInstance: any = undefined; chartInstance: any = undefined;
@ -156,6 +158,11 @@ export class PoolRankingComponent implements OnInit {
} }
network = network.charAt(0).toUpperCase() + network.slice(1); network = network.charAt(0).toUpperCase() + network.slice(1);
let radius: any[] = ['20%', '70%'];
if (this.isMobile() || this.widget) {
radius = ['20%', '65%'];
}
this.chartOptions = { this.chartOptions = {
title: { title: {
text: this.widget ? '' : $localize`:@@mining.pool-chart-title:${network}:NETWORK: mining pools share`, text: this.widget ? '' : $localize`:@@mining.pool-chart-title:${network}:NETWORK: mining pools share`,
@ -173,13 +180,14 @@ export class PoolRankingComponent implements OnInit {
}, },
series: [ series: [
{ {
top: this.widget ? '0%' : (this.isMobile() ? '5%' : '10%'), top: this.widget ? 0 : 35,
bottom: this.widget ? '0%' : (this.isMobile() ? '0%' : '5%'),
name: 'Mining pool', name: 'Mining pool',
type: 'pie', type: 'pie',
radius: this.widget ? ['20%', '60%'] : (this.isMobile() ? ['10%', '50%'] : ['20%', '70%']), radius: radius,
data: this.generatePoolsChartSerieData(miningStats), data: this.generatePoolsChartSerieData(miningStats),
labelLine: { labelLine: {
length: this.isMobile() ? 10 : 15,
length2: this.isMobile() ? 0 : 15,
lineStyle: { lineStyle: {
width: 2, width: 2,
}, },