Highcharts Sankey Displaying-Error
by Niggels
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: 'Luxury Car Ownership',
style: {fontSize: 20}
},
accessibility: {
point: {valueDescriptionFormat: '{index}. {point.from} to {point.to}, {point.weight}.'}
},
tooltip: {
headerFormat: null,
pointFormat:
'{point.fromNode.name} \u2192 {point.toNode.name}: {point.weight} people',
nodeFormat: '{point.name}: {point.sum} people'
},
series: [{
nodePadding: 20,
borderColor: "#1a1a1a",
borderWidth: 1,
keys: ['from', 'to', 'weight'],
nodes: [
{id: '25 - 50 years old', column: 1},
{id: 'Owns Luxury Car', column: 2},
{id: 'Does Not Own Luxury Car', column: 2},
{id: 'Luxury Car with Ferrari', column: 3},
{id: 'Luxury Car with Lamborghini', column: 3},
{id: 'Luxury Car with Porsche', column: 3},
{id: 'Luxury Car with Rolls-Royce', column: 3},
{id: 'Luxury Car with Others', column: 3},
{id: 'No Luxury Car but Interested', column: 4, offset: 100},
{id: 'No Luxury Car and Undecided', column: 4, offset: 100},
{id: 'No Luxury Car and Not Interested', column: 4, offset: 100},
{id: 'Ferrari Loyal', column: 5, offset: -150},
{id: 'Ferrari Disloyal', column: 5, offset: -150},
{id: 'Lamborghini Loyal', column: 5, offset: -150},
{id: 'Lamborghini Disloyal', column: 5, offset: -150},
{id: 'Porsche Loyal', column: 5, offset: -150},
{id: 'Porsche Disloyal', column: 5, offset: -150},
{id: 'Ferrari Disloyal to Rolls-Royce', column: 6, offset: -150},
{id: 'Ferrari Disloyal to Others', column: 6, offset: -150},
{id: 'Lamborghini Disloyal to Rolls-Royce', column: 6, offset: -150},
{id: 'Lamborghini Disloyal to Others', column: 6, offset: -150},
...