Creating A Sankey Diagram Using JavaScript
Creating A Sankey Diagram Using JavaScript
JavaScript
Using AmCharts
HMTL
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>Sankey Diagram</title>
</head>
<body>
<p>
Author: Pranav Thakkar
</br>
<a href="mailto:[email protected]?Subject=Hello%20ForSankeyDiagram"
target="_top">[email protected]</a>
</br>
<a href="mailto:[email protected]?Subject=Hello%20ForSankeyDiagram"
target="_top">[email protected]</a>
</p>
<script src="https://www.amcharts.com/lib/4/core.js"></script>
<script src="https://www.amcharts.com/lib/4/charts.js"></script>
<script src="https://www.amcharts.com/lib/4/themes/animated.js"></script>
<div id="chartdiv"></div>
<script src="./script.js"></script>
</body>
</html>
JAVASCRIPT
//Author: Pranav Thakkar
//[email protected]
//[email protected]
/**
* ---------------------------------------
* This demo was created using amCharts 4.
*
* For more information visit:
* https://www.amcharts.com/
*
* Documentation is available at:
* https://www.amcharts.com/docs/v4/
* ---------------------------------------
*/
// Themes begin
am4core.useTheme(am4themes_animated);
// Themes end
chart.data = [
{ from: "Boiler 9", to: "750#", value: 10 },
{ from: "Boiler 10", to: "750#", value: 8 },
{ from: "Boiler 11", to: "G", value: 4 },
{ from: "1B505", to: "750#", value: 4 },
{ from: "1B506", to: "750#", value: 50 },
{ from: "C", to: "750#", value: 3 },
{ from: "D", to: "G", value: 5 },
{ from: "D", to: "I", value: 2 },
{ from: "D", to: "H", value: 3 },
{ from: "E", to: "H", value: 6 },
{ from: "G", to: "J", value: 5 },
{ from: "I", to: "J", value: 1 },
{ from: "H", to: "J", value: 9 }
];
chart.dataFields.fromName = "from";
chart.dataFields.toName = "to";
chart.dataFields.value = "value";
Report Date 2
CREATING A SANKEY DIAGRAM USING JAVASCRIPT
Using AmCharts
nodeTemplate.inert = true;
nodeTemplate.readerTitle = "Drag me!";
nodeTemplate.showSystemTooltip = true;
nodeTemplate.width = 20;
//export
chart.exporting.menu = new am4core.ExportMenu();
Report Date 3
CREATING A SANKEY DIAGRAM USING JAVASCRIPT
Using AmCharts
CSS
body {
#chartdiv {
width: 100%;
height: 500px
}
Report Date 4