Javascript examples for Google Chart:Org Chart
Custom Tooltip in Google Sheets Org Chart
<html> <head> <title>Org Chart Example</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <style id="compiled-css" type="text/css"> .tooltip {/* w ww .ja va2 s. c om*/ position: relative; display: inline-block; border-bottom: 1px dotted black; } .tooltip .tooltiptext { visibility: hidden; width: 120px; background-color: black; color: #fff; text-align: center; padding: 5px 0; border-radius: 6px; position: absolute; z-index: 1; } .tooltip:hover .tooltiptext { visibility: visible; } </style> </head> <body> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <div id="chart_div"></div> <script type="text/javascript"> google.charts.load('current', {packages:["orgchart"]}); google.charts.setOnLoadCallback(drawChart); const dataSheets1 = "Tooltip1" const tooltip1 = `<div class="tooltip">Hover over me <span class="tooltiptext">${dataSheets1}</span> </div>` const tooltipText = (text, tooltip) => { return `<div class="tooltip">${text} <span class="tooltiptext">${tooltip}</span> </div>` } function drawChart() { var data = new google.visualization.DataTable(); data.addColumn('string', 'Name'); data.addColumn('string', 'Manager'); data.addColumn('string', 'ToolTip'); data.addRows([ [{v:'Mike', f:'Mike<div style="color:red; font-style:italic">President</div>'},'', 'Tooltip1'], [{v:'Jim', f:tooltip1},'Mike', ''], [{v:'Alice', f:tooltipText('Alice', 'CEO of the world tooltip')}, 'Mike', ''], ['Bob', 'Jim', 'Tooltip4'], ['Carol', 'Bob', 'Tooltip5'] ]); var chart = new google.visualization.OrgChart(document.getElementById('chart_div')); chart.draw(data, {allowHtml:true}); } </script> </body> </html>