Links in React Sankey Chart component
18 Nov 201824 minutes to read
Links are the connecting paths that visualize flow between nodes in a Sankey Chart. Each link connects a source node to a target node and carries a quantitative value that determines its visual thickness. The Sankey Chart provides comprehensive customization options for link styling, colors, curvature, and interactions.
This guide covers link customization including appearance properties, color blending, curvature control, and dynamic rendering events.
Link Style Properties
The linkStyle property allows you to customize the visual appearance of all links in the Sankey Chart. These properties control opacity, highlighting behavior, curvature, and color blending.
Link Style Configuration Properties
| Property | Type | Default | Description |
|---|---|---|---|
| opacity | number | 0.35 | Opacity of the link (0 to 1). |
| highlightOpacity | number | 1 | Opacity of link when highlighted or hovered. |
| inactiveOpacity | number | 0.3 | Opacity of link when not interacting (when other links are hovered). |
| curvature | number | 0.55 | Curvature factor of the link path (0 = straight line, 1 = fully curved). |
| colorType | string | ‘Blend’ | Color blending type: ‘Source’, ‘Target’, or ‘Blend’. |
Basic Link Customization
Customize the appearance of all links using the linkStyle property to set global opacity levels, curvature, and color blending behavior:
import * as React from "react";
import * as ReactDOM from "react-dom";
import { SankeyComponent, SankeyNodeDirective, SankeyNodesCollectionDirective, SankeyLinkDirective, SankeyLinksCollectionDirective, Inject, SankeyTooltip, SankeyLegend, SankeyExport } from '@syncfusion/ej2-react-charts';
function App() {
const linkStyle = {
opacity: 0.7,
curvature: 0.5,
colorType: 'Source'
};
return (
<div className="control-pane">
<div className="control-section" id="sankey-container">
<SankeyComponent
width="90%"
height="450px"
linkStyle={linkStyle}
>
<SankeyNodesCollectionDirective>
<SankeyNodeDirective id='Agricultural Waste' />
<SankeyNodeDirective id='Bio-conversion' />
<SankeyNodeDirective id='Liquid Biofuel' />
<SankeyNodeDirective id='Electricity' />
<SankeyNodeDirective id='Heat' />
</SankeyNodesCollectionDirective>
<SankeyLinksCollectionDirective>
<SankeyLinkDirective sourceId='Agricultural Waste' targetId='Bio-conversion' value={124.729} />
<SankeyLinkDirective sourceId='Bio-conversion' targetId='Liquid Biofuel' value={0.597} />
<SankeyLinkDirective sourceId='Bio-conversion' targetId='Electricity' value={26.862} />
<SankeyLinkDirective sourceId='Bio-conversion' targetId='Heat' value={280.845} />
</SankeyLinksCollectionDirective>
<Inject services={[SankeyTooltip, SankeyLegend, SankeyExport]} />
</SankeyComponent>
</div>
</div>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('sankey'));import * as React from "react";
import * as ReactDOM from "react-dom";
import {
SankeyComponent,
Inject,
SankeyTooltip,
SankeyLegend,
SankeyNodeDirective,
SankeyNodesCollectionDirective,
SankeyLinkDirective,
SankeyLinksCollectionDirective
} from '@syncfusion/ej2-react-charts';
function App() {
const linkStyle = {
opacity: 0.7,
curvature: 0.5,
colorType: 'Source'
};
return (
<div className="control-pane">
<div className="control-section">
<SankeyComponent
id="sankey-container"
width="90%"
height="450px"
linkStyle={linkStyle}
>
<SankeyNodesCollectionDirective>
<SankeyNodeDirective id="Agricultural Waste" />
<SankeyNodeDirective id="Biomass Residues" />
<SankeyNodeDirective id="Bio-conversion" />
<SankeyNodeDirective id="Liquid Biofuel" />
<SankeyNodeDirective id="Electricity" />
<SankeyNodeDirective id="Heat" />
</SankeyNodesCollectionDirective>
<SankeyLinksCollectionDirective>
<SankeyLinkDirective sourceId="Agricultural Waste" targetId="Bio-conversion" value={84.152} />
<SankeyLinkDirective sourceId="Biomass Residues" targetId="Bio-conversion" value={24.152} />
<SankeyLinkDirective sourceId="Bio-conversion" targetId="Liquid Biofuel" value={10.597} />
<SankeyLinkDirective sourceId="Bio-conversion" targetId="Electricity" value={36.862} />
<SankeyLinkDirective sourceId="Bio-conversion" targetId="Heat" value={60.845} />
</SankeyLinksCollectionDirective>
<Inject services={[SankeyTooltip, SankeyLegend]} />
</SankeyComponent>
</div>
</div>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('sankey'));Link Curvature
The curvature property controls the bend of the links, affecting the visual flow representation:
- Value 0: Creates straight lines between nodes
- Value 0.5-0.7: Creates moderate curves (often preferred for readability)
- Value 1.0: Creates maximum curvature with smooth paths
Choose curvature values based on your data density and aesthetic preferences:
import * as React from "react";
import * as ReactDOM from "react-dom";
import {
SankeyComponent,
Inject,
SankeyTooltip,
SankeyLegend,
SankeyNodeDirective,
SankeyNodesCollectionDirective,
SankeyLinkDirective,
SankeyLinksCollectionDirective
} from '@syncfusion/ej2-react-charts';
function App() {
return (
<div className="control-pane">
<div className="control-section">
<SankeyComponent
id="sankey-container"
width="90%"
height="450px"
linkStyle={{ curvature: 0.5 }}
>
<SankeyNodesCollectionDirective>
<SankeyNodeDirective id="Agricultural Waste" />
<SankeyNodeDirective id="Biomass Residues" />
<SankeyNodeDirective id="Bio-conversion" />
<SankeyNodeDirective id="Liquid Biofuel" />
<SankeyNodeDirective id="Electricity" />
<SankeyNodeDirective id="Heat" />
</SankeyNodesCollectionDirective>
<SankeyLinksCollectionDirective>
<SankeyLinkDirective sourceId="Agricultural Waste" targetId="Bio-conversion" value={84.152} />
<SankeyLinkDirective sourceId="Biomass Residues" targetId="Bio-conversion" value={24.152} />
<SankeyLinkDirective sourceId="Bio-conversion" targetId="Liquid Biofuel" value={10.597} />
<SankeyLinkDirective sourceId="Bio-conversion" targetId="Electricity" value={36.862} />
<SankeyLinkDirective sourceId="Bio-conversion" targetId="Heat" value={60.845} />
</SankeyLinksCollectionDirective>
<Inject services={[SankeyTooltip, SankeyLegend]} />
</SankeyComponent>
</div>
</div>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('sankey'));import * as React from "react";
import * as ReactDOM from "react-dom";
import {
SankeyComponent,
Inject,
SankeyTooltip,
SankeyLegend,
SankeyNodeDirective,
SankeyNodesCollectionDirective,
SankeyLinkDirective,
SankeyLinksCollectionDirective
} from '@syncfusion/ej2-react-charts';
function App() {
return (
<div className="control-pane">
<div className="control-section">
<SankeyComponent
id="sankey-container"
width="90%"
height="450px"
linkStyle={{ curvature: 0.5 }}
>
<SankeyNodesCollectionDirective>
<SankeyNodeDirective id="Agricultural Waste" />
<SankeyNodeDirective id="Biomass Residues" />
<SankeyNodeDirective id="Bio-conversion" />
<SankeyNodeDirective id="Liquid Biofuel" />
<SankeyNodeDirective id="Electricity" />
<SankeyNodeDirective id="Heat" />
</SankeyNodesCollectionDirective>
<SankeyLinksCollectionDirective>
<SankeyLinkDirective sourceId="Agricultural Waste" targetId="Bio-conversion" value={84.152} />
<SankeyLinkDirective sourceId="Biomass Residues" targetId="Bio-conversion" value={24.152} />
<SankeyLinkDirective sourceId="Bio-conversion" targetId="Liquid Biofuel" value={10.597} />
<SankeyLinkDirective sourceId="Bio-conversion" targetId="Electricity" value={36.862} />
<SankeyLinkDirective sourceId="Bio-conversion" targetId="Heat" value={60.845} />
</SankeyLinksCollectionDirective>
<Inject services={[SankeyTooltip, SankeyLegend]} />
</SankeyComponent>
</div>
</div>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('sankey'));Link Color Type
The colorType property determines how links are colored, providing flexibility in visual representation:
- ‘Source’: Links inherit the color of their source node (useful for tracking origin)
- ‘Target’: Links inherit the color of their target node (useful for tracking destination)
- ‘Blend’: Links display a smooth gradient blend of source and target node colors (default - recommended for most cases)
The color type you choose affects how users perceive flow relationships in the diagram:
import * as React from "react";
import * as ReactDOM from "react-dom";
import {
SankeyComponent,
Inject,
SankeyTooltip,
SankeyLegend,
SankeyNodeDirective,
SankeyNodesCollectionDirective,
SankeyLinkDirective,
SankeyLinksCollectionDirective
} from '@syncfusion/ej2-react-charts';
function App() {
return (
<div className="control-pane">
<div className="control-section">
<SankeyComponent
id="sankey-container"
width="90%"
height="450px"
linkStyle={{ colorType: 'Blend' }}
>
<SankeyNodesCollectionDirective>
<SankeyNodeDirective id="Agricultural Waste" />
<SankeyNodeDirective id="Biomass Residues" />
<SankeyNodeDirective id="Bio-conversion" />
<SankeyNodeDirective id="Liquid Biofuel" />
<SankeyNodeDirective id="Electricity" />
<SankeyNodeDirective id="Heat" />
</SankeyNodesCollectionDirective>
<SankeyLinksCollectionDirective>
<SankeyLinkDirective sourceId="Agricultural Waste" targetId="Bio-conversion" value={84.152} />
<SankeyLinkDirective sourceId="Biomass Residues" targetId="Bio-conversion" value={24.152} />
<SankeyLinkDirective sourceId="Bio-conversion" targetId="Liquid Biofuel" value={10.597} />
<SankeyLinkDirective sourceId="Bio-conversion" targetId="Electricity" value={36.862} />
<SankeyLinkDirective sourceId="Bio-conversion" targetId="Heat" value={60.845} />
</SankeyLinksCollectionDirective>
<Inject services={[SankeyTooltip, SankeyLegend]} />
</SankeyComponent>
</div>
</div>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('sankey'));import * as React from "react";
import * as ReactDOM from "react-dom";
import {
SankeyComponent,
Inject,
SankeyTooltip,
SankeyLegend,
SankeyNodeDirective,
SankeyNodesCollectionDirective,
SankeyLinkDirective,
SankeyLinksCollectionDirective
} from '@syncfusion/ej2-react-charts';
function App() {
return (
<div className="control-pane">
<div className="control-section">
<SankeyComponent
id="sankey-container"
width="90%"
height="450px"
linkStyle={{ colorType: 'Blend' }}
>
<SankeyNodesCollectionDirective>
<SankeyNodeDirective id="Agricultural Waste" />
<SankeyNodeDirective id="Biomass Residues" />
<SankeyNodeDirective id="Bio-conversion" />
<SankeyNodeDirective id="Liquid Biofuel" />
<SankeyNodeDirective id="Electricity" />
<SankeyNodeDirective id="Heat" />
</SankeyNodesCollectionDirective>
<SankeyLinksCollectionDirective>
<SankeyLinkDirective sourceId="Agricultural Waste" targetId="Bio-conversion" value={84.152} />
<SankeyLinkDirective sourceId="Biomass Residues" targetId="Bio-conversion" value={24.152} />
<SankeyLinkDirective sourceId="Bio-conversion" targetId="Liquid Biofuel" value={10.597} />
<SankeyLinkDirective sourceId="Bio-conversion" targetId="Electricity" value={36.862} />
<SankeyLinkDirective sourceId="Bio-conversion" targetId="Heat" value={60.845} />
</SankeyLinksCollectionDirective>
<Inject services={[SankeyTooltip, SankeyLegend]} />
</SankeyComponent>
</div>
</div>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('sankey'));Link Value and Thickness
The link thickness is determined by the value property in the link data. This quantitative value is automatically mapped to the visual thickness of the link:
- Larger values: Create thicker links (proportional to the value)
- Smaller values: Create thinner links
- Equal values: Create links of equal thickness
The thickness visualization makes it easy to understand relative flow quantities at a glance:
import * as React from "react";
import * as ReactDOM from "react-dom";
import {
SankeyComponent,
Inject,
SankeyTooltip,
SankeyLegend,
SankeyNodeDirective,
SankeyNodesCollectionDirective,
SankeyLinkDirective,
SankeyLinksCollectionDirective
} from '@syncfusion/ej2-react-charts';
function App() {
return (
<div className="control-pane">
<div className="control-section">
<SankeyComponent
id="sankey-container"
width="90%"
height="450px"
>
<SankeyNodesCollectionDirective>
<SankeyNodeDirective id="Agricultural Waste" />
<SankeyNodeDirective id="Biomass Residues" />
<SankeyNodeDirective id="Bio-conversion" />
<SankeyNodeDirective id="Liquid Biofuel" />
<SankeyNodeDirective id="Electricity" />
<SankeyNodeDirective id="Heat" />
</SankeyNodesCollectionDirective>
<SankeyLinksCollectionDirective>
<SankeyLinkDirective sourceId="Agricultural Waste" targetId="Bio-conversion" value={84.152} />
<SankeyLinkDirective sourceId="Biomass Residues" targetId="Bio-conversion" value={24.152} />
<SankeyLinkDirective sourceId="Bio-conversion" targetId="Liquid Biofuel" value={10.597} />
<SankeyLinkDirective sourceId="Bio-conversion" targetId="Electricity" value={36.862} />
<SankeyLinkDirective sourceId="Bio-conversion" targetId="Heat" value={60.845} />
</SankeyLinksCollectionDirective>
<Inject services={[SankeyTooltip, SankeyLegend]} />
</SankeyComponent>
</div>
</div>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('sankey'));import * as React from "react";
import * as ReactDOM from "react-dom";
import {
SankeyComponent,
Inject,
SankeyTooltip,
SankeyLegend,
SankeyNodeDirective,
SankeyNodesCollectionDirective,
SankeyLinkDirective,
SankeyLinksCollectionDirective
} from '@syncfusion/ej2-react-charts';
function App() {
return (
<div className="control-pane">
<div className="control-section">
<SankeyComponent
id="sankey-container"
width="90%"
height="450px"
>
<SankeyNodesCollectionDirective>
<SankeyNodeDirective id="Agricultural Waste" />
<SankeyNodeDirective id="Biomass Residues" />
<SankeyNodeDirective id="Bio-conversion" />
<SankeyNodeDirective id="Liquid Biofuel" />
<SankeyNodeDirective id="Electricity" />
<SankeyNodeDirective id="Heat" />
</SankeyNodesCollectionDirective>
<SankeyLinksCollectionDirective>
<SankeyLinkDirective sourceId="Agricultural Waste" targetId="Bio-conversion" value={84.152} />
<SankeyLinkDirective sourceId="Biomass Residues" targetId="Bio-conversion" value={24.152} />
<SankeyLinkDirective sourceId="Bio-conversion" targetId="Liquid Biofuel" value={10.597} />
<SankeyLinkDirective sourceId="Bio-conversion" targetId="Electricity" value={36.862} />
<SankeyLinkDirective sourceId="Bio-conversion" targetId="Heat" value={60.845} />
</SankeyLinksCollectionDirective>
<Inject services={[SankeyTooltip, SankeyLegend]} />
</SankeyComponent>
</div>
</div>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('sankey'));Advanced Link Configuration
Dynamic Link Customization
Use the linkRendering event to customize link appearance dynamically during the render process. This event is triggered for each link before rendering, allowing you to apply conditional styling based on flow values, source-target combinations, or other data attributes:
import * as React from "react";
import * as ReactDOM from "react-dom";
import {
SankeyComponent,
Inject,
SankeyTooltip,
SankeyLegend,
SankeyNodeDirective,
SankeyNodesCollectionDirective,
SankeyLinkDirective,
SankeyLinksCollectionDirective
} from '@syncfusion/ej2-react-charts';
function App() {
const linkRendering = (args) => {
if (args.link.sourceId === 'Bio-conversion' && args.link.targetId === 'Heat') {
args.link.stroke = '#FF6B6B';
args.link.strokeWidth = 3;
args.link.opacity = 1;
} else {
args.link.opacity = 0.6;
}
};
return (
<div className="control-pane">
<div className="control-section">
<SankeyComponent
id="sankey-container"
width="90%"
height="450px"
linkRendering={linkRendering}
>
<SankeyNodesCollectionDirective>
<SankeyNodeDirective id="Agricultural Waste" />
<SankeyNodeDirective id="Biomass Residues" />
<SankeyNodeDirective id="Bio-conversion" />
<SankeyNodeDirective id="Liquid Biofuel" />
<SankeyNodeDirective id="Electricity" />
<SankeyNodeDirective id="Heat" />
</SankeyNodesCollectionDirective>
<SankeyLinksCollectionDirective>
<SankeyLinkDirective sourceId="Agricultural Waste" targetId="Bio-conversion" value={84.152} />
<SankeyLinkDirective sourceId="Biomass Residues" targetId="Bio-conversion" value={24.152} />
<SankeyLinkDirective sourceId="Bio-conversion" targetId="Liquid Biofuel" value={10.597} />
<SankeyLinkDirective sourceId="Bio-conversion" targetId="Electricity" value={36.862} />
<SankeyLinkDirective sourceId="Bio-conversion" targetId="Heat" value={60.845} />
</SankeyLinksCollectionDirective>
<Inject services={[SankeyTooltip, SankeyLegend]} />
</SankeyComponent>
</div>
</div>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('sankey'));import * as React from "react";
import * as ReactDOM from "react-dom";
import {
SankeyComponent,
Inject,
SankeyTooltip,
SankeyLegend,
SankeyNodeDirective,
SankeyNodesCollectionDirective,
SankeyLinkDirective,
SankeyLinksCollectionDirective
} from '@syncfusion/ej2-react-charts';
import { SankeyNodeModel, SankeyLinkModel, SankeyLinkRenderEventArgs } from '@syncfusion/ej2-react-charts';
function App() {
const linkRendering = (args: SankeyLinkRenderEventArgs) => {
if (args.link.sourceId === 'Bio-conversion' && args.link.targetId === 'Heat') {
args.fill = '#FF6B6B';
} else {
args.fill = '#599dbd';
}
};
return (
<div className="control-pane">
<div className="control-section">
<SankeyComponent
id="sankey-container"
width="90%"
height="450px"
linkRendering={linkRendering}
>
<SankeyNodesCollectionDirective>
<SankeyNodeDirective id="Agricultural Waste" />
<SankeyNodeDirective id="Biomass Residues" />
<SankeyNodeDirective id="Bio-conversion" />
<SankeyNodeDirective id="Liquid Biofuel" />
<SankeyNodeDirective id="Electricity" />
<SankeyNodeDirective id="Heat" />
</SankeyNodesCollectionDirective>
<SankeyLinksCollectionDirective>
<SankeyLinkDirective sourceId="Agricultural Waste" targetId="Bio-conversion" value={84.152} />
<SankeyLinkDirective sourceId="Biomass Residues" targetId="Bio-conversion" value={24.152} />
<SankeyLinkDirective sourceId="Bio-conversion" targetId="Liquid Biofuel" value={10.597} />
<SankeyLinkDirective sourceId="Bio-conversion" targetId="Electricity" value={36.862} />
<SankeyLinkDirective sourceId="Bio-conversion" targetId="Heat" value={60.845} />
</SankeyLinksCollectionDirective>
<Inject services={[SankeyTooltip, SankeyLegend]} />
</SankeyComponent>
</div>
</div>
);
}
export default App;
ReactDOM.render(<App />, document.getElementById('sankey'));