From d3330e35a43401af23089da307453e6921856917 Mon Sep 17 00:00:00 2001 From: wisonic-s Date: Wed, 24 Apr 2024 16:28:45 +0800 Subject: [PATCH] =?UTF-8?q?perf(=E5=9B=BE=E8=A1=A8):=20=E6=B0=B4=E6=B3=A2?= =?UTF-8?q?=E5=9B=BE=E5=92=8C=E4=BB=AA=E8=A1=A8=E7=9B=98=E6=97=A0=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E4=B8=8D=E6=B8=B2=E6=9F=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../js/panel/charts/liquid/liquid.ts | 15 ++--- .../js/panel/charts/others/gauge.ts | 59 ++++++++++--------- 2 files changed, 38 insertions(+), 36 deletions(-) diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/liquid/liquid.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/liquid/liquid.ts index c78493fd56..40de8d9e64 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/liquid/liquid.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/liquid/liquid.ts @@ -50,14 +50,15 @@ export class Liquid extends G2PlotChartView { drawChart(drawOptions: G2PlotDrawOptions): G2Liquid { const { chart, container } = drawOptions - if (chart?.data) { - const initOptions: LiquidOptions = { - percent: 0 - } - const options = this.setupOptions(chart, initOptions) - // 开始渲染 - return new G2Liquid(container, options) + if (!chart.data?.series) { + return } + const initOptions: LiquidOptions = { + percent: 0 + } + const options = this.setupOptions(chart, initOptions) + // 开始渲染 + return new G2Liquid(container, options) } protected configTheme(chart: Chart, options: LiquidOptions): LiquidOptions { diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/others/gauge.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/others/gauge.ts index 1c51333171..d89051a874 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/others/gauge.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/others/gauge.ts @@ -65,40 +65,41 @@ export class Gauge extends G2PlotChartView { drawChart(drawOptions: G2PlotDrawOptions): G2Gauge { const { chart, container, scale } = drawOptions - if (chart?.data) { - // options - const initOptions: GaugeOptions = { - percent: 0, - appendPadding: getPadding(chart), - axis: { - tickInterval: 0.2, - label: { - style: { - fontSize: getScaleValue(12, scale) // 刻度值字体大小 - }, - formatter: function (v) { - const r = parseFloat(v) - return v === '0' || !r ? v : r * 100 + '%' - } + if (!chart.data?.series) { + return + } + // options + const initOptions: GaugeOptions = { + percent: 0, + appendPadding: getPadding(chart), + axis: { + tickInterval: 0.2, + label: { + style: { + fontSize: getScaleValue(12, scale) // 刻度值字体大小 }, - tickLine: { - length: getScaleValue(12, scale) * -1, // 刻度线长度 - style: { - lineWidth: getScaleValue(1, scale) // 刻度线宽度 - } - }, - subTickLine: { - count: 4, // 子刻度数 - length: getScaleValue(6, scale) * -1, // 子刻度线长度 - style: { - lineWidth: getScaleValue(1, scale) // 子刻度线宽度 - } + formatter: function (v) { + const r = parseFloat(v) + return v === '0' || !r ? v : r * 100 + '%' + } + }, + tickLine: { + length: getScaleValue(12, scale) * -1, // 刻度线长度 + style: { + lineWidth: getScaleValue(1, scale) // 刻度线宽度 + } + }, + subTickLine: { + count: 4, // 子刻度数 + length: getScaleValue(6, scale) * -1, // 子刻度线长度 + style: { + lineWidth: getScaleValue(1, scale) // 子刻度线宽度 } } } - const options = this.setupOptions(chart, initOptions, scale) - return new G2Gauge(container, options) } + const options = this.setupOptions(chart, initOptions, scale) + return new G2Gauge(container, options) } protected configMisc(chart: Chart, options: GaugeOptions): GaugeOptions {