diff --git a/backend/src/repositories/BlocksRepository.ts b/backend/src/repositories/BlocksRepository.ts
index d57bc8eb0..5d2cdbe36 100644
--- a/backend/src/repositories/BlocksRepository.ts
+++ b/backend/src/repositories/BlocksRepository.ts
@@ -232,7 +232,7 @@ class BlocksRepository {
const connection = await DB.pool.getConnection();
- let query = `SELECT MIN(blockTimestamp) as timestamp, difficulty
+ let query = `SELECT MIN(blockTimestamp) as timestamp, difficulty, height
FROM blocks`;
if (interval) {
diff --git a/frontend/src/app/components/difficulty-chart/difficulty-chart.component.html b/frontend/src/app/components/difficulty-chart/difficulty-chart.component.html
index 0a9a60620..b63ba29f5 100644
--- a/frontend/src/app/components/difficulty-chart/difficulty-chart.component.html
+++ b/frontend/src/app/components/difficulty-chart/difficulty-chart.component.html
@@ -5,4 +5,23 @@
+
+
+
+ Block |
+ Timestamp |
+ Difficulty |
+ Change |
+
+
+
+
+ {{ change[2] }} |
+ {{ change[0] | date:'yyyy-MM-dd HH:mm' }} |
+ {{ formatNumber(change[1], locale, '1.2-2') }} |
+ = 0 ? 'color: #42B747' : 'color: #B74242'">{{ formatNumber(change[3], locale, '1.2-2') }}% |
+
+
+
+
diff --git a/frontend/src/app/components/difficulty-chart/difficulty-chart.component.ts b/frontend/src/app/components/difficulty-chart/difficulty-chart.component.ts
index 635a8a6d9..0e343843d 100644
--- a/frontend/src/app/components/difficulty-chart/difficulty-chart.component.ts
+++ b/frontend/src/app/components/difficulty-chart/difficulty-chart.component.ts
@@ -1,9 +1,10 @@
-import { Component, OnInit } from '@angular/core';
+import { Component, Inject, LOCALE_ID, OnInit } from '@angular/core';
import { EChartsOption } from 'echarts';
import { Observable } from 'rxjs';
-import { map, tap } from 'rxjs/operators';
+import { map, share, tap } from 'rxjs/operators';
import { ApiService } from 'src/app/services/api.service';
import { SeoService } from 'src/app/services/seo.service';
+import { formatNumber } from "@angular/common";
@Component({
selector: 'app-difficulty-chart',
@@ -26,8 +27,10 @@ export class DifficultyChartComponent implements OnInit {
difficultyObservable$: Observable;
isLoading = true;
+ formatNumber = formatNumber;
constructor(
+ @Inject(LOCALE_ID) public locale: string,
private seoService: SeoService,
private apiService: ApiService,
) {
@@ -38,12 +41,25 @@ export class DifficultyChartComponent implements OnInit {
this.difficultyObservable$ = this.apiService.getHistoricalDifficulty$(undefined)
.pipe(
map(data => {
- return data.map(val => [val.timestamp, val.difficulty])
+ let formatted = [];
+ for (let i = 0; i < data.length - 1; ++i) {
+ const change = (data[i].difficulty / data[i + 1].difficulty - 1) * 100;
+ formatted.push([
+ data[i].timestamp,
+ data[i].difficulty,
+ data[i].height,
+ formatNumber(change, this.locale, '1.2-2'),
+ change,
+ formatNumber(data[i].difficulty, this.locale, '1.2-2'),
+ ]);
+ }
+ return formatted;
}),
tap(data => {
this.prepareChartOptions(data);
this.isLoading = false;
- })
+ }),
+ share()
)
}
diff --git a/frontend/src/app/components/pool-ranking/pool-ranking.component.html b/frontend/src/app/components/pool-ranking/pool-ranking.component.html
index 1f6fdbc0e..ac59ab2d2 100644
--- a/frontend/src/app/components/pool-ranking/pool-ranking.component.html
+++ b/frontend/src/app/components/pool-ranking/pool-ranking.component.html
@@ -43,7 +43,7 @@
-