From c33f0ca90c1bae61e74f8f63d16216d392c2ea52 Mon Sep 17 00:00:00 2001 From: sunfanbo Date: Tue, 8 Apr 2025 11:49:04 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat(chart):=20=E4=B8=BA=E6=9F=B1=E7=8A=B6?= =?UTF-8?q?=E5=9B=BE=E6=B7=BB=E5=8A=A0=E6=9F=B1=E5=AD=90=E5=AE=BD=E5=BA=A6?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/types/slides.ts | 1 + .../ChartStylePanel/index.vue | 18 +++++++++++++++++- .../components/element/ChartElement/Chart.vue | 1 + .../element/ChartElement/chartOption.ts | 3 +++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/types/slides.ts b/src/types/slides.ts index 5d14f8303..ff6473664 100644 --- a/src/types/slides.ts +++ b/src/types/slides.ts @@ -416,6 +416,7 @@ export type ChartType = 'bar' | 'column' | 'line' | 'pie' | 'ring' | 'area' | 'r export interface ChartOptions { lineSmooth?: boolean stack?: boolean + barWidth?: number } export interface ChartData { diff --git a/src/views/Editor/Toolbar/ElementStylePanel/ChartStylePanel/index.vue b/src/views/Editor/Toolbar/ElementStylePanel/ChartStylePanel/index.vue index de5258a5f..b2643b481 100644 --- a/src/views/Editor/Toolbar/ElementStylePanel/ChartStylePanel/index.vue +++ b/src/views/Editor/Toolbar/ElementStylePanel/ChartStylePanel/index.vue @@ -20,7 +20,19 @@ style="flex: 3;" >使用平滑曲线 - + +
+
+ 柱子宽度 +
+ +
@@ -130,6 +142,7 @@ import Divider from '@/components/Divider.vue' import Checkbox from '@/components/Checkbox.vue' import Button from '@/components/Button.vue' import Popover from '@/components/Popover.vue' +import NumberInput from '@/components/NumberInput.vue' const mainStore = useMainStore() const slidesStore = useSlidesStore() @@ -150,6 +163,7 @@ const themeColors = ref([]) const textColor = ref('') const lineSmooth = ref(false) const stack = ref(false) +const barWidth = ref() watch(handleElement, () => { if (!handleElement.value || handleElement.value.type !== 'chart') return @@ -162,10 +176,12 @@ watch(handleElement, () => { const { lineSmooth: _lineSmooth, stack: _stack, + barWidth: _barWidth, } = handleElement.value.options if (_lineSmooth !== undefined) lineSmooth.value = _lineSmooth if (_stack !== undefined) stack.value = _stack + if (_barWidth !== undefined) barWidth.value = _barWidth } themeColors.value = handleElement.value.themeColors diff --git a/src/views/components/element/ChartElement/Chart.vue b/src/views/components/element/ChartElement/Chart.vue index d5557120a..cad85e4dc 100644 --- a/src/views/components/element/ChartElement/Chart.vue +++ b/src/views/components/element/ChartElement/Chart.vue @@ -56,6 +56,7 @@ const updateOption = () => { textColor: props.textColor, lineSmooth: props.options?.lineSmooth || false, stack: props.options?.stack || false, + barWidth: props.options?.barWidth }) if (option) chart!.setOption(option, true) } diff --git a/src/views/components/element/ChartElement/chartOption.ts b/src/views/components/element/ChartElement/chartOption.ts index 53d3c3e24..12b6648c3 100644 --- a/src/views/components/element/ChartElement/chartOption.ts +++ b/src/views/components/element/ChartElement/chartOption.ts @@ -17,6 +17,7 @@ export interface ChartOptionPayload { textColor?: string lineSmooth?: boolean stack?: boolean + barWidth?: number } export const getChartOption = ({ @@ -26,6 +27,7 @@ export const getChartOption = ({ textColor, lineSmooth, stack, + barWidth }: ChartOptionPayload): EChartOption | null => { if (type === 'bar') { return { @@ -51,6 +53,7 @@ export const getChartOption = ({ data: item, name: data.legends[index], type: 'bar', + barWidth, label: { show: true, }, From 3b83b2f4b1f183ee88127215b999b3fd7e5cbebd Mon Sep 17 00:00:00 2001 From: sunfanbo Date: Tue, 8 Apr 2025 14:37:41 +0800 Subject: [PATCH 2/2] =?UTF-8?q?refactor(Editor):=20=E5=B0=86"=E6=9F=B1?= =?UTF-8?q?=E5=AD=90=E5=AE=BD=E5=BA=A6"=E4=BF=AE=E6=94=B9=E4=B8=BA"?= =?UTF-8?q?=E6=9F=B1=E6=9D=A1=E5=AE=BD=E5=BA=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Toolbar/ElementStylePanel/ChartStylePanel/index.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/views/Editor/Toolbar/ElementStylePanel/ChartStylePanel/index.vue b/src/views/Editor/Toolbar/ElementStylePanel/ChartStylePanel/index.vue index b2643b481..223aac7ae 100644 --- a/src/views/Editor/Toolbar/ElementStylePanel/ChartStylePanel/index.vue +++ b/src/views/Editor/Toolbar/ElementStylePanel/ChartStylePanel/index.vue @@ -23,11 +23,11 @@
- 柱子宽度 + 柱条宽度