mirror of
https://github.com/mempool/mempool.git
synced 2025-02-24 22:58:30 +01:00
Add pool dominance data to mining pool page
This commit is contained in:
parent
1b21cd89a3
commit
cb866d8fa2
2 changed files with 75 additions and 17 deletions
|
@ -32,6 +32,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.chart {
|
.chart {
|
||||||
|
margin-top: 10px;
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
|
|
|
@ -65,7 +65,9 @@ export class PoolComponent implements OnInit {
|
||||||
.pipe(
|
.pipe(
|
||||||
switchMap((data) => {
|
switchMap((data) => {
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
this.prepareChartOptions(data.map(val => [val.timestamp * 1000, val.avgHashrate]));
|
const hashrate = data.map(val => [val.timestamp * 1000, val.avgHashrate]);
|
||||||
|
const share = data.map(val => [val.timestamp * 1000, val.share * 100]);
|
||||||
|
this.prepareChartOptions(hashrate, share);
|
||||||
return [slug];
|
return [slug];
|
||||||
}),
|
}),
|
||||||
catchError(() => {
|
catchError(() => {
|
||||||
|
@ -130,9 +132,9 @@ export class PoolComponent implements OnInit {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
prepareChartOptions(data) {
|
prepareChartOptions(hashrate, share) {
|
||||||
let title: object;
|
let title: object;
|
||||||
if (data.length <= 1) {
|
if (hashrate.length <= 1) {
|
||||||
title = {
|
title = {
|
||||||
textStyle: {
|
textStyle: {
|
||||||
color: 'grey',
|
color: 'grey',
|
||||||
|
@ -177,26 +179,57 @@ export class PoolComponent implements OnInit {
|
||||||
},
|
},
|
||||||
borderColor: '#000',
|
borderColor: '#000',
|
||||||
formatter: function (ticks: any[]) {
|
formatter: function (ticks: any[]) {
|
||||||
let hashratePowerOfTen: any = selectPowerOfTen(1);
|
let hashrateString = '';
|
||||||
let hashrate = ticks[0].data[1];
|
let dominanceString = '';
|
||||||
|
|
||||||
hashratePowerOfTen = selectPowerOfTen(ticks[0].data[1], 10);
|
for (const tick of ticks) {
|
||||||
hashrate = ticks[0].data[1] / hashratePowerOfTen.divider;
|
if (tick.seriesIndex === 0) {
|
||||||
|
let hashratePowerOfTen = selectPowerOfTen(tick.data[1], 10);
|
||||||
|
let hashrateData = tick.data[1] / hashratePowerOfTen.divider;
|
||||||
|
hashrateString = `${tick.marker} ${tick.seriesName}: ${formatNumber(hashrateData, this.locale, '1.0-0')} ${hashratePowerOfTen.unit}H/s<br>`;
|
||||||
|
} else if (tick.seriesIndex === 1) {
|
||||||
|
dominanceString = `${tick.marker} ${tick.seriesName}: ${formatNumber(tick.data[1], this.locale, '1.0-2')}%`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return `
|
return `
|
||||||
<b style="color: white; margin-left: 18px">${ticks[0].axisValueLabel}</b><br>
|
<b style="color: white; margin-left: 18px">${ticks[0].axisValueLabel}</b><br>
|
||||||
<span>${ticks[0].marker} ${ticks[0].seriesName}: ${formatNumber(hashrate, this.locale, '1.0-0')} ${hashratePowerOfTen.unit}H/s</span><br>
|
<span>${hashrateString}</span>
|
||||||
|
<span>${dominanceString}</span>
|
||||||
`;
|
`;
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
},
|
},
|
||||||
xAxis: data.length <= 1 ? undefined : {
|
xAxis: hashrate.length <= 1 ? undefined : {
|
||||||
type: 'time',
|
type: 'time',
|
||||||
splitNumber: (this.isMobile()) ? 5 : 10,
|
splitNumber: (this.isMobile()) ? 5 : 10,
|
||||||
axisLabel: {
|
axisLabel: {
|
||||||
hideOverlap: true,
|
hideOverlap: true,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
yAxis: data.length <= 1 ? undefined : [
|
legend: {
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
name: $localize`:mining.hashrate:Hashrate`,
|
||||||
|
inactiveColor: 'rgb(110, 112, 121)',
|
||||||
|
textStyle: {
|
||||||
|
color: 'white',
|
||||||
|
},
|
||||||
|
icon: 'roundRect',
|
||||||
|
itemStyle: {
|
||||||
|
color: '#FFB300',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: $localize`:mining.pool-dominance:Pool Dominance`,
|
||||||
|
inactiveColor: 'rgb(110, 112, 121)',
|
||||||
|
textStyle: {
|
||||||
|
color: 'white',
|
||||||
|
},
|
||||||
|
icon: 'roundRect',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
yAxis: hashrate.length <= 1 ? undefined : [
|
||||||
{
|
{
|
||||||
min: (value) => {
|
min: (value) => {
|
||||||
return value.min * 0.9;
|
return value.min * 0.9;
|
||||||
|
@ -214,21 +247,45 @@ export class PoolComponent implements OnInit {
|
||||||
show: false,
|
show: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
],
|
|
||||||
series: data.length <= 1 ? undefined : [
|
|
||||||
{
|
{
|
||||||
zlevel: 0,
|
type: 'value',
|
||||||
name: 'Hashrate',
|
axisLabel: {
|
||||||
|
color: 'rgb(110, 112, 121)',
|
||||||
|
formatter: (val) => {
|
||||||
|
return `${val}%`
|
||||||
|
}
|
||||||
|
},
|
||||||
|
splitLine: {
|
||||||
|
show: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
series: hashrate.length <= 1 ? undefined : [
|
||||||
|
{
|
||||||
|
zlevel: 1,
|
||||||
|
name: $localize`:mining.hashrate:Hashrate`,
|
||||||
showSymbol: false,
|
showSymbol: false,
|
||||||
symbol: 'none',
|
symbol: 'none',
|
||||||
data: data,
|
data: hashrate,
|
||||||
type: 'line',
|
type: 'line',
|
||||||
lineStyle: {
|
lineStyle: {
|
||||||
width: 2,
|
width: 2,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
zlevel: 0,
|
||||||
|
name: $localize`:mining.pool-dominance:Pool Dominance`,
|
||||||
|
showSymbol: false,
|
||||||
|
symbol: 'none',
|
||||||
|
data: share,
|
||||||
|
type: 'line',
|
||||||
|
yAxisIndex: 1,
|
||||||
|
lineStyle: {
|
||||||
|
width: 2,
|
||||||
|
},
|
||||||
|
}
|
||||||
],
|
],
|
||||||
dataZoom: data.length <= 1 ? undefined : [{
|
dataZoom: hashrate.length <= 1 ? undefined : [{
|
||||||
type: 'inside',
|
type: 'inside',
|
||||||
realtime: true,
|
realtime: true,
|
||||||
zoomLock: true,
|
zoomLock: true,
|
||||||
|
|
Loading…
Add table
Reference in a new issue