From cff2ce34f107f4b3ec76b7e458b6fe144f60257d Mon Sep 17 00:00:00 2001 From: tcy <1193318383@qq.com> Date: Fri, 22 Aug 2025 19:14:27 +0800 Subject: [PATCH] =?UTF-8?q?refactor(largeScreen):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E7=8E=B0=E9=87=91=E6=B5=81=E6=8A=A5=E8=A1=A8=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 调整 legend 位置和样式 - 优化 tooltip 内容和格式 - 调整图表布局和样式 --- .../largeScreen/components/optionList.ts | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/views/largeScreen/components/optionList.ts b/src/views/largeScreen/components/optionList.ts index 3c7c900..0daec3b 100644 --- a/src/views/largeScreen/components/optionList.ts +++ b/src/views/largeScreen/components/optionList.ts @@ -696,23 +696,29 @@ export const getInventoryOption = () => { }; export const getBarOptions = (data: any) => { const option = { - - legend: { - show: true, - top: '50%', - }, backgroundColor: '', grid: { left: '8%', - top: '4%', + top: '10%', // 顶部留一点空间给 legend bottom: '8%', right: '2%' }, + legend: { + data: ['现金流入', '现金流出'], // 与 series.name 对应 + top: '0%', + textStyle: { color: '#fff', fontSize: 12 } + }, tooltip: { show: true, backgroundColor: '', trigger: 'axis', - formatter: '{b0}:{c0}万元', + // formatter: '{b0}:{c0}万元', + formatter: (params: any) => { + // params 是数组,对应每条柱子 + return params + .map((p: any) => `${p.seriesName}:${p.value} 万元`) + .join('
'); + }, textStyle: { color: '#fff' }, @@ -788,6 +794,7 @@ export const getBarOptions = (data: any) => { // ], series: [ { + name: '现金流入', type: 'bar', data: data.value[0], // stack: '合并', @@ -826,6 +833,7 @@ export const getBarOptions = (data: any) => { } }, { + name: '现金流出', type: 'bar', data: data.value[1], // stack: '合并', @@ -859,8 +867,8 @@ export const getBarOptions = (data: any) => { formatter: '{c}', position: 'top', color: '#fff', - fontSize: 10 - // padding: 5 + fontSize: 10, + padding: 5 } } ] @@ -888,7 +896,9 @@ export const getBarOptions2 = (data: any) => { } }, tooltip: { - trigger: 'item' + trigger: 'item', + show: true + }, legend: { top: '5%',