Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(liquid): 升级 G2,使用正确的方式向自定义 shape 传参 #1584

Merged
merged 1 commit into from
Sep 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
15 changes: 9 additions & 6 deletions src/plots/liquid/adaptor.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -35,16 +36,18 @@ function geometry(params: Params<LiquidOptions>): Params<LiquidOptions> {
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);
Expand Down
2 changes: 1 addition & 1 deletion src/plots/liquid/shapes/liquid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down