Update fee distribution graph and fix arrow.

This commit is contained in:
softsimon
2020-03-20 02:11:40 +07:00
parent e84ec7dd86
commit 4ae5576452
5 changed files with 59 additions and 25 deletions

View File

@@ -1,7 +1,6 @@
import { Component, OnInit, Input, OnChanges } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import * as Chartist from 'chartist';
import { Component, Input, OnChanges } from '@angular/core';
import { VbytesPipe } from 'src/app/pipes/bytes-pipe/vbytes.pipe';
import * as Chartist from 'chartist';
@Component({
selector: 'app-fee-distribution-graph',
@@ -14,16 +13,10 @@ export class FeeDistributionGraphComponent implements OnChanges {
mempoolVsizeFeesData: any;
mempoolVsizeFeesOptions: any;
mempoolVsizeFeesPieData: any;
mempoolVsizeFeesPieOptions: 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];
radioGroupForm: FormGroup;
constructor(
private vbytesPipe: VbytesPipe,
) { }
ngOnChanges() {
@@ -31,14 +24,22 @@ export class FeeDistributionGraphComponent implements OnChanges {
showArea: true,
showLine: true,
fullWidth: true,
showPoint: false,
showPoint: true,
low: 0,
axisY: {
labelInterpolationFnc: (value: number): any => {
return this.vbytesPipe.transform(value, 2);
},
offset: 60
showLabel: false,
},
axisX: {
showGrid: true,
showLabel: false,
offset: 0
},
plugins: [
Chartist.plugins.ctPointLabels({
textAnchor: 'middle',
labelInterpolationFnc: (value) => Math.round(value)
})
]
};
const fees = this.feeRange;
@@ -46,12 +47,13 @@ export class FeeDistributionGraphComponent implements OnChanges {
for (let i = 0; i < this.feeLevels.length; i++) {
let total = 0;
for (let j = 0; j < fees.length; j++) {
// for (let j = 0; j < fees.length; j++) {
for (const fee of fees) {
if (i === this.feeLevels.length - 1) {
if (fees[j] >= this.feeLevels[i]) {
if (fee >= this.feeLevels[i]) {
total += 1;
}
} else if (fees[j] >= this.feeLevels[i] && fees[j] < this.feeLevels[i + 1]) {
} else if (fee >= this.feeLevels[i] && fee < this.feeLevels[i + 1]) {
total += 1;
}
}
@@ -59,7 +61,8 @@ export class FeeDistributionGraphComponent implements OnChanges {
}
this.mempoolVsizeFeesData = {
series: [fees]
series: [fees],
labels: fees.map((d, i) => i)
};
}