Is it possible to use html tooltips for an OrgChart?

25 views
Skip to first unread message

Peter DiFalco

unread,
Oct 17, 2017, 5:03:25 PM10/17/17
to Google Visualization API
I'm using the the google.visualization.DataTable to display an orgchart and I want to highlight parts of the tooltip via html.  Is this possible?

Note that I can get the title to display as html, but I cannot get the tooltip to display as html.

As an example, I get this result:

With this code:

<html>
 
<head>
   
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
   
<script type="text/javascript">
      google
.charts.load('current', {packages:["orgchart"]});
      google
.charts.setOnLoadCallback(drawChart);

     
function drawChart() {
       
var data = new google.visualization.DataTable();
        data
.addColumn('string', 'Name');
        data
.addColumn('string', 'Manager');
       
data.addColumn({ type: 'string', role: 'tooltip', 'p': { 'html': true, 'role': 'tooltip' } });

       
// For each orgchart box, provide the name, manager, and tooltip to show.
        data
.addRows([
         
[{v:'Mike', f:'Mike<div style="color:red; font-style:italic">President</div>'},
           
'', '<div style="color:green;">The President</div>'],
         
[{v:'Jim', f:'Jim<div style="color:red; font-style:italic">Vice President</div>'},
           
'Mike', 'VP'],
         
['Alice', 'Mike', ''],
         
['Bob', 'Jim', 'Bob Sponge'],
         
['Carol', 'Bob', '']
       
]);

       
// Create the chart.
       
var chart = new google.visualization.OrgChart(document.getElementById('chart_div'));
        // Set chart settings.
        var options = {
        allowHtml:true,
        isHtml:true,
        tooltip:{isHtml:true},
        }
       
// Draw the chart, setting the allowHtml option to true for the tooltips.
        chart
.draw(data, options );
      }
   
</script>
   
</head>
 
<body>
   
<div id="chart_div"></div>
 
</body>
</html>

Thank you.
Reply all
Reply to author
Forward
0 new messages