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.focusoption value:'pathId'.When
emphasis: { focus: 'pathId' }is set on the Sankey series:pathIdproperty (string, number, or array thereof) on each item in theirlinks(oredges) data. Nodes do not require apathId.pathIds from its directly connected links.pathIds of that link.pathIds.pathIdare 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: AddedgetElementsByPathIdmethods toGraphNodeandGraphEdgeto retrieve elements based on sharedpathIds found on links. ReplacedSetusage with plain objects to pass linting.src/chart/sankey/SankeySeries.ts: Added'pathId'to the allowed types foremphasis.focusand removed the old'path'.src/chart/sankey/SankeyView.ts: Integrated the call togetElementsByPathIdwhenfocusis set to'pathId', removed the old'path'condition.test/data/energy_with_paths.json: UpdatedpathIds for testing logical flows.test/sankey.html: Updated a test case to usefocus: 'pathId'and the new test data.Testing
test/sankey.htmlexample (main4) with theenergy_with_paths.jsondataset. The highlighting correctly identifies and un-blurs elements (nodes and links) sharing the relevantpathIds upon hover.npm run checktypeandnpm 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 forpathIdon link data items.