Sankey diagram
author(s): Torstein Hønsi
by anikettiwari
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>
<p class="highcharts-description">
Sankey charts are used to visualize data flow and volume
between nodes. The wider lines indicate larger volumes.
</p>
</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', {
title: {
text: 'Highcharts Sankey Diagram'
},
accessibility: {
point: {
valueDescriptionFormat: '{index}. {point.from} to {point.to}, {point.weight}.'
}
},
series: [{
keys: ['color','from', 'to', 'weight'],
colors: ["#880000", "#AFAFAF", "#008800", "#008800", "#AFAFAF"],
data: [
{color: "#BB0000", from: "Apple", to: "Challenged", weight: 34},
{color: "#BB0000", from: "Challenged", to: "Instituted", weight: 10},
{color: "#BB0000", from: "Challenged", to: "Instituted denied", weight: 34},
{color: "#BB0000", from: "Challenged", to: "Terminated Before Institution", weight: 1},
{color: "#BB0000", from: "Challenged", to: "Others", weight: 1},
{color: "#BB0000", from: "Instituted", to: "All Unpattentable", weight: 15},
{color: "#BB0000", from: "Instituted", to: "Mixed Result", weight: 15},
{color: "#BB0000", from: "Instituted", to: "Patentable", weight: 15},
{color: "#00BB00", from: "Google", to: "Challenged", weight: 24},
{color: "#00BB00", from: "Challenged", to: "Instituted", weight: 15},
{color: "#00BB00", from: "Challenged", to: "Instituted denied", weight: 20},
{color: "#00BB00", from: "Challenged", to: "Terminated Before Institution", weight: 1},
{color: "#00BB00", from: "Challenged", to: "Others", weight: 1},
{color: "#00BB00", from: "Instituted", to: "All Unpattentable", weight: 15},
{color: "#00BB00", from: "Instituted", to: "Mixed Result", weight: 15},
{color: "#00BB00", from: "Instituted", to: "Patentable", weight: 15},
{color: "#0000BB", from: "Alphabet", to: "Challenged", weight: 24},
{color: "#0000BB", from: "Challenged", to: "Instituted", weight: 15},
{color: "#0000BB", from: "Challenged", to: "Instituted denied", weight: 20},
{color: "#0000BB", from: "Challenged", to: "Terminated Before Institution", weight: 1},
{color: "#0000BB", from: "Challenged", to: "Others", weight: 1},
{color: "#0000BB", from: "Instituted", to:...