From ed69591bcf3afe145d08f129e890324af2ef5de8 Mon Sep 17 00:00:00 2001 From: nymkappa <1612910616@pm.me> Date: Wed, 22 Mar 2023 14:09:30 +0900 Subject: [PATCH] Show "No data to display yet" in "Fee distribution" chart on node page when there are no channels yet --- .../node-fee-chart.component.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/frontend/src/app/lightning/node-fee-chart/node-fee-chart.component.ts b/frontend/src/app/lightning/node-fee-chart/node-fee-chart.component.ts index 242ecc6ed..97268226d 100644 --- a/frontend/src/app/lightning/node-fee-chart/node-fee-chart.component.ts +++ b/frontend/src/app/lightning/node-fee-chart/node-fee-chart.component.ts @@ -101,8 +101,15 @@ export class NodeFeeChartComponent implements OnInit { } prepareChartOptions(outgoingData, incomingData): void { + let sum = outgoingData.reduce((accumulator, object) => { + return accumulator + object.count; + }, 0); + sum += incomingData.reduce((accumulator, object) => { + return accumulator + object.count; + }, 0); + let title: object; - if (outgoingData.length === 0) { + if (sum === 0) { title = { textStyle: { color: 'grey', @@ -115,7 +122,7 @@ export class NodeFeeChartComponent implements OnInit { } this.chartOptions = { - title: outgoingData.length === 0 ? title : undefined, + title: sum === 0 ? title : undefined, animation: false, grid: { top: 30, @@ -151,7 +158,7 @@ export class NodeFeeChartComponent implements OnInit { `; } }, - xAxis: outgoingData.length === 0 ? undefined : { + xAxis: sum === 0 ? undefined : { type: 'category', axisLine: { onZero: true }, axisLabel: { @@ -163,7 +170,7 @@ export class NodeFeeChartComponent implements OnInit { }, data: outgoingData.map(bucket => bucket.label) }, - legend: outgoingData.length === 0 ? undefined : { + legend: sum === 0 ? undefined : { padding: 10, data: [ { @@ -184,7 +191,7 @@ export class NodeFeeChartComponent implements OnInit { }, ], }, - yAxis: outgoingData.length === 0 ? undefined : [ + yAxis: sum === 0 ? undefined : [ { type: 'value', axisLabel: { @@ -202,7 +209,7 @@ export class NodeFeeChartComponent implements OnInit { }, }, ], - series: outgoingData.length === 0 ? undefined : [ + series: sum === 0 ? undefined : [ { zlevel: 0, name: $localize`Outgoing Fees`,