Fix statistics graphs
This commit is contained in:
parent
d2f7864266
commit
5b2ecac1f6
@ -66,7 +66,7 @@ export class IncomingTransactionsGraphComponent implements OnInit, OnChanges, On
|
|||||||
if (!this.data) {
|
if (!this.data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.windowPreference = this.windowPreferenceOverride ? this.windowPreferenceOverride : this.storageService.getValue('graphWindowPreference');
|
this.windowPreference = (this.windowPreferenceOverride ? this.windowPreferenceOverride : this.storageService.getValue('graphWindowPreference')) || '2h';
|
||||||
const windowSize = Math.max(10, Math.floor(this.data.series[0].length / 8));
|
const windowSize = Math.max(10, Math.floor(this.data.series[0].length / 8));
|
||||||
this.MA = this.calculateMA(this.data.series[0], windowSize);
|
this.MA = this.calculateMA(this.data.series[0], windowSize);
|
||||||
if (this.outlierCappingEnabled === true) {
|
if (this.outlierCappingEnabled === true) {
|
||||||
@ -216,22 +216,19 @@ export class IncomingTransactionsGraphComponent implements OnInit, OnChanges, On
|
|||||||
type: 'line',
|
type: 'line',
|
||||||
},
|
},
|
||||||
formatter: (params: any) => {
|
formatter: (params: any) => {
|
||||||
const axisValueLabel: string = formatterXAxis(this.locale, this.windowPreference, params[0].axisValue);
|
const bestItem = params.reduce((best, item) => {
|
||||||
|
return (item.seriesName === 'data' && (!best || best.value[1] < item.value[1])) ? item : best;
|
||||||
|
}, null);
|
||||||
|
const axisValueLabel: string = formatterXAxis(this.locale, this.windowPreference, bestItem.axisValue);
|
||||||
const colorSpan = (color: string) => `<span class="indicator" style="background-color: ` + color + `"></span>`;
|
const colorSpan = (color: string) => `<span class="indicator" style="background-color: ` + color + `"></span>`;
|
||||||
let itemFormatted = '<div class="title">' + axisValueLabel + '</div>';
|
let itemFormatted = '<div class="title">' + axisValueLabel + '</div>';
|
||||||
params.map((item: any, index: number) => {
|
if (bestItem) {
|
||||||
|
itemFormatted += `<div class="item">
|
||||||
//Do no include MA in tooltip legend!
|
<div class="indicator-container">${colorSpan(bestItem.color)}</div>
|
||||||
if (item.seriesName !== 'MA') {
|
|
||||||
if (index < 26) {
|
|
||||||
itemFormatted += `<div class="item">
|
|
||||||
<div class="indicator-container">${colorSpan(item.color)}</div>
|
|
||||||
<div class="grow"></div>
|
<div class="grow"></div>
|
||||||
<div class="value">${formatNumber(item.value[1], this.locale, '1.0-0')}<span class="symbol">vB/s</span></div>
|
<div class="value">${formatNumber(bestItem.value[1], this.locale, '1.0-0')}<span class="symbol">vB/s</span></div>
|
||||||
</div>`;
|
</div>`;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
return `<div class="tx-wrapper-tooltip-chart ${(this.template === 'advanced') ? 'tx-wrapper-tooltip-chart-advanced' : ''}"
|
return `<div class="tx-wrapper-tooltip-chart ${(this.template === 'advanced') ? 'tx-wrapper-tooltip-chart-advanced' : ''}"
|
||||||
style="width: ${(this.windowPreference === '2h' || this.template === 'widget') ? '125px' : '215px'}">${itemFormatted}</div>`;
|
style="width: ${(this.windowPreference === '2h' || this.template === 'widget') ? '125px' : '215px'}">${itemFormatted}</div>`;
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ export class MempoolGraphComponent implements OnInit, OnChanges {
|
|||||||
}
|
}
|
||||||
this.isWidget = this.template === 'widget';
|
this.isWidget = this.template === 'widget';
|
||||||
this.showCount = !this.isWidget && !this.hideCount;
|
this.showCount = !this.isWidget && !this.hideCount;
|
||||||
this.windowPreference = this.windowPreferenceOverride ? this.windowPreferenceOverride : this.storageService.getValue('graphWindowPreference');
|
this.windowPreference = (this.windowPreferenceOverride ? this.windowPreferenceOverride : this.storageService.getValue('graphWindowPreference')) || '2h';
|
||||||
this.mempoolVsizeFeesData = this.handleNewMempoolData(this.data.concat([]));
|
this.mempoolVsizeFeesData = this.handleNewMempoolData(this.data.concat([]));
|
||||||
this.mountFeeChart();
|
this.mountFeeChart();
|
||||||
}
|
}
|
||||||
@ -256,11 +256,17 @@ export class MempoolGraphComponent implements OnInit, OnChanges {
|
|||||||
const itemFormatted = [];
|
const itemFormatted = [];
|
||||||
let sum = 0;
|
let sum = 0;
|
||||||
let progressPercentageText = '';
|
let progressPercentageText = '';
|
||||||
let countItem;
|
const unfilteredItems = this.inverted ? [...params].reverse() : params;
|
||||||
let items = this.inverted ? [...params].reverse() : params;
|
const countItem = unfilteredItems.find(p => p.seriesName === 'count');
|
||||||
if (items[items.length - 1].seriesName === 'count') {
|
const usedSeries = {};
|
||||||
countItem = items.pop();
|
const items = unfilteredItems.filter(p => {
|
||||||
}
|
if (usedSeries[p.seriesName] || p.seriesName === 'count') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
usedSeries[p.seriesName] = true;
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
items.map((item: any, index: number) => {
|
items.map((item: any, index: number) => {
|
||||||
sum += item.value[1];
|
sum += item.value[1];
|
||||||
const progressPercentage = (item.value[1] / totalValue) * 100;
|
const progressPercentage = (item.value[1] / totalValue) * 100;
|
||||||
|
@ -231,8 +231,10 @@ export class DashboardComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||||||
this.stateService.live2Chart$
|
this.stateService.live2Chart$
|
||||||
.pipe(
|
.pipe(
|
||||||
scan((acc, stats) => {
|
scan((acc, stats) => {
|
||||||
|
const now = Date.now() / 1000;
|
||||||
|
const start = now - (2 * 60 * 60);
|
||||||
acc.unshift(stats);
|
acc.unshift(stats);
|
||||||
acc = acc.slice(0, 120);
|
acc = acc.filter(p => p.added >= start);
|
||||||
return acc;
|
return acc;
|
||||||
}, (mempoolStats || []))
|
}, (mempoolStats || []))
|
||||||
),
|
),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user