diff --git a/package.json b/package.json index ee793c9cdc..5fa3e385d9 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "dependencies": { "@antv/data-set": "^0.11.5", "@antv/event-emitter": "^0.1.2", - "@antv/g2": "^4.1.0-beta.2", + "@antv/g2": "^4.1.0-beta.6", "dayjs": "^1.8.34", "size-sensor": "^1.0.1", "tslib": "^1.13.0" diff --git a/src/plots/liquid/adaptor.ts b/src/plots/liquid/adaptor.ts index b86f239f4c..d370dc050d 100644 --- a/src/plots/liquid/adaptor.ts +++ b/src/plots/liquid/adaptor.ts @@ -1,3 +1,4 @@ +import { Geometry } from '@antv/g2'; import { deepMix, isFunction } from '@antv/util'; import { interaction, animation, theme, scale } from '../../adaptor/common'; import { Params } from '../../core/adaptor'; @@ -35,16 +36,18 @@ function geometry(params: Params): Params { widthRatio: radius, interval: { color, - style: liquidStyle - ? liquidStyle - : { - liquidRadius: radius, // 只能通过这样的方式,将 radius 传入到自定义 shape 中,TODO 最好是 Geometry 提供传入自定义数据的能力 - }, + style: liquidStyle, shape: 'liquid-fill-gauge', }, }, }); - interval(p); + const { ext } = interval(p); + const geometry = ext.geometry as Geometry; + + // 将 radius 传入到自定义 shape 中 + geometry.customInfo({ + radius, + }); // 关闭组件 chart.legend(false); diff --git a/src/plots/liquid/shapes/liquid.ts b/src/plots/liquid/shapes/liquid.ts index 2a68edab44..e99da9a75b 100644 --- a/src/plots/liquid/shapes/liquid.ts +++ b/src/plots/liquid/shapes/liquid.ts @@ -239,7 +239,7 @@ registerShape('interval', 'liquid-fill-gauge', { const cy = 0.5; // 需要更好的传参方式 - const radio = isNumber(cfg.style.liquidRadius) ? cfg.style.liquidRadius : 0.9; + const radio = isNumber(cfg.customInfo.radius) ? cfg.customInfo.radius : 0.9; // 获取最小 minX const minX = reduce(