Adding 4 year button to mempool graph

fixes #3218
This commit is contained in:
softsimon
2023-03-04 18:48:16 +09:00
parent aef26097ec
commit 4e39c27c75
9 changed files with 35 additions and 4 deletions

View File

@@ -49,6 +49,9 @@
<label class="btn btn-primary btn-sm" [class.active]="radioGroupForm.get('dateSpan').value === '3y'">
<input type="radio" [value]="'3y'" [routerLink]="['/graphs' | relativeUrl]" fragment="3y" formControlName="dateSpan"> 3Y
</label>
<label class="btn btn-primary btn-sm" [class.active]="radioGroupForm.get('dateSpan').value === '4y'">
<input type="radio" [value]="'4y'" [routerLink]="['/graphs' | relativeUrl]" fragment="4y" formControlName="dateSpan"> 4Y
</label>
</div>
<div class="small-buttons">
<div ngbDropdown #myDrop="ngbDropdown">

View File

@@ -70,7 +70,7 @@ export class StatisticsComponent implements OnInit {
this.route
.fragment
.subscribe((fragment) => {
if (['2h', '24h', '1w', '1m', '3m', '6m', '1y', '2y', '3y'].indexOf(fragment) > -1) {
if (['2h', '24h', '1w', '1m', '3m', '6m', '1y', '2y', '3y', '4y'].indexOf(fragment) > -1) {
this.radioGroupForm.controls.dateSpan.setValue(fragment, { emitEvent: false });
}
});
@@ -109,7 +109,10 @@ export class StatisticsComponent implements OnInit {
if (this.radioGroupForm.controls.dateSpan.value === '2y') {
return this.apiService.list2YStatistics$();
}
return this.apiService.list3YStatistics$();
if (this.radioGroupForm.controls.dateSpan.value === '3y') {
return this.apiService.list3YStatistics$();
}
return this.apiService.list4YStatistics$();
})
)
.subscribe((mempoolStats: any) => {
@@ -181,7 +184,7 @@ export class StatisticsComponent implements OnInit {
}
let capRatio = 10;
if (['1m', '3m', '6m', '1y', '2y', '3y'].includes(this.graphWindowPreference)) {
if (['1m', '3m', '6m', '1y', '2y', '3y', '4y'].includes(this.graphWindowPreference)) {
capRatio = 4;
}

View File

@@ -68,6 +68,10 @@ export class ApiService {
return this.httpClient.get<OptimizedMempoolStats[]>(this.apiBaseUrl + this.apiBasePath + '/api/v1/statistics/3y');
}
list4YStatistics$(): Observable<OptimizedMempoolStats[]> {
return this.httpClient.get<OptimizedMempoolStats[]>(this.apiBaseUrl + this.apiBasePath + '/api/v1/statistics/4y');
}
getTransactionTimes$(txIds: string[]): Observable<number[]> {
let params = new HttpParams();
txIds.forEach((txId: string) => {

View File

@@ -21,6 +21,7 @@ export const formatterXAxis = (
return date.toLocaleTimeString(locale, { month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric' });
case '2y':
case '3y':
case '4y':
case 'all':
return date.toLocaleDateString(locale, { year: 'numeric', month: 'long', day: 'numeric' });
}
@@ -45,6 +46,7 @@ export const formatterXAxisLabel = (
case '1y':
case '2y':
case '3y':
case '4y':
return null;
}
};
@@ -71,6 +73,7 @@ export const formatterXAxisTimeCategory = (
return date.toLocaleDateString(locale, { year: 'numeric', month: 'short', day: 'numeric' });
case '2y':
case '3y':
case '4y':
case 'all':
return date.toLocaleDateString(locale, { year: 'numeric', month: 'long' });
}