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

[v5]点击 Legend 过滤后,再点击恢复时,漏斗图取nextPoints错误 #4877

Closed
shield2018 opened this issue Apr 7, 2023 · 2 comments · Fixed by #4960
Closed

[v5]点击 Legend 过滤后,再点击恢复时,漏斗图取nextPoints错误 #4877

shield2018 opened this issue Apr 7, 2023 · 2 comments · Fixed by #4960
Assignees
Labels

Comments

@shield2018
Copy link
Contributor

代码位置:

G2/src/runtime/plot.ts

Lines 1192 to 1221 in f2a53a9

function createMarkShapeFunction(
mark: G2Mark,
state: G2MarkState,
view: G2ViewDescriptor,
library: G2Library,
): (
data: Record<string, any>,
index: number,
element?: DisplayObject,
) => DisplayObject {
const [useShape] = useLibrary<G2ShapeOptions, ShapeComponent, Shape>(
'shape',
library,
);
const { data: abstractData } = mark;
const { defaultShape, data } = state;
const point2d = data.map((d) => d.points);
const { theme, coordinate } = view;
const { type: markType, style = {} } = mark;
return (data, index) => {
const { shape: styleShape = defaultShape } = style;
const { shape = styleShape, points, seriesIndex, index: i, ...v } = data;
const value = { ...v, shape, mark: markType, defaultShape, index };
// Get data-driven style.
// If it is a series shape, such as area and line,
// provides the series of abstract data and indices
// for this shape, otherwise the single datum and
// index.
const abstractDatum = seriesIndex

1214行
const value = { ...v, shape, mark: markType, defaultShape, index };

value的index被设置为外层index。恢复过滤时,index为0。

出现以下问题:
funnel 漏斗图,计算四边形位置时,会使用index获取nextpoint,如下:

export const Funnel: SC<FunnelOptions> = (options) => {
const { adjustPoints = getFunnelPoints, ...style } = options;
return (points, value, coordinate, theme, point2d, ...args) => {
const { index } = value;
const nextPoints = point2d[index + 1];
const funnelPoints = adjustPoints(points, nextPoints, coordinate);
return Color({ colorAttribute: 'fill', ...style })(
funnelPoints,
value,
coordinate,
theme,
point2d,

const { index } = value;
const nextPoints = point2d[index + 1];

导致取到的下一个点坐标错误

@shield2018
Copy link
Contributor Author

关注一下

@pearmini
Copy link
Member

pearmini commented May 4, 2023

这两天就解决

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants