google.charts.load('current', {'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]
]);
var options = {
width: 600
};
var colorMap = {
'A': 'cyan',
'X': 'magenta',
'Y': 'yellow',
'Z': 'lime',
'B': 'violet'
};
var chartDiv = document.getElementById('sankey_basic');
var chart = new google.visualization.Sankey(chartDiv);
var observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
mutation.addedNodes.forEach(function (node) {
if (node.tagName === 'text') {
node.setAttribute('font-size', '20');
node.setAttribute('fill', colorMap[node.innerHTML]);
}
});
});
});
observer.observe(chartDiv, {
childList: true,
subtree: true
});
chart.draw(data, options);
}
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="sankey_basic"></div>