Sankey diagram

author(s): Torstein Hønsi

by djakacki

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">
        Heresies team members and academic majors and minors
    </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: 'Heresies Team Academics'
    },
    accessibility: {
        point: {
            valueDescriptionFormat: '{index}. {point.from} to {point.to}, {point.weight}.'
        }
    },
    series: [{
        keys: ['from', 'to', 'weight'],
        data: [
            ['Maya Wadhwa', 'Women and Gender Studies', 1],
            ['Maya Wadhwa', 'Art and Art History', 1],
            ['Maya Wadhwa', 'International Relations', 1],
            ['Maya Wadhwa', 'Literary Studies', 1],
            ['Sophie McQuaide', 'Art and Art History', 1],
            ['Sophie McQuaide', 'Studio Art', 1],
            ['Lucy Wadsworth', 'Art and Art History', 1],
            ['Lucy Wadsworth', 'Psychology', 1],
            ['Haley Beardsley', 'Literary Studies', 1],
            ['Haley Beardsley', 'Digital Humanities', 1],
            ['Anna Marie Wingard', 'Literary Studies', 1],
            ['Anna Marie Wingard', 'Anthropology', 1],
            ['Maggie Hunter', 'Creative Writing', 1],
            ['Maggie Smith', 'Literary Studies', 1],
            ['Bri Perea', 'Political Science', 1],
            ['Kaitlyn Segreti', 'Art and Art History', 1],
            ['Kaitlyn Segreti', 'Studio Art', 1],
            ['Ricky Rodriguez', 'Creative Writing', 1],
            ['Kaitlyn Carduff', 'Women and Gender Studies', 1],
            ['Kaitlyn Carduff', 'Political Science', 1],
            ['Zoha Nadeer', 'MIDE', 1],
            ['Zoha Nadeer', 'Art and Design', 1],
            ['Mia DeRoco', 'History', 1]
        ],
        type: 'sankey',
        name: 'Sankey demo series'
    }]

});