2020-03-19 20:11:40 +01:00
|
|
|
import { Component, Input, OnChanges } from '@angular/core';
|
2020-03-17 15:53:20 +01:00
|
|
|
import { VbytesPipe } from 'src/app/pipes/bytes-pipe/vbytes.pipe';
|
2020-03-19 20:11:40 +01:00
|
|
|
import * as Chartist from 'chartist';
|
2020-03-17 15:53:20 +01:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-fee-distribution-graph',
|
|
|
|
templateUrl: './fee-distribution-graph.component.html',
|
|
|
|
styleUrls: ['./fee-distribution-graph.component.scss']
|
|
|
|
})
|
|
|
|
export class FeeDistributionGraphComponent implements OnChanges {
|
|
|
|
@Input() feeRange;
|
|
|
|
|
|
|
|
mempoolVsizeFeesData: any;
|
|
|
|
mempoolVsizeFeesOptions: any;
|
|
|
|
|
|
|
|
feeLevels = [1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 20, 30, 40, 50, 60, 70, 80, 90, 100, 125, 150, 175, 200,
|
|
|
|
250, 300, 350, 400, 500];
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
) { }
|
|
|
|
|
|
|
|
ngOnChanges() {
|
|
|
|
this.mempoolVsizeFeesOptions = {
|
|
|
|
showArea: true,
|
|
|
|
showLine: true,
|
|
|
|
fullWidth: true,
|
2020-03-19 20:11:40 +01:00
|
|
|
showPoint: true,
|
2020-03-17 15:53:20 +01:00
|
|
|
low: 0,
|
|
|
|
axisY: {
|
2020-03-19 20:11:40 +01:00
|
|
|
showLabel: false,
|
|
|
|
},
|
|
|
|
axisX: {
|
|
|
|
showGrid: true,
|
|
|
|
showLabel: false,
|
|
|
|
offset: 0
|
2020-03-17 15:53:20 +01:00
|
|
|
},
|
2020-03-19 20:11:40 +01:00
|
|
|
plugins: [
|
|
|
|
Chartist.plugins.ctPointLabels({
|
|
|
|
textAnchor: 'middle',
|
|
|
|
labelInterpolationFnc: (value) => Math.round(value)
|
|
|
|
})
|
|
|
|
]
|
2020-03-17 15:53:20 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
const fees = this.feeRange;
|
|
|
|
const series = [];
|
|
|
|
|
|
|
|
for (let i = 0; i < this.feeLevels.length; i++) {
|
|
|
|
let total = 0;
|
2020-03-19 20:11:40 +01:00
|
|
|
// for (let j = 0; j < fees.length; j++) {
|
|
|
|
for (const fee of fees) {
|
2020-03-17 15:53:20 +01:00
|
|
|
if (i === this.feeLevels.length - 1) {
|
2020-03-19 20:11:40 +01:00
|
|
|
if (fee >= this.feeLevels[i]) {
|
2020-03-17 15:53:20 +01:00
|
|
|
total += 1;
|
|
|
|
}
|
2020-03-19 20:11:40 +01:00
|
|
|
} else if (fee >= this.feeLevels[i] && fee < this.feeLevels[i + 1]) {
|
2020-03-17 15:53:20 +01:00
|
|
|
total += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
series.push(total);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.mempoolVsizeFeesData = {
|
2020-03-19 20:11:40 +01:00
|
|
|
series: [fees],
|
|
|
|
labels: fees.map((d, i) => i)
|
2020-03-17 15:53:20 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|