From 3942b7cb949e306f1df8d07422849c79f4941642 Mon Sep 17 00:00:00 2001 From: YANG QIA <2013xile@gmail.com> Date: Mon, 18 Mar 2024 12:33:03 +0800 Subject: [PATCH] fix(data-vi): tooltip bug of pie chart (#3745) --- .../src/client/chart/g2plot/pie.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/plugins/@nocobase/plugin-data-visualization/src/client/chart/g2plot/pie.ts b/packages/plugins/@nocobase/plugin-data-visualization/src/client/chart/g2plot/pie.ts index dc75e17b37..588a33f106 100644 --- a/packages/plugins/@nocobase/plugin-data-visualization/src/client/chart/g2plot/pie.ts +++ b/packages/plugins/@nocobase/plugin-data-visualization/src/client/chart/g2plot/pie.ts @@ -1,6 +1,6 @@ import { G2PlotChart } from './g2plot'; import { Pie as G2Pie } from '@ant-design/plots'; -import { ChartType } from '../chart'; +import { ChartType, RenderProps } from '../chart'; export class Pie extends G2PlotChart { constructor() { @@ -30,4 +30,19 @@ export class Pie extends G2PlotChart { }, }; }; + + getProps({ data, general, advanced, fieldProps }: RenderProps) { + const props = super.getProps({ data, general, advanced, fieldProps }); + return { + ...props, + tooltip: (d, index: number, data, column: any) => { + const field = column.y0.field; + const props = fieldProps[field]; + const name = props?.label || field; + const transformer = props?.transformer; + const value = column.y0.value[index]; + return { name, value: transformer ? transformer(value) : value }; + }, + }; + } }