Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Currently, highlighting related elements in Sankey charts is limited to adjacency (
focus: 'adjacency'
) or full upstream/downstream paths (focus: 'trajectory'
). There is no built-in way to highlight specific logical paths or flows defined directly within the user's data.Solution
This PR introduces a new
emphasis.focus
option value:'pathId'
.When
emphasis: { focus: 'pathId' }
is set on the Sankey series:pathId
property (string, number, or array thereof) on each item in theirlinks
(oredges
) data. Nodes do not require apathId
.pathId
s from its directly connected links.pathId
s of that link.pathId
s.pathId
are highlighted by remaining un-blurred ("highlight by contrast").This allows users to define and visually highlight arbitrary logical flows within their Sankey diagram based on data annotation.
Changes
src/data/Graph.ts
: AddedgetElementsByPathId
methods toGraphNode
andGraphEdge
to retrieve elements based on sharedpathId
s found on links. ReplacedSet
usage with plain objects to pass linting.src/chart/sankey/SankeySeries.ts
: Added'pathId'
to the allowed types foremphasis.focus
and removed the old'path'
.src/chart/sankey/SankeyView.ts
: Integrated the call togetElementsByPathId
whenfocus
is set to'pathId'
, removed the old'path'
condition.test/data/energy_with_paths.json
: UpdatedpathId
s for testing logical flows.test/sankey.html
: Updated a test case to usefocus: 'pathId'
and the new test data.Testing
test/sankey.html
example (main4
) with theenergy_with_paths.json
dataset. The highlighting correctly identifies and un-blurs elements (nodes and links) sharing the relevantpathId
s upon hover.npm run checktype
andnpm run lint
.npm run release
.Documentation Note
The official ECharts documentation will need to be updated to include the new



emphasis.focus: 'pathId'
option for Sankey charts, explaining its behavior and the requirement forpathId
on link data items.