Adding a button to invert the graph globally.
This commit is contained in:
parent
76238f5943
commit
ca540d902a
@ -43,7 +43,7 @@ import { NgbTypeaheadModule } from '@ng-bootstrap/ng-bootstrap';
|
|||||||
import { FeesBoxComponent } from './components/fees-box/fees-box.component';
|
import { FeesBoxComponent } from './components/fees-box/fees-box.component';
|
||||||
import { DashboardComponent } from './dashboard/dashboard.component';
|
import { DashboardComponent } from './dashboard/dashboard.component';
|
||||||
import { FontAwesomeModule, FaIconLibrary } from '@fortawesome/angular-fontawesome';
|
import { FontAwesomeModule, FaIconLibrary } from '@fortawesome/angular-fontawesome';
|
||||||
import { faAngleDoubleDown, faAngleDoubleUp, faAngleDown, faAngleUp, faBolt, faChartArea, faCogs, faCubes, faDatabase, faInfoCircle,
|
import { faAngleDoubleDown, faAngleDoubleUp, faAngleDown, faAngleUp, faBolt, faChartArea, faCogs, faCubes, faDatabase, faExchangeAlt, faInfoCircle,
|
||||||
faLink, faList, faSearch, faTachometerAlt, faThList, faTint, faTv } from '@fortawesome/free-solid-svg-icons';
|
faLink, faList, faSearch, faTachometerAlt, faThList, faTint, faTv } from '@fortawesome/free-solid-svg-icons';
|
||||||
import { ApiDocsComponent } from './components/api-docs/api-docs.component';
|
import { ApiDocsComponent } from './components/api-docs/api-docs.component';
|
||||||
import { TermsOfServiceComponent } from './components/terms-of-service/terms-of-service.component';
|
import { TermsOfServiceComponent } from './components/terms-of-service/terms-of-service.component';
|
||||||
@ -121,5 +121,6 @@ export class AppModule {
|
|||||||
library.addIcons(faTint);
|
library.addIcons(faTint);
|
||||||
library.addIcons(faAngleDown);
|
library.addIcons(faAngleDown);
|
||||||
library.addIcons(faAngleUp);
|
library.addIcons(faAngleUp);
|
||||||
|
library.addIcons(faExchangeAlt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import { VbytesPipe } from 'src/app/shared/pipes/bytes-pipe/vbytes.pipe';
|
|||||||
import * as Chartist from '@mempool/chartist';
|
import * as Chartist from '@mempool/chartist';
|
||||||
import { OptimizedMempoolStats } from 'src/app/interfaces/node-api.interface';
|
import { OptimizedMempoolStats } from 'src/app/interfaces/node-api.interface';
|
||||||
import { StateService } from 'src/app/services/state.service';
|
import { StateService } from 'src/app/services/state.service';
|
||||||
|
import { StorageService } from 'src/app/services/storage.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-mempool-graph',
|
selector: 'app-mempool-graph',
|
||||||
@ -21,11 +22,13 @@ export class MempoolGraphComponent implements OnInit, OnChanges {
|
|||||||
mempoolVsizeFeesData: any;
|
mempoolVsizeFeesData: any;
|
||||||
|
|
||||||
isMobile = window.innerWidth <= 767.98;
|
isMobile = window.innerWidth <= 767.98;
|
||||||
|
inverted: boolean;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private vbytesPipe: VbytesPipe,
|
private vbytesPipe: VbytesPipe,
|
||||||
private stateService: StateService,
|
private stateService: StateService,
|
||||||
@Inject(LOCALE_ID) private locale: string,
|
@Inject(LOCALE_ID) private locale: string,
|
||||||
|
private storageService: StorageService,
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
@ -62,7 +65,7 @@ export class MempoolGraphComponent implements OnInit, OnChanges {
|
|||||||
showLine: false,
|
showLine: false,
|
||||||
fullWidth: true,
|
fullWidth: true,
|
||||||
showPoint: false,
|
showPoint: false,
|
||||||
stackedLine: true,
|
stackedLine: !this.inverted,
|
||||||
low: 0,
|
low: 0,
|
||||||
axisX: {
|
axisX: {
|
||||||
labelInterpolationFnc: labelInterpolationFnc,
|
labelInterpolationFnc: labelInterpolationFnc,
|
||||||
@ -72,7 +75,7 @@ export class MempoolGraphComponent implements OnInit, OnChanges {
|
|||||||
labelInterpolationFnc: (value: number): any => this.vbytesPipe.transform(value, 2),
|
labelInterpolationFnc: (value: number): any => this.vbytesPipe.transform(value, 2),
|
||||||
offset: showLegend ? 160 : 60,
|
offset: showLegend ? 160 : 60,
|
||||||
},
|
},
|
||||||
plugins: []
|
plugins: this.inverted ? [Chartist.plugins.ctTargetLine({ value: 1000000 })] : []
|
||||||
};
|
};
|
||||||
|
|
||||||
if (showLegend) {
|
if (showLegend) {
|
||||||
@ -97,6 +100,7 @@ export class MempoolGraphComponent implements OnInit, OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges() {
|
ngOnChanges() {
|
||||||
|
this.inverted = this.storageService.getValue('inverted-graph') === 'true';
|
||||||
this.mempoolVsizeFeesData = this.handleNewMempoolData(this.data.concat([]));
|
this.mempoolVsizeFeesData = this.handleNewMempoolData(this.data.concat([]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,10 +135,12 @@ export class MempoolGraphComponent implements OnInit, OnChanges {
|
|||||||
feesArray.push(0);
|
feesArray.push(0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (this.inverted && finalArray.length) {
|
||||||
|
feesArray = feesArray.map((value, i) => value + finalArray[finalArray.length - 1][i]);
|
||||||
|
}
|
||||||
finalArray.push(feesArray);
|
finalArray.push(feesArray);
|
||||||
}
|
}
|
||||||
finalArray.reverse();
|
finalArray.reverse();
|
||||||
return finalArray;
|
return finalArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
<input ngbButton type="radio" [value]="'1y'" [routerLink]="['/graphs' | relativeUrl]" fragment="1y"> 1Y
|
<input ngbButton type="radio" [value]="'1y'" [routerLink]="['/graphs' | relativeUrl]" fragment="1y"> 1Y
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
<button (click)="invertGraph()" class="btn btn-primary btn-sm ml-2 d-none d-md-inline"><fa-icon [icon]="['fas', 'exchange-alt']" [rotate]="90" [fixedWidth]="true" title="Search"></fa-icon></button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
@ -12,6 +12,7 @@ import { ApiService } from '../../services/api.service';
|
|||||||
import * as Chartist from '@mempool/chartist';
|
import * as Chartist from '@mempool/chartist';
|
||||||
import { StateService } from 'src/app/services/state.service';
|
import { StateService } from 'src/app/services/state.service';
|
||||||
import { SeoService } from 'src/app/services/seo.service';
|
import { SeoService } from 'src/app/services/seo.service';
|
||||||
|
import { StorageService } from 'src/app/services/storage.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-statistics',
|
selector: 'app-statistics',
|
||||||
@ -33,6 +34,7 @@ export class StatisticsComponent implements OnInit {
|
|||||||
transactionsWeightPerSecondOptions: any;
|
transactionsWeightPerSecondOptions: any;
|
||||||
|
|
||||||
radioGroupForm: FormGroup;
|
radioGroupForm: FormGroup;
|
||||||
|
inverted: boolean;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@Inject(LOCALE_ID) private locale: string,
|
@Inject(LOCALE_ID) private locale: string,
|
||||||
@ -42,6 +44,7 @@ export class StatisticsComponent implements OnInit {
|
|||||||
private apiService: ApiService,
|
private apiService: ApiService,
|
||||||
private stateService: StateService,
|
private stateService: StateService,
|
||||||
private seoService: SeoService,
|
private seoService: SeoService,
|
||||||
|
private storageService: StorageService,
|
||||||
) {
|
) {
|
||||||
this.radioGroupForm = this.formBuilder.group({
|
this.radioGroupForm = this.formBuilder.group({
|
||||||
dateSpan: '2h'
|
dateSpan: '2h'
|
||||||
@ -51,6 +54,7 @@ export class StatisticsComponent implements OnInit {
|
|||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.seoService.setTitle('Graphs');
|
this.seoService.setTitle('Graphs');
|
||||||
this.stateService.networkChanged$.subscribe((network) => this.network = network);
|
this.stateService.networkChanged$.subscribe((network) => this.network = network);
|
||||||
|
this.inverted = this.storageService.getValue('inverted-graph') === 'true';
|
||||||
const isMobile = window.innerWidth <= 767.98;
|
const isMobile = window.innerWidth <= 767.98;
|
||||||
let labelHops = isMobile ? 48 : 24;
|
let labelHops = isMobile ? 48 : 24;
|
||||||
|
|
||||||
@ -157,4 +161,9 @@ export class StatisticsComponent implements OnInit {
|
|||||||
series: [mempoolStats.map((stats) => stats.vbytes_per_second)],
|
series: [mempoolStats.map((stats) => stats.vbytes_per_second)],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
invertGraph() {
|
||||||
|
this.storageService.setValue('inverted-graph', !this.inverted);
|
||||||
|
document.location.reload();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ export class StorageService {
|
|||||||
return localStorage.getItem(key);
|
return localStorage.getItem(key);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user