From 0ead7aa722c5361ef92da64e710f6920e4aa8243 Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 25 May 2021 22:14:37 +0200 Subject: [PATCH] Don't add series to legend if series does not exist --- src/components/charts/CandleChart.vue | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/components/charts/CandleChart.vue b/src/components/charts/CandleChart.vue index a502c33a..f041a914 100644 --- a/src/components/charts/CandleChart.vue +++ b/src/components/charts/CandleChart.vue @@ -453,16 +453,12 @@ export default class CandleChart extends Vue { }); } Object.entries(value).forEach(([sk, sv]) => { - if ( - !Array.isArray(this.chartOptions.legend) && - this.chartOptions.legend?.data && - Array.isArray(this.chartOptions.legend.data) - ) { - this.chartOptions.legend.data.push(sk); - } // entries per subplot const col = this.dataset.columns.findIndex((el) => el === sk); if (col > 0) { + if (!Array.isArray(this.chartOptions.legend) && this.chartOptions.legend?.data) { + this.chartOptions.legend.data.push(sk); + } const sp: SeriesOption = { name: sk, type: sv.type || 'line', @@ -519,11 +515,7 @@ export default class CandleChart extends Vue { if (Array.isArray(this.chartOptions?.series)) { this.chartOptions.series.push(sp); } - if ( - this.chartOptions.legend && - !Array.isArray(this.chartOptions.legend) && - this.chartOptions.legend.data - ) { + if (!Array.isArray(this.chartOptions.legend) && this.chartOptions.legend?.data) { this.chartOptions.legend.data.push(nameClose); } const closeSeries: ScatterSeriesOption = {