Title and Subtitle in Vue Sankey Chart component
18 Nov 201824 minutes to read
The Sankey Chart supports adding descriptive titles and subtitles to provide context and information about your data visualization. These text elements help users quickly understand the purpose and content of the diagram. You can fully customize the text, styling, alignment, and appearance using dedicated properties.
This guide covers title and subtitle configuration, styling options, and best practices for effective diagram labeling.
Title and Subtitle Properties
| Property | Type | Description |
|---|---|---|
| title | string | The main title text displayed at the top of the chart. |
| subTitle | string | The subtitle text displayed below the main title. |
| titleStyle | object | Styling options for the title text. |
| subTitleStyle | object | Styling options for the subtitle text. |
Title/Subtitle Style Properties
Both titleStyle and subTitleStyle support the following properties:
| Property | Type | Default | Description |
|---|---|---|---|
| size | string | null | Font size for the text. |
| fontWeight | string | null | Font weight (e.g., ‘400’, ‘700’). |
| fontFamily | string | null | Font family name. |
| color | string | null | Text color. |
| fontStyle | string | ‘normal’ | Font style (‘normal’ or ‘italic’). |
| opacity | number | 1 | Text opacity (0 to 1). |
| textAlignment | string | ‘Center’ | Text alignment (‘Left’, ‘Center’, ‘Right’). |
Basic Title and Subtitle
Add a main title and descriptive subtitle to your Sankey Chart to provide context about the data visualization:
<template>
<div class="control-pane">
<div class="control-section" id="sankey-container">
<EjsSankey
width="90%"
height="450px"
title="Energy Flow Diagram"
subTitle="Agricultural Energy Conversion"
>
<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"
title="Energy Flow Diagram"
subTitle="Agricultural Energy Conversion"
>
<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>Customized Title and Subtitle Styling
Apply custom styling to both the title and subtitle including font properties, colors, alignment, and opacity to match your design requirements:
<template>
<div class="control-pane">
<div class="control-section" id="sankey-container">
<EjsSankey
width="90%"
height="450px"
:title="title"
:subTitle="subtitle"
:titleStyle="titleStyle"
:subTitleStyle="subtitleStyle"
>
<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 title = ref("Energy Flow Diagram");
const subtitle = ref("Agricultural Energy Conversion");
const titleStyle = ref({
fontFamily: "Arial",
fontStyle: "italic",
fontWeight: "bold",
size: "18px",
color: "#1F77B4"
});
const subtitleStyle = ref({
fontFamily: "Arial",
fontStyle: "normal",
fontWeight: "normal",
size: "14px",
color: "#FF7F0E"
});
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"
:subTitle="subTitle"
:titleStyle="titleStyle"
:subTitleStyle="subTitleStyle"
>
<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 {
title: "Energy Flow Diagram",
subTitle: "Agricultural Energy Conversion",
titleStyle: {
fontFamily: "Arial",
fontStyle: "italic",
fontWeight: "bold",
size: "18px",
color: "#1F77B4"
},
subTitleStyle: {
fontFamily: "Arial",
fontStyle: "normal",
fontWeight: "normal",
size: "14px",
color: "#FF7F0E"
}
};
},
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>Title Only (Without Subtitle)
Add only a title to the Sankey Chart when a subtitle is not needed. This provides a clean, minimal header for your visualization:
<template>
<div class="control-pane">
<div class="control-section" id="sankey-container">
<EjsSankey
width="90%"
height="450px"
:title="title"
>
<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 title = ref("Energy Flow Diagram");
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"
>
<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 {
title: "Energy Flow Diagram"
};
},
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>Title with Different Alignments
Control the alignment of title and subtitle text:
<template>
<div class="control-pane">
<div class="control-section">
<EjsSankey
id="sankey-container"
width="90%"
height="450px"
:title="title"
:subTitle="subtitle"
:titleStyle="titleStyle"
:subTitleStyle="subtitleStyle"
>
<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 title = ref("Energy Flow Diagram");
const subtitle = ref("Agricultural Energy Conversion");
const titleStyle = ref({ textAlignment: "Near" });
const subtitleStyle = ref({ textAlignment: "Center" });
provide("sankey", [SankeyTooltip, SankeyLegend, SankeyExport]);
</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"
:title="title"
:subTitle="subtitle"
:titleStyle="titleStyle"
:subTitleStyle="subtitleStyle"
>
<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 {
title: "Energy Flow Diagram",
subtitle: "Agricultural Energy Conversion",
titleStyle: { textAlignment: "Near" },
subtitleStyle: { textAlignment: "Center" }
};
},
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>Title Best Practices
- Descriptive: Use clear, descriptive titles that explain what the chart shows
- Concise: Keep titles brief and to the point
- Hierarchy: Make the title larger and bolder than the subtitle for visual hierarchy
- Readability: Ensure sufficient contrast between text color and background
- Font Choice: Use readable fonts like Segoe UI, Arial, or Verdana