Sankey diagram
author(s): Torstein Hønsi
by amrutaJgtp
HTML
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/sankey.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<script src="https://code.highcharts.com/modules/accessibility.js"></script>
<figure class="highcharts-figure">
<div id="container"></div>
</figure>
CSS
#csv {
display: none;
}
.highcharts-figure, .highcharts-data-table table {
min-width: 310px;
max-width: 800px;
margin: 1em auto;
}
.highcharts-data-table table {
font-family: Verdana, sans-serif;
border-collapse: collapse;
border: 1px solid #EBEBEB;
margin: 10px auto;
text-align: center;
width: 100%;
max-width: 500px;
}
.highcharts-data-table caption {
padding: 1em 0;
font-size: 1.2em;
color: #555;
}
.highcharts-data-table th {
font-weight: 600;
padding: 0.5em;
}
.highcharts-data-table td, .highcharts-data-table th, .highcharts-data-table caption {
padding: 0.5em;
}
.highcharts-data-table thead tr, .highcharts-data-table tr:nth-child(even) {
background: #f8f8f8;
}
.highcharts-data-table tr:hover {
background: #f1f7ff;
}
JavaScript
Highcharts.chart("container", {
chart: {
inverted: false,
backgroundColor: "rgba(255,255,255,0)",
plotBackgroundColor: "rgba(255,255,255,0)",
zoomType: "xy",
resetZoomButton: { theme: { style: { visibility: "hidden" } } },
spacingBottom: 5,
spacingTop: 10,
},
plotOptions: {
series: {
animation: { duration: 700 },
cursor: "pointer",
allowPointSelect: true,
showInLegend: false,
turboThreshold: 0,
stickyTracking: false,
events: {},
point: { events: {} },
borderRadius: 0,
},
},
series: [
{
showInLegend: true,
name: "bonus",
legendColor: "rgba(0,41,170,1)",
borderWidth: 0,
nodeWidth: 20,
curveFactor: 0.33,
linkOpacity: 0.5,
dataLabels: {
enabled: true,
borderWidth: 0,
style: {
fontSize: "1rem",
fontFamily: "Open Sans",
fontWeight: "normal",
fontStyle: "normal",
textDecoration: "none",
},
align: "center",
verticalAlign: "middle",
inside: true,
rotation: 0,
overflow: "justify",
crop: false,
allowOverlap: true,
className: "chartwidget-sankey-nodelabels",
},
nodePadding: 10,
nodeTooltipBackgroundColor: "#ffffff",
linkTooltipBackgroundColor: "#ffffff",
nodes: [
{
id: 1,
name: "Business Analyst",
destinationItemKey: "11",
color: "rgba(0,41,170,1)",
},
{
id: 2,
name: "Documentation",
destinationItemKey: "9",
color: "rgba(65,146,217,1)",
},
{
id: 3,
name: "Finance",
destinationItemKey: "7",
color: "rgba(242,174,48,1)",
},
{
id: 4,
name: "HR_ADMIN",
destinationItemKey: "6",
color: "rgba(242,92,5,1)",
},
{
id:...