Customization in Vue Sankey Chart component
18 Nov 201824 minutes to read
The Sankey Chart provides extensive customization options to create visualizations that match your specific design requirements and data presentation needs. From styling and theming to advanced visual techniques, the component enables complete control over appearance and behavior.
This guide covers comprehensive customization techniques including styling, theming, color mapping, and visual customization strategies.
Styling Overview
The Sankey Chart supports multiple levels of styling customization:
- Global Styling: Apply consistent styles to all elements
- Element-Level Styling: Customize specific nodes, links, or labels
- Data-Driven Styling: Apply styles based on data values or conditions
- Theme-Based Styling: Use predefined themes or create custom themes
Node and Link Styling
Global Node Styling
Apply consistent styling to all nodes using the nodeStyle property:
<template>
<div class="control-pane">
<div class="control-section" id="sankey-container">
<EjsSankey
width="90%"
height="450px"
:nodeStyle="nodeStyle"
>
<ESankeyNodesCollection>
<ESankeyNode id="Agricultural Waste" />
<ESankeyNode id="Bio-conversion" />
<ESankeyNode id="Liquid Biofuel" />
<ESankeyNode id="Electricity" />
<ESankeyNode id="Heat" />
</ESankeyNodesCollection>
<ESankeyLinksCollection>
<ESankeyLink sourceId="Agricultural Waste" targetId="Bio-conversion" :value="124.729" />
<ESankeyLink sourceId="Bio-conversion" targetId="Liquid Biofuel" :value="0.597" />
<ESankeyLink sourceId="Bio-conversion" targetId="Electricity" :value="26.862" />
<ESankeyLink sourceId="Bio-conversion" targetId="Heat" :value="280.845" />
</ESankeyLinksCollection>
</EjsSankey>
</div>
</div>
</template>
<script setup>
import { ref, provide } from "vue";
import {
SankeyComponent as EjsSankey,
SankeyNodesCollectionDirective as ESankeyNodesCollection,
SankeyNodeDirective as ESankeyNode,
SankeyLinksCollectionDirective as ESankeyLinksCollection,
SankeyLinkDirective as ESankeyLink,
SankeyTooltip,
SankeyLegend,
SankeyExport
} from "@syncfusion/ej2-vue-charts";
const nodeStyle = ref({
fill: "#4472C4",
opacity: 0.8,
border: { width: 2, color: "#2E5090" }
});
provide("sankey", [SankeyTooltip, SankeyLegend, SankeyExport]);
</script>
<style>
#sankey-container {
height: 450px;
}
</style><template>
<div class="control-pane">
<div class="control-section" id="sankey-container">
<ejs-sankey
width="90%"
height="450px"
:nodeStyle="nodeStyle"
>
<e-sankey-nodes-collection>
<e-sankey-node id="Agricultural Waste" />
<e-sankey-node id="Bio-conversion" />
<e-sankey-node id="Liquid Biofuel" />
<e-sankey-node id="Electricity" />
<e-sankey-node id="Heat" />
</e-sankey-nodes-collection>
<e-sankey-links-collection>
<e-sankey-link sourceId="Agricultural Waste" targetId="Bio-conversion" :value="124.729" />
<e-sankey-link sourceId="Bio-conversion" targetId="Liquid Biofuel" :value="0.597" />
<e-sankey-link sourceId="Bio-conversion" targetId="Electricity" :value="26.862" />
<e-sankey-link sourceId="Bio-conversion" targetId="Heat" :value="280.845" />
</e-sankey-links-collection>
</ejs-sankey>
</div>
</div>
</template>
<script>
import {
SankeyComponent,
SankeyNodesCollectionDirective,
SankeyNodeDirective,
SankeyLinksCollectionDirective,
SankeyLinkDirective,
SankeyTooltip,
SankeyLegend,
SankeyExport
} from "@syncfusion/ej2-vue-charts";
export default {
name: "App",
data() {
return {
nodeStyle: {
fill: "#4472C4",
opacity: 0.8,
border: { width: 2, color: "#2E5090" }
}
};
},
components: {
"ejs-sankey": SankeyComponent,
"e-sankey-nodes-collection": SankeyNodesCollectionDirective,
"e-sankey-node": SankeyNodeDirective,
"e-sankey-links-collection": SankeyLinksCollectionDirective,
"e-sankey-link": SankeyLinkDirective
},
provide: {
sankey: [SankeyTooltip, SankeyLegend, SankeyExport]
}
};
</script>
<style>
#sankey-container {
height: 450px;
}
</style>Global Link Styling
Configure link appearance using the linkStyle property:
<template>
<div class="control-pane">
<div class="control-section" id="sankey-container">
<EjsSankey
width="90%"
height="450px"
:linkStyle="linkStyle"
>
<ESankeyNodesCollection>
<ESankeyNode id="Agricultural Waste" />
<ESankeyNode id="Biomass Residues" />
<ESankeyNode id="Bio-conversion" />
<ESankeyNode id="Liquid Biofuel" />
<ESankeyNode id="Electricity" />
<ESankeyNode id="Heat" />
</ESankeyNodesCollection>
<ESankeyLinksCollection>
<ESankeyLink sourceId="Agricultural Waste" targetId="Bio-conversion" :value="84.152" />
<ESankeyLink sourceId="Biomass Residues" targetId="Bio-conversion" :value="24.152" />
<ESankeyLink sourceId="Bio-conversion" targetId="Liquid Biofuel" :value="10.597" />
<ESankeyLink sourceId="Bio-conversion" targetId="Electricity" :value="36.862" />
<ESankeyLink sourceId="Bio-conversion" targetId="Heat" :value="60.845" />
</ESankeyLinksCollection>
</EjsSankey>
</div>
</div>
</template>
<script setup>
import { ref, provide } from "vue";
import {
SankeyComponent as EjsSankey,
SankeyNodesCollectionDirective as ESankeyNodesCollection,
SankeyNodeDirective as ESankeyNode,
SankeyLinksCollectionDirective as ESankeyLinksCollection,
SankeyLinkDirective as ESankeyLink,
SankeyTooltip,
SankeyLegend,
} from "@syncfusion/ej2-vue-charts";
const linkStyle = ref({
opacity: 0.5,
curvature: 0.4
});
provide("sankey", [SankeyTooltip, SankeyLegend]);
</script>
<style>
#sankey-container {
height: 450px;
}
</style><template>
<div class="control-pane">
<div class="control-section" id="sankey-container">
<ejs-sankey
width="90%"
height="450px"
:linkStyle="linkStyle"
>
<e-sankey-nodes-collection>
<e-sankey-node id="Agricultural Waste" />
<e-sankey-node id="Biomass Residues" />
<e-sankey-node id="Bio-conversion" />
<e-sankey-node id="Liquid Biofuel" />
<e-sankey-node id="Electricity" />
<e-sankey-node id="Heat" />
</e-sankey-nodes-collection>
<e-sankey-links-collection>
<e-sankey-link sourceId="Agricultural Waste" targetId="Bio-conversion" :value="84.152" />
<e-sankey-link sourceId="Biomass Residues" targetId="Bio-conversion" :value="24.152" />
<e-sankey-link sourceId="Bio-conversion" targetId="Liquid Biofuel" :value="10.597" />
<e-sankey-link sourceId="Bio-conversion" targetId="Electricity" :value="36.862" />
<e-sankey-link sourceId="Bio-conversion" targetId="Heat" :value="60.845" />
</e-sankey-links-collection>
</ejs-sankey>
</div>
</div>
</template>
<script>
import {
SankeyComponent,
SankeyNodesCollectionDirective,
SankeyNodeDirective,
SankeyLinksCollectionDirective,
SankeyLinkDirective,
SankeyTooltip,
SankeyLegend,
} from "@syncfusion/ej2-vue-charts";
export default {
name: "App",
data() {
return {
linkStyle: {
opacity: 0.5,
curvature: 0.4
}
};
},
components: {
"ejs-sankey": SankeyComponent,
"e-sankey-nodes-collection": SankeyNodesCollectionDirective,
"e-sankey-node": SankeyNodeDirective,
"e-sankey-links-collection": SankeyLinksCollectionDirective,
"e-sankey-link": SankeyLinkDirective
},
provide: {
sankey: [SankeyTooltip, SankeyLegend]
}
};
</script>
<style>
#sankey-container {
height: 450px;
}
</style>Individual Element Customization
Custom Node Appearance
Customize individual nodes by setting properties on each node object:
<template>
<div class="control-pane">
<div class="control-section" id="sankey-container">
<EjsSankey
width="90%"
height="450px"
>
<ESankeyNodesCollection>
<ESankeyNode id="Agricultural Waste" fill="#FF6B6B" />
<ESankeyNode id="Bio-conversion" fill="#4ECDC4" />
<ESankeyNode id="Liquid Biofuel" fill="#45B7D1" />
<ESankeyNode id="Electricity" fill="#FFA07A" />
<ESankeyNode id="Heat" fill="#98D8C8" />
</ESankeyNodesCollection>
<ESankeyLinksCollection>
<ESankeyLink sourceId="Agricultural Waste" targetId="Bio-conversion" :value="124.729" />
<ESankeyLink sourceId="Bio-conversion" targetId="Liquid Biofuel" :value="0.597" />
<ESankeyLink sourceId="Bio-conversion" targetId="Electricity" :value="26.862" />
<ESankeyLink sourceId="Bio-conversion" targetId="Heat" :value="280.845" />
</ESankeyLinksCollection>
</EjsSankey>
</div>
</div>
</template>
<script setup>
import { provide } from "vue";
import {
SankeyComponent as EjsSankey,
SankeyNodesCollectionDirective as ESankeyNodesCollection,
SankeyNodeDirective as ESankeyNode,
SankeyLinksCollectionDirective as ESankeyLinksCollection,
SankeyLinkDirective as ESankeyLink,
SankeyTooltip,
SankeyLegend,
SankeyExport
} from "@syncfusion/ej2-vue-charts";
provide("sankey", [SankeyTooltip, SankeyLegend, SankeyExport]);
</script>
<style>
#sankey-container {
height: 450px;
}
</style><template>
<div class="control-pane">
<div class="control-section" id="sankey-container">
<ejs-sankey
width="90%"
height="450px"
>
<e-sankey-nodes-collection>
<e-sankey-node id="Agricultural Waste" fill="#FF6B6B" />
<e-sankey-node id="Bio-conversion" fill="#4ECDC4" />
<e-sankey-node id="Liquid Biofuel" fill="#45B7D1" />
<e-sankey-node id="Electricity" fill="#FFA07A" />
<e-sankey-node id="Heat" fill="#98D8C8" />
</e-sankey-nodes-collection>
<e-sankey-links-collection>
<e-sankey-link sourceId="Agricultural Waste" targetId="Bio-conversion" :value="124.729" />
<e-sankey-link sourceId="Bio-conversion" targetId="Liquid Biofuel" :value="0.597" />
<e-sankey-link sourceId="Bio-conversion" targetId="Electricity" :value="26.862" />
<e-sankey-link sourceId="Bio-conversion" targetId="Heat" :value="280.845" />
</e-sankey-links-collection>
</ejs-sankey>
</div>
</div>
</template>
<script>
import {
SankeyComponent,
SankeyNodesCollectionDirective,
SankeyNodeDirective,
SankeyLinksCollectionDirective,
SankeyLinkDirective,
SankeyTooltip,
SankeyLegend,
SankeyExport
} from "@syncfusion/ej2-vue-charts";
export default {
name: "App",
components: {
"ejs-sankey": SankeyComponent,
"e-sankey-nodes-collection": SankeyNodesCollectionDirective,
"e-sankey-node": SankeyNodeDirective,
"e-sankey-links-collection": SankeyLinksCollectionDirective,
"e-sankey-link": SankeyLinkDirective
},
provide: {
sankey: [SankeyTooltip, SankeyLegend, SankeyExport]
}
};
</script>
<style>
#sankey-container {
height: 450px;
}
</style>Custom Node Labels
Customize individual node labels with specific text, styling, and positioning:
<template>
<div class="control-pane">
<div class="control-section" id="sankey-container">
<EjsSankey
width="90%"
height="450px"
:labelSettings="labelSettings"
>
<ESankeyNodesCollection>
<ESankeyNode id="Agricultural Waste" />
<ESankeyNode id="Biomass Residues" />
<ESankeyNode id="Bio-conversion" />
<ESankeyNode id="Liquid Biofuel" />
<ESankeyNode id="Electricity" />
<ESankeyNode id="Heat" />
</ESankeyNodesCollection>
<ESankeyLinksCollection>
<ESankeyLink sourceId="Agricultural Waste" targetId="Bio-conversion" :value="84.152" />
<ESankeyLink sourceId="Biomass Residues" targetId="Bio-conversion" :value="24.152" />
<ESankeyLink sourceId="Bio-conversion" targetId="Liquid Biofuel" :value="10.597" />
<ESankeyLink sourceId="Bio-conversion" targetId="Electricity" :value="36.862" />
<ESankeyLink sourceId="Bio-conversion" targetId="Heat" :value="60.845" />
</ESankeyLinksCollection>
</EjsSankey>
</div>
</div>
</template>
<script setup>
import { provide } from "vue";
import {
SankeyComponent as EjsSankey,
SankeyNodesCollectionDirective as ESankeyNodesCollection,
SankeyNodeDirective as ESankeyNode,
SankeyLinksCollectionDirective as ESankeyLinksCollection,
SankeyLinkDirective as ESankeyLink,
SankeyTooltip,
SankeyLegend,
SankeyExport
} from "@syncfusion/ej2-vue-charts";
const labelSettings = {
fontFamily: "Segoe UI",
fontWeight: "bold",
size: "14px",
color: "#1a1a1a"
};
provide("sankey", [SankeyTooltip, SankeyLegend, SankeyExport]);
</script>
<style>
#sankey-container {
height: 450px;
}
</style><template>
<div class="control-pane">
<div class="control-section" id="sankey-container">
<ejs-sankey
width="90%"
height="450px"
:labelSettings="labelSettings"
>
<e-sankey-nodes-collection>
<e-sankey-node id="Agricultural Waste" />
<e-sankey-node id="Biomass Residues" />
<e-sankey-node id="Bio-conversion" />
<e-sankey-node id="Liquid Biofuel" />
<e-sankey-node id="Electricity" />
<e-sankey-node id="Heat" />
</e-sankey-nodes-collection>
<e-sankey-links-collection>
<e-sankey-link sourceId="Agricultural Waste" targetId="Bio-conversion" :value="84.152" />
<e-sankey-link sourceId="Biomass Residues" targetId="Bio-conversion" :value="24.152" />
<e-sankey-link sourceId="Bio-conversion" targetId="Liquid Biofuel" :value="10.597" />
<e-sankey-link sourceId="Bio-conversion" targetId="Electricity" :value="36.862" />
<e-sankey-link sourceId="Bio-conversion" targetId="Heat" :value="60.845" />
</e-sankey-links-collection>
</ejs-sankey>
</div>
</div>
</template>
<script>
import {
SankeyComponent,
SankeyNodesCollectionDirective,
SankeyNodeDirective,
SankeyLinksCollectionDirective,
SankeyLinkDirective,
SankeyTooltip,
SankeyLegend,
SankeyExport
} from "@syncfusion/ej2-vue-charts";
export default {
name: "App",
data() {
return {
labelSettings: {
fontFamily: "Segoe UI",
fontWeight: "bold",
size: "14px",
color: "#1a1a1a"
}
};
},
components: {
"ejs-sankey": SankeyComponent,
"e-sankey-nodes-collection": SankeyNodesCollectionDirective,
"e-sankey-node": SankeyNodeDirective,
"e-sankey-links-collection": SankeyLinksCollectionDirective,
"e-sankey-link": SankeyLinkDirective
},
provide: {
sankey: [SankeyTooltip, SankeyLegend, SankeyExport]
}
};
</script>
<style>
#sankey-container {
height: 450px;
}
</style>Color Customization
Predefined Color Palettes
Apply predefined color palettes to automatically color nodes:
const nodes = [
{ id: 'Source1', label: { text: 'Source 1' }, color: '#3DA6D4' },
{ id: 'Source2', label: { text: 'Source 2' }, color: '#FFA500' },
{ id: 'Target', label: { text: 'Target' }, color: '#28A745' }
];Color Mapping
Map colors to specific categories or value ranges:
<template>
<div class="control-pane">
<div class="control-section" id="sankey-container">
<EjsSankey
width="90%"
height="450px"
>
<ESankeyNodesCollection>
<ESankeyNode id="Agricultural Waste" />
<ESankeyNode id="Biomass Residues" />
<ESankeyNode id="Bio-conversion" />
<ESankeyNode id="Liquid Biofuel" />
<ESankeyNode id="Electricity" />
<ESankeyNode id="Heat" />
</ESankeyNodesCollection>
<ESankeyLinksCollection>
<ESankeyLink sourceId="Agricultural Waste" targetId="Bio-conversion" :value="84.152" />
<ESankeyLink sourceId="Biomass Residues" targetId="Bio-conversion" :value="24.152" />
<ESankeyLink sourceId="Bio-conversion" targetId="Liquid Biofuel" :value="10.597" />
<ESankeyLink sourceId="Bio-conversion" targetId="Electricity" :value="36.862" />
<ESankeyLink sourceId="Bio-conversion" targetId="Heat" :value="60.845" />
</ESankeyLinksCollection>
</EjsSankey>
</div>
</div>
</template>
<script setup>
import { provide } from "vue";
import {
SankeyComponent as EjsSankey,
SankeyNodesCollectionDirective as ESankeyNodesCollection,
SankeyNodeDirective as ESankeyNode,
SankeyLinksCollectionDirective as ESankeyLinksCollection,
SankeyLinkDirective as ESankeyLink,
SankeyTooltip,
SankeyLegend,
SankeyExport
} from "@syncfusion/ej2-vue-charts";
provide("sankey", [SankeyTooltip, SankeyLegend, SankeyExport]);
</script>
<style>
#sankey-container {
height: 450px;
}
</style><template>
<div class="control-pane">
<div class="control-section" id="sankey-container">
<ejs-sankey
width="90%"
height="450px"
>
<e-sankey-nodes-collection>
<e-sankey-node id="Agricultural Waste" />
<e-sankey-node id="Biomass Residues" />
<e-sankey-node id="Bio-conversion" />
<e-sankey-node id="Liquid Biofuel" />
<e-sankey-node id="Electricity" />
<e-sankey-node id="Heat" />
</e-sankey-nodes-collection>
<e-sankey-links-collection>
<e-sankey-link
sourceId="Agricultural Waste"
targetId="Bio-conversion"
:value="84.152"
/>
<e-sankey-link
sourceId="Biomass Residues"
targetId="Bio-conversion"
:value="24.152"
/>
<e-sankey-link
sourceId="Bio-conversion"
targetId="Liquid Biofuel"
:value="10.597"
/>
<e-sankey-link
sourceId="Bio-conversion"
targetId="Electricity"
:value="36.862"
/>
<e-sankey-link
sourceId="Bio-conversion"
targetId="Heat"
:value="60.845"
/>
</e-sankey-links-collection>
</ejs-sankey>
</div>
</div>
</template>
<script>
import {
SankeyComponent,
SankeyNodesCollectionDirective,
SankeyNodeDirective,
SankeyLinksCollectionDirective,
SankeyLinkDirective,
SankeyTooltip,
SankeyLegend,
SankeyExport
} from "@syncfusion/ej2-vue-charts";
export default {
name: "App",
components: {
"ejs-sankey": SankeyComponent,
"e-sankey-nodes-collection": SankeyNodesCollectionDirective,
"e-sankey-node": SankeyNodeDirective,
"e-sankey-links-collection": SankeyLinksCollectionDirective,
"e-sankey-link": SankeyLinkDirective
},
provide: {
sankey: [SankeyTooltip, SankeyLegend, SankeyExport]
}
};
</script>
<style>
#sankey-container {
height: 450px;
}
</style>Theme Customization
Apply Theme
const theme = 'Material'; // or 'Fabric', 'Bootstrap', 'HighContrast'Custom Theme Colors
<template>
<div class="control-pane">
<div class="control-section" id="sankey-container">
<EjsSankey
width="90%"
height="450px"
:nodeStyle="nodeStyle"
:linkStyle="linkStyle"
>
<ESankeyNodesCollection>
<ESankeyNode id="Agricultural Waste" />
<ESankeyNode id="Biomass Residues" />
<ESankeyNode id="Bio-conversion" />
<ESankeyNode id="Liquid Biofuel" />
<ESankeyNode id="Electricity" />
<ESankeyNode id="Heat" />
</ESankeyNodesCollection>
<ESankeyLinksCollection>
<ESankeyLink sourceId="Agricultural Waste" targetId="Bio-conversion" :value="84.152" />
<ESankeyLink sourceId="Biomass Residues" targetId="Bio-conversion" :value="24.152" />
<ESankeyLink sourceId="Bio-conversion" targetId="Liquid Biofuel" :value="10.597" />
<ESankeyLink sourceId="Bio-conversion" targetId="Electricity" :value="36.862" />
<ESankeyLink sourceId="Bio-conversion" targetId="Heat" :value="60.845" />
</ESankeyLinksCollection>
</EjsSankey>
</div>
</div>
</template>
<script setup>
import { ref, provide } from "vue";
import {
SankeyComponent as EjsSankey,
SankeyNodesCollectionDirective as ESankeyNodesCollection,
SankeyNodeDirective as ESankeyNode,
SankeyLinksCollectionDirective as ESankeyLinksCollection,
SankeyLinkDirective as ESankeyLink,
SankeyTooltip,
SankeyLegend,
SankeyExport
} from "@syncfusion/ej2-vue-charts";
const customTheme = {
nodeFill: "#5A5A5A",
linkFill: "#B3B3B3"
};
const nodeStyle = ref({ fill: customTheme.nodeFill });
const linkStyle = ref({ fill: customTheme.linkFill });
provide("sankey", [SankeyTooltip, SankeyLegend, SankeyExport]);
</script>
<style>
#sankey-container {
height: 450px;
}
</style><template>
<div class="control-pane">
<div class="control-section" id="sankey-container">
<ejs-sankey
width="90%"
height="450px"
:nodeStyle="nodeStyle"
:linkStyle="linkStyle"
>
<e-sankey-nodes-collection>
<e-sankey-node id="Agricultural Waste" />
<e-sankey-node id="Biomass Residues" />
<e-sankey-node id="Bio-conversion" />
<e-sankey-node id="Liquid Biofuel" />
<e-sankey-node id="Electricity" />
<e-sankey-node id="Heat" />
</e-sankey-nodes-collection>
<e-sankey-links-collection>
<e-sankey-link sourceId="Agricultural Waste" targetId="Bio-conversion" :value="84.152" />
<e-sankey-link sourceId="Biomass Residues" targetId="Bio-conversion" :value="24.152" />
<e-sankey-link sourceId="Bio-conversion" targetId="Liquid Biofuel" :value="10.597" />
<e-sankey-link sourceId="Bio-conversion" targetId="Electricity" :value="36.862" />
<e-sankey-link sourceId="Bio-conversion" targetId="Heat" :value="60.845" />
</e-sankey-links-collection>
</ejs-sankey>
</div>
</div>
</template>
<script>
import {
SankeyComponent,
SankeyNodesCollectionDirective,
SankeyNodeDirective,
SankeyLinksCollectionDirective,
SankeyLinkDirective,
SankeyTooltip,
SankeyLegend,
SankeyExport
} from "@syncfusion/ej2-vue-charts";
export default {
name: "App",
data() {
const customTheme = {
nodeFill: "#5A5A5A",
linkFill: "#B3B3B3"
};
return {
nodeStyle: { fill: customTheme.nodeFill },
linkStyle: { fill: customTheme.linkFill }
};
},
components: {
"ejs-sankey": SankeyComponent,
"e-sankey-nodes-collection": SankeyNodesCollectionDirective,
"e-sankey-node": SankeyNodeDirective,
"e-sankey-links-collection": SankeyLinksCollectionDirective,
"e-sankey-link": SankeyLinkDirective
},
provide: {
sankey: [SankeyTooltip, SankeyLegend, SankeyExport]
}
};
</script>
<style>
#sankey-container {
height: 450px;
}
</style>Tooltip Customization
Template-Based Tooltips
Create custom tooltip templates for rich content:
<template>
<div class="control-pane">
<div class="control-section" id="sankey-container">
<EjsSankey
width="90%"
height="450px"
:tooltip="tooltip"
>
<ESankeyNodesCollection>
<ESankeyNode id="Agricultural Waste" />
<ESankeyNode id="Biomass Residues" />
<ESankeyNode id="Bio-conversion" />
<ESankeyNode id="Liquid Biofuel" />
<ESankeyNode id="Electricity" />
<ESankeyNode id="Heat" />
</ESankeyNodesCollection>
<ESankeyLinksCollection>
<ESankeyLink sourceId="Agricultural Waste" targetId="Bio-conversion" :value="84.152" />
<ESankeyLink sourceId="Biomass Residues" targetId="Bio-conversion" :value="24.152" />
<ESankeyLink sourceId="Bio-conversion" targetId="Liquid Biofuel" :value="10.597" />
<ESankeyLink sourceId="Bio-conversion" targetId="Electricity" :value="36.862" />
<ESankeyLink sourceId="Bio-conversion" targetId="Heat" :value="60.845" />
</ESankeyLinksCollection>
</EjsSankey>
</div>
</div>
</template>
<script setup>
import { provide } from "vue";
import {
SankeyComponent as EjsSankey,
SankeyNodesCollectionDirective as ESankeyNodesCollection,
SankeyNodeDirective as ESankeyNode,
SankeyLinksCollectionDirective as ESankeyLinksCollection,
SankeyLinkDirective as ESankeyLink,
SankeyTooltip,
SankeyLegend
} from "@syncfusion/ej2-vue-charts";
const tooltip = {
enable: true,
nodeFormat:
'<div style="padding:10px"><b>${sourceNodeName} → ${targetNodeName}</b><br/>Value: ${value}</div>'
};
provide("sankey", [SankeyTooltip, SankeyLegend]);
</script>
<style>
#sankey-container {
height: 450px;
}
</style><template>
<div class="control-pane">
<div class="control-section" id="sankey-container">
<ejs-sankey
width="90%"
height="450px"
:tooltip="tooltip"
>
<e-sankey-nodes-collection>
<e-sankey-node id="Agricultural Waste" />
<e-sankey-node id="Biomass Residues" />
<e-sankey-node id="Bio-conversion" />
<e-sankey-node id="Liquid Biofuel" />
<e-sankey-node id="Electricity" />
<e-sankey-node id="Heat" />
</e-sankey-nodes-collection>
<e-sankey-links-collection>
<e-sankey-link sourceId="Agricultural Waste" targetId="Bio-conversion" :value="84.152" />
<e-sankey-link sourceId="Biomass Residues" targetId="Bio-conversion" :value="24.152" />
<e-sankey-link sourceId="Bio-conversion" targetId="Liquid Biofuel" :value="10.597" />
<e-sankey-link sourceId="Bio-conversion" targetId="Electricity" :value="36.862" />
<e-sankey-link sourceId="Bio-conversion" targetId="Heat" :value="60.845" />
</e-sankey-links-collection>
</ejs-sankey>
</div>
</div>
</template>
<script>
import {
SankeyComponent,
SankeyNodesCollectionDirective,
SankeyNodeDirective,
SankeyLinksCollectionDirective,
SankeyLinkDirective,
SankeyTooltip,
SankeyLegend
} from "@syncfusion/ej2-vue-charts";
export default {
name: "App",
data() {
return {
tooltip: {
enable: true,
nodeFormat:
'<div style="padding:10px"><b>${sourceNodeName} → ${targetNodeName}</b><br/>Value: ${value}</div>'
}
};
},
components: {
"ejs-sankey": SankeyComponent,
"e-sankey-nodes-collection": SankeyNodesCollectionDirective,
"e-sankey-node": SankeyNodeDirective,
"e-sankey-links-collection": SankeyLinksCollectionDirective,
"e-sankey-link": SankeyLinkDirective
},
provide: {
sankey: [SankeyTooltip, SankeyLegend]
}
};
</script>
<style>
#sankey-container {
height: 450px;
}
</style>Advanced Customization Patterns
Conditional Styling Based on Data
Apply different styles based on data conditions or value ranges:
const onNodeRendering = (args) => {
const value = args.node.value || 0;
if (value > 200) {
args.node.color = '#00A651'; // High flow - green
} else if (value > 100) {
args.node.color = '#FFB81C'; // Medium flow - orange
} else {
args.node.color = '#E81B23'; // Low flow - red
}
};Category-Based Styling
Assign colors and styles based on node categories:
const categoryColors = {
'Energy': '#FF6B6B',
'Transport': '#4ECDC4',
'Industry': '#95E1D3',
'Residential': '#FFD93D'
};
const onNodeRendering = (args) => {
const category = extractCategory(args.node.id);
args.node.color = categoryColors[category] || '#999';
};Interactive Styling
Apply different styles for hover and focus states:
const onNodeEnter = (args) => {
// Highlight node on hover
args.node.highlightOpacity = 1;
};
const onNodeLeave = (args) => {
// Reset to normal state
args.node.highlightOpacity = 0.3;
};Performance Optimization
Large Dataset Customization
For charts with many nodes and links, optimize rendering performance:
-
Use Global Styles: Apply global
nodeStyleandlinkStyleinstead of individual customization - Minimize Calculations: Reduce complex calculations in rendering events
- Conditional Rendering: Only customize visible elements in viewport
- Cache Results: Cache computed styles and colors
Customization Best Practices
Key Considerations
-
Consistency
- Maintain consistent color schemes across nodes and links
- Use meaningful colors that represent data categories
- Apply visual hierarchy through size and opacity
-
Performance
- Avoid complex calculations in rendering events
- Use global styles when possible
- Optimize for large datasets
-
Accessibility
- Don’t rely solely on color for information
- Ensure sufficient contrast ratios
- Provide alternative representations
-
User Experience
- Use intuitive color mapping
- Provide clear visual feedback for interactions
- Maintain visual consistency with your application
-
Maintainability
- Document custom styling logic
- Use reusable style functions
- Separate styling from business logic
Example: Comprehensive Customization
<template>
<div class="control-pane">
<div class="control-section" id="sankey-container">
<EjsSankey
width="90%"
height="450px"
:title="title"
:margin="margin"
:nodeStyle="nodeStyle"
:linkStyle="linkStyle"
:labelSettings="labelSettings"
:tooltip="tooltip"
:legendSettings="legendSettings"
>
<ESankeyNodesCollection>
<ESankeyNode id="Agricultural Waste" fill="#FF6B6B" />
<ESankeyNode id="Biomass Residues" />
<ESankeyNode id="Bio-conversion" fill="#4ECDC4" />
<ESankeyNode id="Liquid Biofuel" fill="#45B7D1" />
<ESankeyNode id="Electricity" fill="#FFA07A" />
<ESankeyNode id="Heat" fill="#98D8C8" />
</ESankeyNodesCollection>
<ESankeyLinksCollection>
<ESankeyLink sourceId="Agricultural Waste" targetId="Bio-conversion" :value="84.152" />
<ESankeyLink sourceId="Biomass Residues" targetId="Bio-conversion" :value="24.152" />
<ESankeyLink sourceId="Bio-conversion" targetId="Liquid Biofuel" :value="10.597" />
<ESankeyLink sourceId="Bio-conversion" targetId="Electricity" :value="36.862" />
<ESankeyLink sourceId="Bio-conversion" targetId="Heat" :value="60.845" />
</ESankeyLinksCollection>
</EjsSankey>
</div>
</div>
</template>
<script setup>
import { provide, ref } from "vue";
import {
SankeyComponent as EjsSankey,
SankeyNodesCollectionDirective as ESankeyNodesCollection,
SankeyNodeDirective as ESankeyNode,
SankeyLinksCollectionDirective as ESankeyLinksCollection,
SankeyLinkDirective as ESankeyLink,
SankeyTooltip,
SankeyLegend,
SankeyExport
} from "@syncfusion/ej2-vue-charts";
const title = ref("Comprehensive Sankey Customization");
const margin = ref({ left: 40, right: 40, top: 40, bottom: 40 });
const nodeStyle = ref({ opacity: 0.85 });
const linkStyle = ref({ opacity: 0.6, curvature: 0.5 });
const labelSettings = ref({ textStyle: { fontWeight: "bold" } });
const tooltip = ref({
enable: true,
format: "<b>${sourceNodeName} → ${targetNodeName}</b><br/>Value: ${value}"
});
const legendSettings = ref({ visible: true, position: "Bottom" });
provide("sankey", [SankeyTooltip, SankeyLegend, SankeyExport]);
</script>
<style>
#sankey-container {
height: 450px;
}
</style><template>
<div class="control-pane">
<div class="control-section" id="sankey-container">
<ejs-sankey
width="90%"
height="450px"
:title="title"
:margin="margin"
:nodeStyle="nodeStyle"
:linkStyle="linkStyle"
:labelSettings="labelSettings"
:tooltip="tooltip"
:legendSettings="legendSettings"
>
<e-sankey-nodes-collection>
<e-sankey-node id="Agricultural Waste" fill="#FF6B6B" />
<e-sankey-node id="Biomass Residues" />
<e-sankey-node id="Bio-conversion" fill="#4ECDC4" />
<e-sankey-node id="Liquid Biofuel" fill="#45B7D1" />
<e-sankey-node id="Electricity" fill="#FFA07A" />
<e-sankey-node id="Heat" fill="#98D8C8" />
</e-sankey-nodes-collection>
<e-sankey-links-collection>
<e-sankey-link sourceId="Agricultural Waste" targetId="Bio-conversion" :value="84.152" />
<e-sankey-link sourceId="Biomass Residues" targetId="Bio-conversion" :value="24.152" />
<e-sankey-link sourceId="Bio-conversion" targetId="Liquid Biofuel" :value="10.597" />
<e-sankey-link sourceId="Bio-conversion" targetId="Electricity" :value="36.862" />
<e-sankey-link sourceId="Bio-conversion" targetId="Heat" :value="60.845" />
</e-sankey-links-collection>
</ejs-sankey>
</div>
</div>
</template>
<script>
import {
SankeyComponent,
SankeyNodesCollectionDirective,
SankeyNodeDirective,
SankeyLinksCollectionDirective,
SankeyLinkDirective,
SankeyTooltip,
SankeyLegend,
SankeyExport
} from "@syncfusion/ej2-vue-charts";
export default {
name: "App",
data() {
return {
title: "Comprehensive Sankey Customization",
margin: { left: 40, right: 40, top: 40, bottom: 40 },
nodeStyle: { opacity: 0.85 },
linkStyle: { opacity: 0.6, curvature: 0.5 },
labelSettings: { textStyle: { fontWeight: "bold" } },
tooltip: {
enable: true,
format: "<b>${sourceNodeName} → ${targetNodeName}</b><br/>Value: ${value}"
},
legendSettings: { visible: true, position: "Bottom" }
};
},
components: {
"ejs-sankey": SankeyComponent,
"e-sankey-nodes-collection": SankeyNodesCollectionDirective,
"e-sankey-node": SankeyNodeDirective,
"e-sankey-links-collection": SankeyLinksCollectionDirective,
"e-sankey-link": SankeyLinkDirective
},
provide: {
sankey: [SankeyTooltip, SankeyLegend, SankeyExport]
}
};
</script>
<style>
#sankey-container {
height: 450px;
}
</style>