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(tree): fix tree update error with animation and without animation #18491

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
31 changes: 22 additions & 9 deletions src/chart/tree/TreeView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -603,28 +603,41 @@ function removeNodeEdge(
data: SeriesData,
group: graphic.Group,
seriesModel: TreeSeriesModel,
removeAnimationOpt: AnimationOption
removeAnimationOpt: AnimationOption,
currentSymbol?: TreeSymbol,
sourceSymbol?: TreeSymbol
) {
const virtualRoot = data.tree.root;
const { source, sourceLayout } = getSourceNode(virtualRoot, node);

const symbolEl: TreeSymbol = data.getItemGraphicEl(node.dataIndex) as TreeSymbol;
const animateModel = seriesModel.getModel('animation');

const isAnimationEnabled = animateModel.isAnimationEnabled();

// use the current symbol when the node is delete immediately
const symbolEl: TreeSymbol = data.getItemGraphicEl(node.dataIndex) as TreeSymbol ?? currentSymbol;

if (!symbolEl) {
return;
}

const sourceSymbolEl = data.getItemGraphicEl(source.dataIndex) as TreeSymbol;
const sourceEdge = sourceSymbolEl.__edge;
// use the source symbol when the node is delete immediately
const sourceSymbolEl = data.getItemGraphicEl(source.dataIndex) as TreeSymbol ?? sourceSymbol;
const sourceEdge = sourceSymbolEl?.__edge;

const edgeShape = seriesModel.get('edgeShape');
// 1. when expand the sub tree, delete the children node should delete the edge of
// the source at the same time. because the polyline edge shape is only owned by the source.
// 2.when the node is the only children of the source, delete the node should delete the edge of
// 2. when the node is the only children of the source, delete the node should delete the edge of
// the source at the same time. the same reason as above.
// 3. when the tree shape is polyline and animation is off, delete the edge of the source at the same time.
const edge = symbolEl.__edge
|| ((source.isExpand === false || source.children.length === 1) ? sourceEdge : undefined);
|| ((
source.isExpand === false || source.children.length === 1 || (
edgeShape === 'polyline' && !isAnimationEnabled
)
) ? sourceEdge : undefined);

const edgeShape = seriesModel.get('edgeShape');
const layoutOpt = seriesModel.get('layout');
const orient = seriesModel.get('orient');
const curvature = seriesModel.get(['lineStyle', 'curveness']);
Expand Down Expand Up @@ -716,10 +729,10 @@ function removeNode(

// remove edge as parent node
node.children.forEach(childNode => {
removeNodeEdge(childNode, data, group, seriesModel, removeAnimationOpt);
removeNodeEdge(childNode, data, group, seriesModel, removeAnimationOpt, undefined, symbolEl);
});
// remove edge as child node
removeNodeEdge(node, data, group, seriesModel, removeAnimationOpt);
removeNodeEdge(node, data, group, seriesModel, removeAnimationOpt, symbolEl);
}

function getEdgeShape(
Expand Down
2 changes: 2 additions & 0 deletions test/runTest/actions/__meta__.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/runTest/actions/tree-polyline-without-animation.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/runTest/actions/tree-radial-without-animation.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

134 changes: 134 additions & 0 deletions test/tree-basic-without-animation-polyline.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading