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 dc75e17b3..588a33f10 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 }; + }, + }; + } }