From f3a9386ebf4394694eed21a0c626dae754ac8c81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=81=A5?= Date: Tue, 11 Apr 2023 15:47:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=9B=BE=E8=A1=A8=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E9=80=89=E9=A1=B9=E7=8A=B6=E6=80=81=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/useCreateElement.ts | 14 +++++++++----- .../ElementStylePanel/ChartStylePanel/index.vue | 12 ++++++------ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/hooks/useCreateElement.ts b/src/hooks/useCreateElement.ts index 2c64ee3e..58e9575d 100644 --- a/src/hooks/useCreateElement.ts +++ b/src/hooks/useCreateElement.ts @@ -103,11 +103,15 @@ export default () => { }, } - let options: ChartOptions = {} - if (type === 'horizontalBar') options = { horizontalBars: true } - else if (type === 'area') options = { showArea: true } - else if (type === 'scatter') options = { showLine: false } - else if (type === 'ring') options = { donut: true } + const options: ChartOptions = { + ...(type === 'bar' ? { horizontalBars: false, stackBars: false } : {}), + ...(type === 'horizontalBar' ? { horizontalBars: true, stackBars: false } : {}), + ...(type === 'line' ? { showLine: true, lineSmooth: true, showArea: false } : {}), + ...(type === 'area' ? { showLine: true, lineSmooth: true, showArea: true } : {}), + ...(type === 'scatter' ? { showLine: false, lineSmooth: true, showArea: false } : {}), + ...(type === 'pie' ? { donut: false } : {}), + ...(type === 'ring' ? { donut: true } : {}), + } createElement({ ...newElement, diff --git a/src/views/Editor/Toolbar/ElementStylePanel/ChartStylePanel/index.vue b/src/views/Editor/Toolbar/ElementStylePanel/ChartStylePanel/index.vue index 1b00ae95..4050f253 100644 --- a/src/views/Editor/Toolbar/ElementStylePanel/ChartStylePanel/index.vue +++ b/src/views/Editor/Toolbar/ElementStylePanel/ChartStylePanel/index.vue @@ -230,12 +230,12 @@ watch(handleElement, () => { stackBars: _stackBars, } = handleElement.value.options - if (_lineSmooth !== undefined) lineSmooth.value = _lineSmooth as boolean - if (_showLine !== undefined) showLine.value = _showLine - if (_showArea !== undefined) showArea.value = _showArea - if (_horizontalBars !== undefined) horizontalBars.value = _horizontalBars - if (_donut !== undefined) donut.value = _donut - if (_stackBars !== undefined) stackBars.value = _stackBars + lineSmooth.value = !!_lineSmooth + showLine.value = !!_showLine + showArea.value = !!_showArea + horizontalBars.value = !!_horizontalBars + donut.value = !!_donut + stackBars.value = !!_stackBars } themeColor.value = handleElement.value.themeColor