Sankey Diagram not getting value
HTML
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<div id="sankey_basic" style="width: 900px; height: 300px;"></div>
JavaScript
google.charts.load('43', {
packages: ['sankey']
});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'From');
data.addColumn('string', 'To');
data.addColumn('number', 'Weight');
data.addRows([
['A', 'X', 5],
['A', 'Y', 7],
['A', 'Z', 6],
['B', 'X', 2],
['B', 'Y', 9],
['B', 'Z', 4]
]);
// Sets chart options.
var options = {
width: 600,
sankey: {
node: {
interactivity: true,
color: {
unfocused: {
fillOpacity: 0.2
}
}
},
link: {
color: {
unfocused: {
fillOpacity: 0.2
}
}
}
}
};
// Instantiates and draws our chart, passing in some options.
var chart = new
google.visualization.Sankey(document.getElementById('sankey_basic'));
google.visualization.events.addListener(chart, 'select', selectHandler);
function selectHandler(e) {
var selection = chart.getSelection();
var message = '';
for (var i = 0; i < selection.length; i++) {
var item = selection[i];
if (item.row != null && item.column != null) {
message += '{row:' + item.row + ',column:' + item.column + '}';
} else if (item.row != null) {
message += '{row:' + item.row + '}';
} else if (item.column != null) {
message += '{column:' + item.column + '}';
} else if (item.name != null) {
message += '{name:"' + item.name + '"}';
}
}
if (message == '') {
message = 'nothing';
}
alert('You selected ' + message);
}
chart.draw(data, options);
}