Compare commits

...

4 Commits

Author SHA1 Message Date
wiz
ef78b252f3
Merge branch 'master' into mononaut/fee-widget-gradient 2023-05-09 12:51:09 -05:00
Mononaut
db4886fb41
fix recommended fee gradient 2023-05-08 13:06:56 -06:00
Mononaut
5257716e1a
Dynamic fee ranges & legend in mempool graph 2023-05-08 12:53:37 -06:00
Mononaut
47b95af8ae
increase range of fee colors 2023-05-08 12:44:14 -06:00
6 changed files with 43 additions and 22 deletions

View File

@ -29,6 +29,14 @@ export const mempoolFeeColors = [
'ba3243', 'ba3243',
'b92b48', 'b92b48',
'b9254b', 'b9254b',
'b8214d',
'b71d4f',
'b61951',
'b41453',
'b30e55',
'b10857',
'b00259',
'ae005b',
]; ];
export const chartColors = [ export const chartColors = [
@ -69,6 +77,7 @@ export const chartColors = [
"#3E2723", "#3E2723",
"#212121", "#212121",
"#263238", "#263238",
"#801313",
]; ];
export const poolsColor = { export const poolsColor = {

View File

@ -26,15 +26,23 @@ export class FeesBoxComponent implements OnInit {
this.recommendedFees$ = this.stateService.recommendedFees$ this.recommendedFees$ = this.stateService.recommendedFees$
.pipe( .pipe(
tap((fees) => { tap((fees) => {
let feeLevelIndex = feeLevels.slice().reverse().findIndex((feeLvl) => fees.minimumFee >= feeLvl); let feeLevelIndex = feeLevels.slice().reverse().findIndex((feeLvl) => fees.economyFee >= feeLvl);
feeLevelIndex = feeLevelIndex >= 0 ? feeLevels.length - feeLevelIndex : feeLevelIndex; feeLevelIndex = feeLevelIndex >= 0 ? feeLevels.length - feeLevelIndex : feeLevelIndex;
const startColor = '#' + (mempoolFeeColors[feeLevelIndex - 1] || mempoolFeeColors[mempoolFeeColors.length - 1]); const startColor = '#' + (mempoolFeeColors[feeLevelIndex - 1] || mempoolFeeColors[mempoolFeeColors.length - 1]);
feeLevelIndex = feeLevels.slice().reverse().findIndex((feeLvl) => fees.hourFee >= feeLvl);
feeLevelIndex = feeLevelIndex >= 0 ? feeLevels.length - feeLevelIndex : feeLevelIndex;
const lowColor = '#' + (mempoolFeeColors[feeLevelIndex - 1] || mempoolFeeColors[mempoolFeeColors.length - 1]);
feeLevelIndex = feeLevels.slice().reverse().findIndex((feeLvl) => fees.halfHourFee >= feeLvl);
feeLevelIndex = feeLevelIndex >= 0 ? feeLevels.length - feeLevelIndex : feeLevelIndex;
const medColor = '#' + (mempoolFeeColors[feeLevelIndex - 1] || mempoolFeeColors[mempoolFeeColors.length - 1]);
feeLevelIndex = feeLevels.slice().reverse().findIndex((feeLvl) => fees.fastestFee >= feeLvl); feeLevelIndex = feeLevels.slice().reverse().findIndex((feeLvl) => fees.fastestFee >= feeLvl);
feeLevelIndex = feeLevelIndex >= 0 ? feeLevels.length - feeLevelIndex : feeLevelIndex; feeLevelIndex = feeLevelIndex >= 0 ? feeLevels.length - feeLevelIndex : feeLevelIndex;
const endColor = '#' + (mempoolFeeColors[feeLevelIndex - 1] || mempoolFeeColors[mempoolFeeColors.length - 1]); const highColor = '#' + (mempoolFeeColors[feeLevelIndex - 1] || mempoolFeeColors[mempoolFeeColors.length - 1]);
this.gradient = `linear-gradient(to right, ${startColor}, ${endColor})`; this.gradient = `linear-gradient(to right, ${lowColor} 0%, ${medColor} 50%, ${highColor} 100%)`;
this.noPriority = startColor; this.noPriority = startColor;
} }
) )

View File

@ -23,8 +23,7 @@ import { download, formatterXAxis, formatterXAxisLabel } from '../../shared/grap
}) })
export class MempoolGraphComponent implements OnInit, OnChanges { export class MempoolGraphComponent implements OnInit, OnChanges {
@Input() data: any[]; @Input() data: any[];
@Input() limitFee = 350; @Input() filterSize = 100000;
@Input() limitFilterFee = 1;
@Input() height: number | string = 200; @Input() height: number | string = 200;
@Input() top: number | string = 20; @Input() top: number | string = 20;
@Input() right: number | string = 10; @Input() right: number | string = 10;
@ -99,16 +98,20 @@ export class MempoolGraphComponent implements OnInit, OnChanges {
} }
generateArray(mempoolStats: OptimizedMempoolStats[]) { generateArray(mempoolStats: OptimizedMempoolStats[]) {
const finalArray: number[][][] = []; let finalArray: number[][][] = [];
let feesArray: number[][] = []; let feesArray: number[][] = [];
const limitFeesTemplate = this.template === 'advanced' ? 26 : 20; let maxTier = 0;
for (let index = limitFeesTemplate; index > -1; index--) { for (let index = 37; index > -1; index--) {
feesArray = []; feesArray = [];
mempoolStats.forEach((stats) => { mempoolStats.forEach((stats) => {
if (stats.vsizes[index] >= this.filterSize) {
maxTier = Math.max(maxTier, index);
}
feesArray.push([stats.added * 1000, stats.vsizes[index] ? stats.vsizes[index] : 0]); feesArray.push([stats.added * 1000, stats.vsizes[index] ? stats.vsizes[index] : 0]);
}); });
finalArray.push(feesArray); finalArray.push(feesArray);
} }
this.feeLimitIndex = maxTier;
finalArray.reverse(); finalArray.reverse();
return finalArray; return finalArray;
} }
@ -121,7 +124,7 @@ export class MempoolGraphComponent implements OnInit, OnChanges {
const newColors = []; const newColors = [];
for (let index = 0; index < series.length; index++) { for (let index = 0; index < series.length; index++) {
const value = series[index]; const value = series[index];
if (index >= this.feeLimitIndex) { if (index < this.feeLimitIndex) {
newColors.push(this.chartColorsOrdered[index]); newColors.push(this.chartColorsOrdered[index]);
seriesGraph.push({ seriesGraph.push({
zlevel: 0, zlevel: 0,
@ -371,17 +374,21 @@ export class MempoolGraphComponent implements OnInit, OnChanges {
orderLevels() { orderLevels() {
this.feeLevelsOrdered = []; this.feeLevelsOrdered = [];
for (let i = 0; i < feeLevels.length; i++) { let maxIndex = Math.min(feeLevels.length, this.feeLimitIndex);
if (feeLevels[i] === this.limitFilterFee) { for (let i = 0; i < maxIndex; i++) {
this.feeLimitIndex = i;
}
if (feeLevels[i] <= this.limitFee) {
if (this.stateService.network === 'liquid' || this.stateService.network === 'liquidtestnet') { if (this.stateService.network === 'liquid' || this.stateService.network === 'liquidtestnet') {
this.feeLevelsOrdered.push(`${(feeLevels[i] / 10).toFixed(1)} - ${(feeLevels[i + 1] / 10).toFixed(1)}`); if (i === maxIndex - 1) {
this.feeLevelsOrdered.push(`${(feeLevels[i] / 10).toFixed(1)}+`);
} else {
this.feeLevelsOrdered.push(`${(feeLevels[i] / 10).toFixed(1)} - ${(feeLevels[i + 1] / 10).toFixed(1)}`);
}
} else { } else {
this.feeLevelsOrdered.push(`${feeLevels[i]} - ${feeLevels[i + 1]}`); if (i === maxIndex - 1) {
this.feeLevelsOrdered.push(`${feeLevels[i]}+`);
} else {
this.feeLevelsOrdered.push(`${feeLevels[i]} - ${feeLevels[i + 1]}`);
}
} }
}
} }
this.chartColorsOrdered = chartColors.slice(0, this.feeLevelsOrdered.length); this.chartColorsOrdered = chartColors.slice(0, this.feeLevelsOrdered.length);
} }

View File

@ -84,8 +84,7 @@
</div> </div>
<div class="card-body"> <div class="card-body">
<div class="incoming-transactions-graph"> <div class="incoming-transactions-graph">
<app-mempool-graph #mempoolgraph dir="ltr" [template]="'advanced'" [limitFee]="500" <app-mempool-graph #mempoolgraph dir="ltr" [template]="'advanced'" [height]="500" [left]="65" [right]="10"
[limitFilterFee]="filterFeeIndex" [height]="500" [left]="65" [right]="10"
[data]="mempoolStats && mempoolStats.length ? mempoolStats : null"></app-mempool-graph> [data]="mempoolStats && mempoolStats.length ? mempoolStats : null"></app-mempool-graph>
</div> </div>
</div> </div>

View File

@ -3,7 +3,6 @@
<div class="chart-holder"> <div class="chart-holder">
<app-mempool-graph <app-mempool-graph
[template]="'advanced'" [template]="'advanced'"
[limitFee]="500"
[height]="600" [height]="600"
[left]="60" [left]="60"
[right]="10" [right]="10"

View File

@ -26,8 +26,7 @@
<div class="mempool-graph"> <div class="mempool-graph">
<app-mempool-graph <app-mempool-graph
[template]="'widget'" [template]="'widget'"
[limitFee]="150" [filterSize]="1000000"
[limitFilterFee]="1"
[data]="mempoolStats.value?.mempool" [data]="mempoolStats.value?.mempool"
[windowPreferenceOverride]="'2h'" [windowPreferenceOverride]="'2h'"
></app-mempool-graph> ></app-mempool-graph>