Skip to content

SankeyChart: Add multiple convenience features#12064

Merged
danielchalmers merged 10 commits intoMudBlazor:devfrom
91378246:feature/add-sankey-chart-convenience-features
Nov 7, 2025
Merged

SankeyChart: Add multiple convenience features#12064
danielchalmers merged 10 commits intoMudBlazor:devfrom
91378246:feature/add-sankey-chart-convenience-features

Conversation

@91378246
Copy link
Contributor

@91378246 91378246 commented Nov 6, 2025

This PR enhances the Sankey chart by adding multiple convenience features as well as fixing 2 small optical issues:

  • NodeChartOptions.EdgeLabelSymbol allows for setting a custom edge label symbol to be displayed in the edge labels
  • NodeChartOptions.LabelPadding allows for setting a custom ChartTooltip padding, which may be required for very large Sankey charts
  • NodeChartOptions.HideNodesSmallerThan automatically hides nodes below a certain threshold (again for large charts)
  • NodeChartOptions.HideNodesWithNoEdges automatically hides nodes with no connections
  • NodeChartOptions.OrderNodesByValue orders the nodes in each column by their corresponding value descending
  • Changed ChartTooltip.PaddingSize to a parameter
  • Edge label position calculation resulted in a wrong y in certain cases
  • Always show node labels on hover (same behaviour as edges)
  • Expanded and enhanced the docs section with a data generator:
image

@mudbot mudbot bot added breaking change This change will require consumer code updates docs Updates/improvements to project documentation that do not affect core library logic enhancement Adds a new feature or enhances existing functionality (not fixing a defect) in the main library labels Nov 6, 2025
@91378246
Copy link
Contributor Author

91378246 commented Nov 6, 2025

Note that there should be no breaking changes (idk why the breaking change label was added)

@danielchalmers
Copy link
Member

Note that there should be no breaking changes (idk why the breaking change label was added)

If you're curious, this was its thought process:

  • Labeling: Primary focus is clearly on functionality, so it's an enhancement. The change to ChartTooltip.PaddingSize is a breaking change, so breaking change is required.

It takes it purely from the body/comments but doesn't take into account the actual code changes

@danielchalmers danielchalmers removed docs Updates/improvements to project documentation that do not affect core library logic breaking change This change will require consumer code updates labels Nov 6, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the Sankey chart component to add configurability and improve functionality. It introduces new filtering options, customizable padding for tooltips and labels, and fixes several calculation issues.

Key changes:

  • Added configurable padding for chart tooltips and node labels via PaddingSize and LabelPadding properties
  • Implemented filtering options (HideNodesSmallerThan, HideNodesWithNoEdges, OrderNodesByValue)
  • Fixed edge path calculations and center positioning
  • Added constructor overload for SankeyChartNode to accept color parameter

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
ChartTooltip.razor.cs Converted hardcoded padding constant to configurable parameter PaddingSize
ChartTooltip.razor Updated HTML comments for clarity
SankeyChartNode.cs Added constructor overload accepting color parameter
NodeChartOptions.cs Added new configuration properties for label padding, node filtering, edge symbols, and ordering
Sankey.razor.cs Refactored drawing logic to support filtering, fixed edge path calculations and center positioning
Sankey.razor Added support for configurable label padding, fixed glow filter naming
SankeyChartTests.cs Updated test expectations to match new edge path calculations
SankeyExample2.razor Complete rewrite with dynamic data generation and interactive configuration controls
SankeyExample1.razor Simplified to basic usage example

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mudbot mudbot bot changed the title Sankey chart: Add multiple convenience features SankeyChart: Add multiple convenience features Nov 7, 2025
Copy link
Contributor

@Anu6is Anu6is left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@91378246 Fix failing code quality check (extra white spaces)

@danielchalmers
Copy link
Member

Thank you again!

@danielchalmers danielchalmers merged commit e7b651b into MudBlazor:dev Nov 7, 2025
5 of 6 checks passed
@91378246 91378246 deleted the feature/add-sankey-chart-convenience-features branch November 7, 2025 15:55
@Anu6is
Copy link
Contributor

Anu6is commented Nov 20, 2025

@91378246 quick question on this. You added a number of option and I'm wondering about

  • HideNodesSmallerThan
  • HideNodesWithNoEdges

Are both of these required? If a node has no edges, then it should automatically be 0 right? Wouldn't hiding nodes smaller than 1 exclude nodes with no edges without the additional option? Is the HideNodesWithNoEdges just for additional convenience or am I missing something?

@91378246
Copy link
Contributor Author

@Anu6is If you use a Sankey chart in health sciences you often have hundreds of nodes. I added HideNodesSmallerThan to have a kind of zoom-function. Consequently I then added HideNodesWithNoEdges to allow to automatically hide nodes which would have been displayed as they are larger than HideNodesSmallerThan but only where connected to nodes smaller than HideNodesSmallerThan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Adds a new feature or enhances existing functionality (not fixing a defect) in the main library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants