Blazor-ApexSankey 0.0.1

dotnet add package Blazor-ApexSankey --version 0.0.1
                    
NuGet\Install-Package Blazor-ApexSankey -Version 0.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Blazor-ApexSankey" Version="0.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Blazor-ApexSankey" Version="0.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Blazor-ApexSankey" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Blazor-ApexSankey --version 0.0.1
                    
#r "nuget: Blazor-ApexSankey, 0.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Blazor-ApexSankey@0.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Blazor-ApexSankey&version=0.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Blazor-ApexSankey&version=0.0.1
                    
Install as a Cake Tool

Blazor-ApexSankey

A Blazor component library for creating interactive Sankey diagrams using ApexSankey. Built for Blazor WebAssembly with full support for two-way data binding, customizable styling, and event handling.

Blazor-ApexSankey

Features

  • 🔗 Two-Way Binding - Automatic re-rendering when data changes
  • 🎨 Fully Customizable - Control nodes, edges, fonts, colors, and tooltips
  • Event Handling - Handle node clicks and render callbacks
  • 📱 WebAssembly - Built specifically for Blazor WebAssembly
  • 🛠️ TypeScript Definitions - Full IntelliSense support
  • 📦 Easy Integration - Simple NuGet package installation

Installation

dotnet add package Blazor-ApexSankey

Quick Start

1. Add the script reference

In your index.html, add the svg.js dependency before the Blazor script:

<script src="https://cdn.jsdelivr.net/npm/@svgdotjs/svg.js"></script>
<script src="_framework/blazor.webassembly.js"></script>

2. Add the using statement

In your _Imports.razor:

@using Blazor-ApexSankey
@using Blazor-ApexSankey.Components
@using Blazor-ApexSankey.Models

3. Use the component

@page "/my-sankey"

<ApexSankey Data="@sankeyData"
            Options="@options"
            OnNodeClick="@HandleNodeClick" />

@code {
    private SankeyData sankeyData = new()
    {
        Nodes = new List<SankeyNode>
        {
            new() { Id = "A", Title = "Source A" },
            new() { Id = "B", Title = "Source B" },
            new() { Id = "C", Title = "Target C" }
        },
        Edges = new List<SankeyEdge>
        {
            new() { Source = "A", Target = "C", Value = 10 },
            new() { Source = "B", Target = "C", Value = 20 }
        }
    };

    private SankeyOptions options = new()
    {
        Width = "800",
        Height = "600",
        NodeWidth = 20,
        FontFamily = "Arial, sans-serif"
    };

    private void HandleNodeClick(NodeClickEventArgs args)
    {
        Console.WriteLine($"Clicked node: {args.Node.Title}");
    }
}

Configuration Options

Option Type Default Description
Width string "800" Container width
Height string "800" Container height
CanvasStyle string null CSS styles for canvas
Spacing int 100 Top/left spacing
NodeWidth int 20 Width of nodes
NodeBorderWidth int 1 Node border width
NodeBorderColor string null Node border color
EdgeOpacity double 0.4 Edge opacity (0-1)
EdgeGradientFill bool true Enable gradient fill
EnableTooltip bool false Show tooltips
EnableToolbar bool false Show toolbar
TooltipTemplate string null Custom tooltip JS function
TooltipBorderColor string "#BCBCBC" Tooltip border color
TooltipBGColor string "#FFFFFF" Tooltip background
FontSize string "14px" Node label font size
FontFamily string null Font family
FontWeight string "400" Font weight
FontColor string "#000000" Label color

Data Models

SankeyNode

public class SankeyNode
{
    public string Id { get; set; }      // required
    public string Title { get; set; }   // required
    public string? Color { get; set; }  // optional
}

SankeyEdge

public class SankeyEdge
{
    public string Source { get; set; }  // required
    public string Target { get; set; }  // required
    public double Value { get; set; }   // required
    public string? Type { get; set; }   // optional
    public string? Color { get; set; }  // optional
}

Custom Ordering

You can specify custom node ordering:

var data = new SankeyData
{
    Nodes = nodes,
    Edges = edges,
    Options = new SankeyDataOptions
    {
        Order = new List<List<List<string>>>
        {
            new() { new() { "A", "B" } },
            new() { new() { "C" } }
        }
    }
};

Events

Event Type Description
OnNodeClick EventCallback<NodeClickEventArgs> Fired when a node is clicked
OnRender EventCallback Fired after chart renders

Licensing

To use with a commercial license:

// set before creating any chart instances
await ApexSankeyInterop.SetLicenseAsync(jsRuntime, "your-license-key");

Browser Support

Blazor-ApexSankey supports all modern browsers that support WebAssembly:

  • Chrome 57+
  • Firefox 52+
  • Safari 11+
  • Edge 16+

License

See LICENSE for details.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.1 73 1/11/2026