From f955cb3e0bcc8601cc86b175ce442acb87aaba38 Mon Sep 17 00:00:00 2001 From: wisonic-s Date: Wed, 5 Jun 2024 16:44:54 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E5=9B=BE=E8=A1=A8):=20=E9=9D=A2?= =?UTF-8?q?=E7=A7=AF=E5=9B=BE=E6=97=A0=E6=95=B0=E6=8D=AE=E4=B8=8D=E6=B8=B2?= =?UTF-8?q?=E6=9F=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/js/panel/charts/line/area.ts | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/line/area.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/line/area.ts index 5b5c376214..db8088713c 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/line/area.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/line/area.ts @@ -86,24 +86,25 @@ export class Area extends G2PlotChartView { drawChart(drawOptions: G2PlotDrawOptions): G2Area { const { chart, container, action } = drawOptions - if (chart?.data) { - // data - const data = cloneDeep(chart.data.data) - - const initOptions: AreaOptions = { - ...this.baseOptions, - data, - appendPadding: getPadding(chart) - } - // options - const options = this.setupOptions(chart, initOptions) - // 开始渲染 - const newChart = new G2Area(container, options) - - newChart.on('point:click', action) - - return newChart + if (!chart.data.data?.length) { + return } + // data + const data = cloneDeep(chart.data.data) + + const initOptions: AreaOptions = { + ...this.baseOptions, + data, + appendPadding: getPadding(chart) + } + // options + const options = this.setupOptions(chart, initOptions) + // 开始渲染 + const newChart = new G2Area(container, options) + + newChart.on('point:click', action) + + return newChart } protected configLabel(chart: Chart, options: AreaOptions): AreaOptions {