Skip to content

Commit 84b9578

Browse files
authored
Merge pull request #17009 from susiwen8/tree-relative
feat(tree): `tree` focus supports `relative`
2 parents 6d45e2a + a44c7f5 commit 84b9578

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

src/chart/tree/TreeSeries.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export interface TreeSeriesStateOption<TCbParams = never> {
5555

5656
interface TreeStatesMixin {
5757
emphasis?: {
58-
focus?: DefaultEmphasisFocus | 'ancestor' | 'descendant'
58+
focus?: DefaultEmphasisFocus | 'ancestor' | 'descendant' | 'relative'
5959
scale?: boolean
6060
}
6161
}

src/chart/tree/TreeView.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -485,9 +485,11 @@ function updateNode(
485485

486486
// Handle status
487487
const focus = itemModel.get(['emphasis', 'focus']);
488-
const focusDataIndices: number[] = focus === 'ancestor'
489-
? node.getAncestorsIndices()
490-
: focus === 'descendant' ? node.getDescendantIndices() : null;
488+
const focusDataIndices: number[] = focus === 'relative'
489+
? zrUtil.concatArray(node.getAncestorsIndices(), node.getDescendantIndices()) as number[]
490+
: focus === 'ancestor'
491+
? node.getAncestorsIndices()
492+
: focus === 'descendant' ? node.getDescendantIndices() : null;
491493

492494
if (focusDataIndices) {
493495
// Modify the focus to data indices.

test/tree-legend.html

+3-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)