Events in Vue Sankey Chart component
18 Nov 201824 minutes to read
The Sankey Chart provides comprehensive events that allow you to customize behavior, respond to user interactions, and hook into the chart life cycle. These events enable advanced customization scenarios including data transformation, analytics tracking, and dynamic UI updates.
This guide covers life cycle events, rendering events, interaction events, and export/print events.
Event List
| Event | Description |
|---|---|
| load | Triggers before the Sankey loads. Allows customization before rendering. |
| loaded | Triggers after the Sankey is fully loaded and rendered. |
| legendItemRendering | Triggers before a legend item is rendered. Allows customization of legend items. |
| labelRendering | Triggers before a label is rendered. Allows customization of label text and style. |
| nodeRendering | Triggers before a node is rendered. Allows customization of node appearance. |
| linkRendering | Triggers before a link is rendered. Allows customization of link appearance. |
| tooltipRendering | Triggers before a tooltip is rendered. Allows customization of tooltip content. |
| nodeClick | Triggers when a node is clicked. |
| nodeEnter | Triggers when the mouse enters a node area. |
| nodeLeave | Triggers when the mouse leaves a node area. |
| linkClick | Triggers when a link is clicked. |
| linkEnter | Triggers when the mouse enters a link area. |
| linkLeave | Triggers when the mouse leaves a link area. |
| sizeChanged | Triggers when the chart size changes. |
| beforeExport | Triggers before the export process starts. |
| afterExport | Triggers after the export process completes. |
| exportCompleted | Triggers when export is completed. |
| beforePrint | Triggers before the print process starts. |
Lifecycle Events
Load Event
The load event triggers before the Sankey Chart begins rendering. Use this event to customize configuration, apply themes, or prepare data before the chart loads:
<template>
<div class="control-pane">
<div class="control-section" id="sankey-container">
<EjsSankey
width="90%"
height="450px"
:load="onLoad"
>
<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 { 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";
function onLoad(args) {
console.log("Sankey chart is loading...", args);
}
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"
:load="onLoad"
>
<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",
methods: {
onLoad(args) {
console.log("Sankey chart is loading...", args);
}
},
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>Loaded Event
The loaded event triggers after the Sankey Chart is completely rendered and ready for interaction. Use this event to initialize calculations, perform analytics, or trigger dependent components:
<template>
<div class="control-pane">
<div class="control-section">
<EjsSankey
id="sankey-container"
width="90%"
height="450px"
:loaded="onLoaded"
>
<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";
function onLoaded(args) {
console.log("Sankey chart has loaded successfully", args);
}
provide("sankey", [SankeyTooltip, SankeyLegend]);
</script>
<style>
#sankey-container {
height: 450px;
}
</style><template>
<div class="control-pane">
<div class="control-section">
<ejs-sankey
id="sankey-container"
width="90%"
height="450px"
:loaded="onLoaded"
>
<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",
methods: {
onLoaded(args) {
console.log("Sankey chart has loaded successfully", args);
}
},
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>Interaction Events
Node Interaction Events
Handle node click and hover events to respond to user actions and provide interactive feedback:
<template>
<div class="control-pane">
<div class="control-section">
<EjsSankey
id="sankey-container"
width="90%"
height="450px"
:nodeClick="onNodeMouseClick"
:nodeEnter="onNodeMouseEnter"
>
<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";
function onNodeMouseClick(args) {
console.log("Node clicked:", args.node);
}
function onNodeMouseEnter(args) {
console.log("Node hovered:", args.node);
}
provide("sankey", [SankeyTooltip, SankeyLegend]);
</script>
<style>
#sankey-container {
height: 450px;
}
</style><template>
<div class="control-pane">
<div class="control-section">
<ejs-sankey
id="sankey-container"
width="90%"
height="450px"
:nodeMouseClick="onNodeMouseClick"
:nodeMouseEnter="onNodeMouseEnter"
>
<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",
methods: {
onNodeClick(args) {
console.log("Node clicked:", args.node);
},
onNodeEnter(args) {
console.log("Node hovered:", args.node);
}
},
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>Link Interaction Events
Handle link click and hover events:
<template>
<div class="control-pane">
<div class="control-section">
<EjsSankey
id="sankey-container"
width="90%"
height="450px"
:linkClick="onLinkMouseClick"
:linkEnter="onLinkMouseEnter"
>
<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";
function onLinkMouseClick(args) {
console.log("Link clicked:", args.link);
}
function onLinkMouseEnter(args) {
console.log("Link hovered:", args.link);
}
provide("sankey", [SankeyTooltip, SankeyLegend]);
</script>
<style>
#sankey-container {
height: 450px;
}
</style><template>
<div class="control-pane">
<div class="control-section">
<ejs-sankey
id="sankey-container"
width="90%"
height="450px"
:linkClick="onLinkMouseClick"
:linkEnter="onLinkMouseEnter"
>
<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",
methods: {
onLinkMouseClick(args) {
console.log("Link clicked:", args.link);
},
onLinkMouseEnter(args) {
console.log("Link hovered:", args.link);
}
},
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>Rendering Events
Use rendering events to customize elements dynamically based on data values, conditions, or business logic. This is the most powerful approach for data-driven styling.
Node Rendering Event
The nodeRendering event triggers before each node is rendered, allowing dynamic node customization:
<template>
<div class="control-pane">
<div class="control-section" id="sankey-container">
<EjsSankey
width="90%"
height="450px"
:nodeRendering="onNodeRendering"
>
<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";
// Event handler: customize node appearance
function onNodeRendering(args) {
if (args.node.id === 'Agricultural Waste') {
args.node.color = '#FF6B6B'
} else if (args.node.id === 'Bio-conversion') {
args.node.color = '#4ECDC4'
}
}
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"
:nodeRendering="onNodeRendering"
>
<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",
methods: {
onNodeRendering(args) {
if (args.node.id === 'Agricultural Waste') {
args.node.color = '#FF6B6B'
} else if (args.node.id === 'Bio-conversion') {
args.node.color = '#4ECDC4'
}
}
},
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>Link Rendering Event
The linkRendering event triggers before each link is rendered, allowing dynamic link customization:
<template>
<div class="control-pane">
<div class="control-section" id="sankey-container">
<EjsSankey
width="90%"
height="450px"
:linkRendering="onLinkRendering"
>
<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";
// Event: set link style based on value threshold
function onLinkRendering(args) {
if (args?.link?.value > 50) {
args.fill = "#FF6B6B" ;
} else {
args.fill = "#70AD47" ;
}
}
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"
:linkRendering="onLinkRendering"
>
<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",
methods: {
onLinkRendering(args) {
// Customize link appearance during rendering
if (args?.link?.value > 50) {
args.fill = "#FF6B6B" ;
} else {
args.fill = "#70AD47" ;
}
}
},
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>Label Rendering Event
The labelRendering event triggers before each label is rendered, allowing dynamic label customization:
<template>
<div class="control-pane">
<div class="control-section" id="sankey-container">
<EjsSankey
width="90%"
height="450px"
:labelRendering="onLabelRendering"
>
<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 { 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";
function onLabelRendering(args) {
args.labelStyle = {
fontFamily: "Arial",
fontStyle: "normal",
fontWeight: "bold",
fontSize: "12px",
color: "#000"
};
}
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"
:labelRendering="onLabelRendering"
>
<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",
methods: {
onLabelRendering(args) {
args.labelStyle = {
fontFamily: "Arial",
fontStyle: "normal",
fontWeight: "bold",
fontSize: "12px",
color: "#000"
};
}
},
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>Legend Item Rendering Event
The legendItemRendering event triggers before a legend item is rendered, allowing custom legend item styling:
<template>
<div class="control-pane">
<div class="control-section" id="sankey-container">
<EjsSankey
width="90%"
height="450px"
:legendSettings="legendSettings"
:legendItemRendering="onLegendItemRendering"
>
<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 { provide, reactive } 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 legendSettings = reactive({
visible: true,
position: 'Bottom'
});
function onLegendItemRendering(args) {
if (args && args.text) {
args.text = String(args.text).toUpperCase();
}
args.fill= '#333'
}
provide('sankey', [SankeyTooltip, SankeyLegend, SankeyExport]);
</script>
<style>
#sankey-container {
height: 450px;
}
</style><template>
<div id="app" class="control-pane">
<div class="control-section" id="sankey-container">
<ejs-sankey
width="90%"
height="450px"
:legendSettings="legendSettings"
:legendItemRendering="onLegendItemRendering"
>
<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',
components: {
'ejs-sankey': SankeyComponent,
'e-sankey-nodes-collection': SankeyNodesCollectionDirective,
'e-sankey-node': SankeyNodeDirective,
'e-sankey-links-collection': SankeyLinksCollectionDirective,
'e-sankey-link': SankeyLinkDirective
},
data() {
return {
legendSettings: {
visible: true,
position: 'Bottom'
}
};
},
methods: {
onLegendItemRendering(args) {
if (args && args.text) {
args.text = String(args.text).toUpperCase();
}
args.fill= '#333'
}
},
provide: {
sankey: [SankeyTooltip, SankeyLegend, SankeyExport]
}
};
</script>
<style>
#sankey-container {
height: 450px;
}
</style>Size Changed Event
Respond when the chart size changes (e.g., window resize):
<template>
<div class="control-pane">
<div class="control-section">
<EjsSankey
id="sankey-container"
width="90%"
height="450px"
:sizeChanged="onSizeChanged"
>
<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";
function onSizeChanged(args) {
console.log("Chart size changed:", { width: args.currentSize.width, height: args.currentSize.height });
}
provide("sankey", [SankeyTooltip, SankeyLegend]);
</script>
<style>
#sankey-container {
height: 450px;
}
</style><template>
<div class="control-pane">
<div class="control-section">
<ejs-sankey
id="sankey-container"
width="90%"
height="450px"
:sizeChanged="onSizeChanged"
>
<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",
methods: {
onSizeChanged(args) {
console.log("Chart size changed:", { width: args.currentSize.width, height: args.currentSize.height });
}
},
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>Complete Event Handler Example
Combine multiple events for comprehensive handling:
<template>
<div class="control-pane">
<div class="control-section">
<EjsSankey
id="sankey-container"
width="90%"
height="450px"
:loaded="onLoadComplete"
>
<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";
// Post-render hook (mirrors React's loaded)
function onLoadComplete(args) {
console.log("Sankey chart rendering complete", args);
const el = document.getElementById("sankey-container");
if (el) el.setAttribute("title", "Sankey Chart Ready");
}
provide("sankey", [SankeyTooltip, SankeyLegend]);
</script>
<style>
#sankey-container {
height: 450px;
}
</style><template>
<div class="control-pane">
<div class="control-section">
<ejs-sankey
id="sankey-container"
width="90%"
height="450px"
:loaded="onLoadComplete"
>
<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",
methods: {
onLoadComplete(args) {
console.log("Sankey chart rendering complete", args);
const el = document.getElementById("sankey-container");
if (el) el.setAttribute("title", "Sankey Chart Ready");
}
},
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>