From a389ed8ec3e180b1cd206d76b317a6c35406ce62 Mon Sep 17 00:00:00 2001 From: wisonic-s Date: Thu, 28 Mar 2024 14:52:38 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=9B=BE=E8=A1=A8):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E7=80=91=E5=B8=83=E5=9B=BE=E5=9B=BE=E4=BE=8B=E9=80=89=E9=A1=B9?= =?UTF-8?q?=E6=97=A0=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../js/panel/charts/bar/waterfall.ts | 77 +++++++++++-------- 1 file changed, 46 insertions(+), 31 deletions(-) diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/bar/waterfall.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/bar/waterfall.ts index eac9a7ac46..a584f2d57b 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/bar/waterfall.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/bar/waterfall.ts @@ -127,37 +127,6 @@ export class Waterfall extends G2PlotChartView { fill: setGradientColor(hexColorToRGBA(totalColorRgba, alpha), gradient, 270) } }, - legend: { - items: [ - { - name: '增加', - value: '', - marker: { - style: { - fill: setGradientColor(hexColorToRGBA(risingColorRgba, alpha), gradient, 270) - } - } - }, - { - name: '减少', - value: '', - marker: { - style: { - fill: setGradientColor(hexColorToRGBA(fallingColorRgba, alpha), gradient, 270) - } - } - }, - { - name: '合计', - value: '', - marker: { - style: { - fill: setGradientColor(hexColorToRGBA(totalColorRgba, alpha), gradient, 270) - } - } - } - ] - }, risingFill: setGradientColor(hexColorToRGBA(risingColorRgba, alpha), gradient, 270), fallingFill: setGradientColor(hexColorToRGBA(fallingColorRgba, alpha), gradient, 270) } @@ -256,9 +225,55 @@ export class Waterfall extends G2PlotChartView { } } + protected configLegend(chart: Chart, options: WaterfallOptions): WaterfallOptions { + const tmp = super.configLegend(chart, options) + if (!tmp.legend) { + return tmp + } + const customAttr = parseJson(chart.customAttr) + const { colors, gradient, alpha } = customAttr.basicStyle + const [risingColorRgba, fallingColorRgba, totalColorRgba] = colors + return { + ...tmp, + legend: { + ...tmp.legend, + items: [ + { + name: '增加', + value: '', + marker: { + style: { + fill: setGradientColor(hexColorToRGBA(risingColorRgba, alpha), gradient, 270) + } + } + }, + { + name: '减少', + value: '', + marker: { + style: { + fill: setGradientColor(hexColorToRGBA(fallingColorRgba, alpha), gradient, 270) + } + } + }, + { + name: '合计', + value: '', + marker: { + style: { + fill: setGradientColor(hexColorToRGBA(totalColorRgba, alpha), gradient, 270) + } + } + } + ] + } + } + } + protected setupOptions(chart: Chart, options: WaterfallOptions): WaterfallOptions { return flow( this.configTheme, + this.configLegend, this.configBasicStyle, this.configLabel, this.configTooltip,