Change renderer to svg.

Fix data structure of mempool graph.
Change tooltip total position (top).
Change tooltip visual of partial porcentage.
This commit is contained in:
Miguel Medeiros 2021-09-07 17:48:43 -03:00
parent 584d091d4e
commit 9020c618f0
No known key found for this signature in database
GPG Key ID: 819EDEE4673F3EBB
4 changed files with 25 additions and 29 deletions

View File

@ -1 +1 @@
<div echarts class="echarts" (chartInit)="onChartReady($event)" [options]="mempoolVsizeFeesOptions"></div> <div echarts class="echarts" (chartInit)="onChartReady($event)" [initOpts]="mempoolVsizeFeesInitOptions" [options]="mempoolVsizeFeesOptions"></div>

View File

@ -24,6 +24,9 @@ export class MempoolGraphComponent implements OnInit, OnChanges {
mempoolVsizeFeesData: any; mempoolVsizeFeesData: any;
mempoolVsizeFeesOptions: EChartsOption; mempoolVsizeFeesOptions: EChartsOption;
mempoolVsizeFeesInitOptions = {
renderer: 'svg',
};
windowPreference: string; windowPreference: string;
hoverIndexSerie: -1; hoverIndexSerie: -1;
feeLimitIndex: number; feeLimitIndex: number;
@ -70,20 +73,11 @@ export class MempoolGraphComponent implements OnInit, OnChanges {
generateArray(mempoolStats: OptimizedMempoolStats[]) { generateArray(mempoolStats: OptimizedMempoolStats[]) {
const finalArray: number[][] = []; const finalArray: number[][] = [];
let feesArray: number[] = []; let feesArray: number[] = [];
for (let index = 37; index > -1; index--) { for (let index = 37; index > -1; index--) {
feesArray = []; feesArray = [];
mempoolStats.forEach((stats) => { mempoolStats.forEach((stats) => {
const theFee = stats.vsizes[index].toString(); feesArray.push(stats.vsizes[index] ? stats.vsizes[index] : 0);
if (theFee) {
feesArray.push(parseInt(theFee, 10));
} else {
feesArray.push(0);
}
}); });
if (finalArray.length) {
feesArray = feesArray.map((value, i) => value + finalArray[finalArray.length - 1][i]);
}
finalArray.push(feesArray); finalArray.push(feesArray);
} }
finalArray.reverse(); finalArray.reverse();
@ -103,10 +97,9 @@ export class MempoolGraphComponent implements OnInit, OnChanges {
} }
}); });
const yAxisSeries = series.map((value: Array<number>, index: number) => { const seriesGraph = series.map((value: Array<number>, index: number) => {
if (index <= this.feeLimitIndex){ if (index <= this.feeLimitIndex){
return { return {
name: feeLevelsOrdered[index],
type: 'line', type: 'line',
stack: 'total', stack: 'total',
smooth: false, smooth: false,
@ -157,42 +150,37 @@ export class MempoolGraphComponent implements OnInit, OnChanges {
}, },
formatter: (params: any) => { formatter: (params: any) => {
const legendName = (index: number) => feeLevelsOrdered[index]; const legendName = (index: number) => feeLevelsOrdered[index];
const colorSpan = (index: number) => `<span class="indicator" style="background-color: ${chartColors[index]}"></span><span>${legendName(index)}</span>`; const colorSpan = (index: number) => `<span class="indicator" style="background-color: ${chartColors[index]}"></span><span>${legendName(index)}`;
const title = `<div class="title">${params[0].axisValue}</div>`;
const rangeLines = params;
let total = 0; let total = 0;
rangeLines.map((item: any) => { params.map((item: any) => {
total += item.value; total += item.value;
}); });
const title = `<div class="title">${params[0].axisValue}
<span class="total-value">${this.vbytesPipe.transform(total, 2, 'vB', 'MvB', false)}</span></div>`;
const itemFormatted = []; const itemFormatted = [];
let totalParcial = 0; let totalParcial = 0;
let progressPercentageText = ''; let progressPercentageText = '';
rangeLines.map((item: any, index: number) => { params.map((item: any, index: number) => {
totalParcial += item.value; totalParcial += item.value;
let progressPercentage = 0; let progressPercentage = 0;
let progressPercentageTotalParcial = 0;
if (index <= this.feeLimitIndex) { if (index <= this.feeLimitIndex) {
progressPercentage = (item.value / total) * 100; progressPercentage = (item.value / total) * 100;
progressPercentageTotalParcial = (totalParcial / total) * 100;
let activeItemClass = ''; let activeItemClass = '';
if (this.hoverIndexSerie === index) { if (this.hoverIndexSerie === index) {
progressPercentageText = `<div class="total-parcial-active"> progressPercentageText = `<div class="total-parcial-active">
<span>${this.vbytesPipe.transform(totalParcial, 2, 'vB', 'MvB', false)}</span> <span class="progress-percentage">${progressPercentage.toFixed(2)} <span class="symbol">%</span></span><span class="total-parcial-vbytes">${this.vbytesPipe.transform(totalParcial, 2, 'vB', 'MvB', false)}</span>
<div class="total-percentage-bar"><span><span style="width: ${progressPercentageTotalParcial}%; background: ${chartColors[index]}"></span></span></div> <div class="total-percentage-bar"><span><span style="width: ${progressPercentage}%; background: ${chartColors[index]}"></span></span></div>
</div>`; </div>`;
activeItemClass = 'active'; activeItemClass = 'active';
} }
itemFormatted.push(`<tr class="item ${activeItemClass}"> itemFormatted.push(`<tr class="item ${activeItemClass}">
<td class="indicator-container">${colorSpan(index)}</td> <td class="indicator-container">${colorSpan(index)}</td>
<td class="value">${this.vbytesPipe.transform(item.value, 2, 'vB', 'MvB', false)}</td> <td class="value">${this.vbytesPipe.transform(item.value, 2, 'vB', 'MvB', false)}</td>
<td class="total-percentage-bar"><span><span style="width: ${progressPercentage}%; background: ${chartColors[index]}"></span></span></td> <td class="total-progress-percentage"><span color: ${chartColors[index]}">${progressPercentage.toFixed(1)} <span class="symbol">%</span></td>
</tr>`); </tr>`);
} }
}); });
const progressActiveDiv = `<span class="total-value">${progressPercentageText}</span>`; const progressActiveDiv = `<span class="total-value">${progressPercentageText}</span>`;
const totalDiv = `<div class="total-label">Total
<span class="total-value">${this.vbytesPipe.transform(total, 2, 'vB', 'MvB', false)}</span>
</div>`;
const advancedClass = (this.template === 'advanced') ? 'fees-wrapper-tooltip-chart-advanced' : ''; const advancedClass = (this.template === 'advanced') ? 'fees-wrapper-tooltip-chart-advanced' : '';
return `<div class="fees-wrapper-tooltip-chart ${advancedClass}"> return `<div class="fees-wrapper-tooltip-chart ${advancedClass}">
${title} ${title}
@ -207,7 +195,6 @@ export class MempoolGraphComponent implements OnInit, OnChanges {
<tbody>${itemFormatted.reverse().join('')}</tbody> <tbody>${itemFormatted.reverse().join('')}</tbody>
</table> </table>
${progressActiveDiv} ${progressActiveDiv}
${totalDiv}
</div>`; </div>`;
} }
}, },
@ -261,7 +248,7 @@ export class MempoolGraphComponent implements OnInit, OnChanges {
} }
} }
}, },
series: yAxisSeries series: seriesGraph
}; };
} }
} }

View File

@ -6,7 +6,7 @@ export interface OptimizedMempoolStats {
vbytes_per_second: number; vbytes_per_second: number;
total_fee: number; total_fee: number;
mempool_byte_weight: number; mempool_byte_weight: number;
vsizes: number[] | string[]; vsizes: number[];
} }
interface Ancestor { interface Ancestor {

View File

@ -294,6 +294,9 @@ html:lang(ru) .card-title {
font-weight: 700; font-weight: 700;
margin-bottom: 2px; margin-bottom: 2px;
color: #fff; color: #fff;
.total-value {
float: right;
}
} }
.active { .active {
color: yellow !important; color: yellow !important;
@ -332,6 +335,9 @@ html:lang(ru) .card-title {
.total-percentage-bar { .total-percentage-bar {
padding-left: 8px; padding-left: 8px;
} }
.total-progress-percentage {
text-align: right;
}
} }
.total-label { .total-label {
width: 100%; width: 100%;
@ -376,6 +382,9 @@ html:lang(ru) .card-title {
transition: 1000 all ease-in-out; transition: 1000 all ease-in-out;
} }
} }
.progress-percentage {
float: left;
}
} }
} }