From 97ded1a3158c1cebed049b3e079606a8ef7791a3 Mon Sep 17 00:00:00 2001 From: ulleo Date: Tue, 24 Jun 2025 14:26:26 +0800 Subject: [PATCH] feat: pie chart add label --- frontend/src/views/chat/component/charts/Pie.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/frontend/src/views/chat/component/charts/Pie.ts b/frontend/src/views/chat/component/charts/Pie.ts index 76b5192e..ba2d5cd5 100644 --- a/frontend/src/views/chat/component/charts/Pie.ts +++ b/frontend/src/views/chat/component/charts/Pie.ts @@ -24,6 +24,10 @@ export class Pie extends BaseG2Chart { .encode('y', y[0].value) .encode('color', series[0].value) .legend('color', { position: 'bottom', layout: { justifyContent: 'center' } }) + .label({ + position: 'outside', + text: (data: any) => `${data[series[0].value]}: ${data[y[0].value]}`, + }) .tooltip((data) => { return { name: y[0].name, value: data[y[0].value] } })