Google org Chart with HTML tool tip - Javascript Google Chart

Javascript examples for Google Chart:Org Chart

Description

Google org Chart with HTML tool tip

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Org Chart Example</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script> 
      <script type="text/javascript" src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script> 
      <link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css"> 
   </head> 
   <body> 
      <script type="text/javascript" src="https://www.google.com/jsapi?autoload={'modules':[{'name':'visualization','version':'1','packages':['orgchart']}]}"></script> 
      <div id="chart_div" "></div> 
      <script type="text/javascript">
      $(function () {//from   www . j  a  va2  s.c o  m
          $(document).tooltip({
              content: function () {
                  return $(this).prop('title');
              }
          });
      });
google.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}});
        data.addRows([
          [{v:'Mike', f:'Mike<div style="color:red; font-style:italic">President</div>'}, '', 'The President'],
            [{v:'Jim', f:'Jim<div style="color:red; font-style:italic">Vice President<div>'}, 'Mike', '<div style="color:red; font-style:italic">Vice President<div>'],
          ['Alice', 'Mike', ''],
          ['Bob', 'Jim', '<b>Bob</b> Sponge'],
          ['Carol', 'Bob', '']
        ]);
        var chart = new google.visualization.OrgChart(document.getElementById('chart_div'));
        var  options = {
            tooltip: {isHtml: true},
              allowHtml:true
        };
        chart.draw(data, options);
      }

      </script>  
   </body>
</html>

Related Tutorials