From c35ece5561a0970f4062e7dedd84c7f81bf4fd76 Mon Sep 17 00:00:00 2001 From: ulleo Date: Thu, 11 Dec 2025 18:11:02 +0800 Subject: [PATCH] fix: fix pie chart display showing incorrect visual proportions --- frontend/src/views/chat/component/charts/Pie.ts | 12 ++++++++++-- g2-ssr/charts/pie.js | 14 +++++++++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/frontend/src/views/chat/component/charts/Pie.ts b/frontend/src/views/chat/component/charts/Pie.ts index 433b1f05..baaf707c 100644 --- a/frontend/src/views/chat/component/charts/Pie.ts +++ b/frontend/src/views/chat/component/charts/Pie.ts @@ -30,16 +30,24 @@ export class Pie extends BaseG2Chart { y: y[0].value, color: series[0].value, }, + scale: { + x: { + nice: true, + }, + y: { + type: 'linear', + }, + }, legend: { color: { position: 'bottom', layout: { justifyContent: 'center' } }, }, + animate: { enter: { type: 'waveIn' } }, labels: [ { - position: 'outside', + position: 'spider', text: (data: any) => { return `${data[series[0].value]}: ${data[y[0].value]}${_data.isPercent ? '%' : ''}` }, - transform: [{ type: 'exceedAdjust' }, { type: 'overlapHide' }], }, ], tooltip: { diff --git a/g2-ssr/charts/pie.js b/g2-ssr/charts/pie.js index eb52534b..3495b476 100644 --- a/g2-ssr/charts/pie.js +++ b/g2-ssr/charts/pie.js @@ -21,18 +21,22 @@ function getPieOptions(baseOptions, axis, data) { y: y[0].value, color: series[0].value, }, + scale: { + x: { + nice: true, + }, + y: { + type: 'linear', + }, + }, legend: { color: {position: 'bottom', layout: {justifyContent: 'center'}}, }, labels: [ { - position: 'outside', + position: 'spider', text: (data) => `${data[series[0].value]}: ${data[y[0].value]}${_data.isPercent ? '%' : ''}`, - transform: [ - { type: 'exceedAdjust' }, - { type: 'overlapHide' }, - ], }, ], tooltip: {