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,
  },
  title: {
    text: ".",
    style: { color: "rgba(255, 255, 255, 0)", fontSize: "1px" },
    floating: true,
    margin: 0,
  },
  tooltip: {
    enabled: true,
    borderWidth: 1,
    borderRadius: 1,
    backgroundColor: "#ffffff",
    style: {
      color: "#000000",
      fontSize: "1rem",
      fontFamily: "Open Sans",
      fontWeight: "normal",
      fontStyle: "normal",
      textDecoration: "none",
    },
    useHTML: true,
  },
  plotOptions: {
    series: {
      animation: null,
      cursor: "pointer",
      allowPointSelect: true,
      showInLegend: false,
      turboThreshold: 0,
      stickyTracking: false,
      events: {},
      point: { events: {} },
      borderRadius: 0,
    },
  },
  legend: {
    enabled: false,
    item: {},
    borderWidth: 0,
    layout: "horizontal",
    eQLegendPlacement: "CHART",
    backgroundColor: "rgba(255,255,255,0)",
    itemHoverStyle: {
      color: "#000000",
      fontSize: "1rem",
      fontFamily: "Open Sans",
      fontWeight: "normal",
      fontStyle: "normal",
      textDecoration: "none",
    },
    itemStyle: {
      color: "#000000",
      fontSize: "1rem",
      fontFamily: "Open Sans",
      fontWeight: "normal",
      fontStyle: "normal",
      textDecoration: "none",
    },
    align: "center",
    verticalAlign: "bottom",
    margin: 0,
    padding: 5,
    itemHiddenStyle: { color: "rgb(204, 204, 204)", textDecoration: "none" },
    events: {},
  },
  credits: { enabled: false },
  exporting: { enabled: false },
  lang: { noData: "" },
  series: [
    {
      showInLegend: true,
      name: "bonus",
      legendColor: "rgba(0,41,170,1)",
      borderWidth: 0,
      nodeWidth: 20,
      curveFactor: 0.33,
...