Appearance in ASP.NET MVC Sankey Chart component
The Sankey Chart provides comprehensive customization options to control visual appearance, dimensions, responsiveness, colors, borders, and themes. These appearance settings enable you to create diagrams that match your application’s design system and user experience requirements.
This guide covers dimension configuration, responsive sizing, backgrounds, borders, margins, and theme selection.
Dimensions
Control the size of the Sankey Chart using the Width and Height properties. You can specify dimensions in pixels (px) or percentages (%) to create fixed or responsive layouts.
Width and Height Properties
| Property | Type | Default | Description |
|---|---|---|---|
| width | string | null | Width of the chart as a CSS value (e.g., ‘700px’ or ‘100%’). |
| height | string | null | Height of the chart as a CSS value (e.g., ‘420px’ or ‘100%’). |
@Html.EJS().Sankey("sankey-container")
.Width("800px")
.Height("600px")
.Margin(m => m.Left(40).Right(40).Top(40).Bottom(40))
.Tooltip(tooltip => tooltip.Enable(true))
.LegendSettings(legend => legend.Visible(true))
.Nodes(ViewBag.SankeyNodes)
.Links(ViewBag.SankeyLinks)
.Render()public ActionResult Index()
{
List<SankeyNode> nodes = new List<SankeyNode>
{
new SankeyNode { Id = "Agricultural Waste" },
new SankeyNode { Id = "Biomass Residues" },
new SankeyNode { Id = "Bio-conversion" },
new SankeyNode { Id = "Liquid Biofuel" },
new SankeyNode { Id = "Electricity" },
new SankeyNode { Id = "Heat" }
};
List<SankeyLink> links = new List<SankeyLink>
{
new SankeyLink { SourceId = "Agricultural Waste", TargetId = "Bio-conversion", Value = 84.152 },
new SankeyLink { SourceId = "Biomass Residues", TargetId = "Bio-conversion", Value = 24.152 },
new SankeyLink { SourceId = "Bio-conversion", TargetId = "Liquid Biofuel", Value = 10.597 },
new SankeyLink { SourceId = "Bio-conversion", TargetId = "Electricity", Value = 36.862 },
new SankeyLink { SourceId = "Bio-conversion", TargetId = "Heat", Value = 60.845 }
};
ViewBag.SankeyNodes = nodes;
ViewBag.SankeyLinks = links;
return View();
}Responsive Sizing
Use percentage-based dimensions for responsive layouts that adapt to container sizes. This is recommended for applications that need to work across different device sizes and screen orientations:
@Html.EJS().Sankey("sankey-container")
.Width("90%")
.Tooltip(t => t.Enable(true))
.LegendSettings(l => l.Visible(true))
.Load("onSankeyLoad")
.Nodes(ViewBag.SankeyNodes)
.Links(ViewBag.SankeyLinks)
.Render()
<script>
function onSankeyLoad(args) {
var isDevice = ej.base.Browser.isDevice;
args.chart.height = isDevice ? '600px' : '450px';
args.chart.margin = {
left: isDevice ? 10 : 40,
right: isDevice ? 10 : 40,
top: 20,
bottom: 20
};
}
</script>public ActionResult Index()
{
List<SankeyNode> nodes = new List<SankeyNode>
{
new SankeyNode { Id = "Agricultural Waste" },
new SankeyNode { Id = "Biomass Residues" },
new SankeyNode { Id = "Bio-conversion" },
new SankeyNode { Id = "Liquid Biofuel" },
new SankeyNode { Id = "Electricity" },
new SankeyNode { Id = "Heat" }
};
List<SankeyLink> links = new List<SankeyLink>
{
new SankeyLink { SourceId = "Agricultural Waste", TargetId = "Bio-conversion", Value = 84.152 },
new SankeyLink { SourceId = "Biomass Residues", TargetId = "Bio-conversion", Value = 24.152 },
new SankeyLink { SourceId = "Bio-conversion", TargetId = "Liquid Biofuel", Value = 10.597 },
new SankeyLink { SourceId = "Bio-conversion", TargetId = "Electricity", Value = 36.862 },
new SankeyLink { SourceId = "Bio-conversion", TargetId = "Heat", Value = 60.845 }
};
ViewBag.SankeyNodes = nodes;
ViewBag.SankeyLinks = links;
return View();
}Background Customization
Customize the background of the Sankey Chart with solid colors or background images to match your application’s theme or create specific visual effects.
Background Properties
| Property | Type | Default | Description |
|---|---|---|---|
| background | string | null | Background color of the chart (CSS color value). |
| backgroundImage | string | null | Background image URL. |
@Html.EJS().Sankey("sankey-container")
.Width("90%")
.Height("450px")
.Background("#f0f0f0")
.Tooltip(tooltip => tooltip.Enable(true))
.LegendSettings(legend => legend.Visible(true))
.Nodes(ViewBag.SankeyNodes)
.Links(ViewBag.SankeyLinks)
.Render()public ActionResult Index()
{
List<SankeyNode> nodes = new List<SankeyNode>
{
new SankeyNode { Id = "Agricultural Waste" },
new SankeyNode { Id = "Biomass Residues" },
new SankeyNode { Id = "Bio-conversion" },
new SankeyNode { Id = "Liquid Biofuel" },
new SankeyNode { Id = "Electricity" },
new SankeyNode { Id = "Heat" }
};
List<SankeyLink> links = new List<SankeyLink>
{
new SankeyLink { SourceId = "Agricultural Waste", TargetId = "Bio-conversion", Value = 84.152 },
new SankeyLink { SourceId = "Biomass Residues", TargetId = "Bio-conversion", Value = 24.152 },
new SankeyLink { SourceId = "Bio-conversion", TargetId = "Liquid Biofuel", Value = 10.597 },
new SankeyLink { SourceId = "Bio-conversion", TargetId = "Electricity", Value = 36.862 },
new SankeyLink { SourceId = "Bio-conversion", TargetId = "Heat", Value = 60.845 }
};
ViewBag.SankeyNodes = nodes;
ViewBag.SankeyLinks = links;
return View();
}Border Customization
Customize the border of the Sankey Chart container.
Border Properties
| Property | Type | Default | Description |
|---|---|---|---|
| border.color | string | ’’ | Border color. Accepts values in hex or RGBA as valid CSS color strings. |
| border.width | number | 1 | Border width in pixels. |
| border.dashArray | string | ’’ | Sets the length of dashes in the stroke of border. |
@Html.EJS().Sankey("sankey-container")
.Width("90%")
.Height("450px")
.Border(br => br.Color("#333").Width(2))
.Tooltip(tooltip => tooltip.Enable(true))
.LegendSettings(legend => legend.Visible(true))
.Nodes(ViewBag.SankeyNodes)
.Links(ViewBag.SankeyLinks)
.Render()public ActionResult Index()
{
List<SankeyNode> nodes = new List<SankeyNode>
{
new SankeyNode { Id = "Agricultural Waste" },
new SankeyNode { Id = "Biomass Residues" },
new SankeyNode { Id = "Bio-conversion" },
new SankeyNode { Id = "Liquid Biofuel" },
new SankeyNode { Id = "Electricity" },
new SankeyNode { Id = "Heat" }
};
List<SankeyLink> links = new List<SankeyLink>
{
new SankeyLink { SourceId = "Agricultural Waste", TargetId = "Bio-conversion", Value = 84.152 },
new SankeyLink { SourceId = "Biomass Residues", TargetId = "Bio-conversion", Value = 24.152 },
new SankeyLink { SourceId = "Bio-conversion", TargetId = "Liquid Biofuel", Value = 10.597 },
new SankeyLink { SourceId = "Bio-conversion", TargetId = "Electricity", Value = 36.862 },
new SankeyLink { SourceId = "Bio-conversion", TargetId = "Heat", Value = 60.845 }
};
ViewBag.SankeyNodes = nodes;
ViewBag.SankeyLinks = links;
return View();
}Margin Customization
Control the spacing around the chart content using margins.
Margin Properties
| Property | Type | Default | Description |
|---|---|---|---|
| margin.left | number | 10 | Left margin in pixels. |
| margin.right | number | 10 | Right margin in pixels. |
| margin.top | number | 10 | Top margin in pixels. |
| margin.bottom | number | 10 | Bottom margin in pixels. |
@Html.EJS().Sankey("sankey-container")
.Width("90%")
.Height("450px")
.Margin(m => m.Left(50).Right(50).Top(50).Bottom(50))
.Tooltip(t => t.Enable(true))
.LegendSettings(l => l.Visible(true))
.Nodes(ViewBag.SankeyNodes)
.Links(ViewBag.SankeyLinks)
.Render()public ActionResult Index()
{
List<SankeyNode> nodes = new List<SankeyNode>
{
new SankeyNode { Id = "Agricultural Waste" },
new SankeyNode { Id = "Biomass Residues" },
new SankeyNode { Id = "Bio-conversion" },
new SankeyNode { Id = "Liquid Biofuel" },
new SankeyNode { Id = "Electricity" },
new SankeyNode { Id = "Heat" }
};
List<SankeyLink> links = new List<SankeyLink>
{
new SankeyLink { SourceId = "Agricultural Waste", TargetId = "Bio-conversion", Value = 84.152 },
new SankeyLink { SourceId = "Biomass Residues", TargetId = "Bio-conversion", Value = 24.152 },
new SankeyLink { SourceId = "Bio-conversion", TargetId = "Liquid Biofuel", Value = 10.597 },
new SankeyLink { SourceId = "Bio-conversion", TargetId = "Electricity", Value = 36.862 },
new SankeyLink { SourceId = "Bio-conversion", TargetId = "Heat", Value = 60.845 }
};
ViewBag.SankeyNodes = nodes;
ViewBag.SankeyLinks = links;
return View();
}Theme
The Sankey Chart provides multiple built-in themes to customize the visual appearance. Apply a theme using the Theme property.
Theme Configuration
@Html.EJS().Sankey("sankey-container")
.Width("90%")
.Height("450px")
.Tooltip(t => t.Enable(true))
.LegendSettings(l => l.Visible(true))
.Load("onSankeyLoad")
.Nodes(ViewBag.SankeyNodes)
.Links(ViewBag.SankeyLinks)
.Render()
<script>
function onSankeyLoad(args) {
args.chart.theme = 'Tailwind';
}
</script>public ActionResult Index()
{
List<SankeyNode> nodes = new List<SankeyNode>
{
new SankeyNode { Id = "Agricultural Waste" },
new SankeyNode { Id = "Biomass Residues" },
new SankeyNode { Id = "Bio-conversion" },
new SankeyNode { Id = "Liquid Biofuel" },
new SankeyNode { Id = "Electricity" },
new SankeyNode { Id = "Heat" }
};
List<SankeyLink> links = new List<SankeyLink>
{
new SankeyLink { SourceId = "Agricultural Waste", TargetId = "Bio-conversion", Value = 84.152 },
new SankeyLink { SourceId = "Biomass Residues", TargetId = "Bio-conversion", Value = 24.152 },
new SankeyLink { SourceId = "Bio-conversion", TargetId = "Liquid Biofuel", Value = 10.597 },
new SankeyLink { SourceId = "Bio-conversion", TargetId = "Electricity", Value = 36.862 },
new SankeyLink { SourceId = "Bio-conversion", TargetId = "Heat", Value = 60.845 }
};
ViewBag.SankeyNodes = nodes;
ViewBag.SankeyLinks = links;
return View();
}