Need to Get Images in a working Org chart having data from google sheets.

Skip to first unread message


Oct 22, 2021, 9:12:46 AM10/22/21
to Google Visualization API

Request your help in a project.

We have used Google Org chart to create an hierarchy. Which is working absolutely fine.

The database is Google Sheets: Link:

The following code used to get the results and is working aboslutely fine.

Now we need to get images from the google sheets Image column and display at the corresponding Name

Can anyone please help us.

There is another thread which has answered this but the code is not working for us.


Code for Reference

  <div id="orgchart_admin"></div>
  <script src=""></script>
  <script type="text/javascript" src=""></script>
  <script type="text/javascript">
    google.charts.load('current', {'packages' : ['orgchart', 'table']});
    google.charts.setOnLoadCallback(function() { initialize('') });

    function initialize() {
      document.getElementById('orgchart_admin').innerHTML = "<i class='fa fa-spinner fa-spin fa-3x fa-fw'></i>";
      var dataSourceUrl = '';

      // Tells it that the first row contains headers: 'Role', 'Reports To', 'Name'
      var query = new google.visualization.Query(dataSourceUrl + '&headers=1');

      // Send the query with a callback function.

    function handleQueryResponse(response) {
      // Called when the query response is returned.
      if (response.isError()) {
        alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());

      var raw_data = response.getDataTable();
      var data = new google.visualization.DataTable();

      data.addColumn('string', 'Entity');
      data.addColumn('string', 'ParentEntity');
      data.addColumn('string', 'ToolTip');

      // Loops through all rows and populates a new DataTable with formatted values for the orgchart
      var num_rows = raw_data.getNumberOfRows();
      for (var i = 0; i < num_rows; i++) {
        var role = raw_data.getValue(i, 0);
        var reportsTo = raw_data.getValue(i,1);
        var name = raw_data.getValue(i,2) != null ? raw_data.getValue(i,2) : '';

          { v: role,
            f: name + "<div class='role'>" + role + "</div>"

      // Loops through all rows and populates a new DataTable with formatted values for the orgchart
      var container = document.getElementById('orgchart_admin');
      var chart = new google.visualization.OrgChart(container);
      chart.draw(data, {allowHtml:true, 'size': 'large'});

Reply all
Reply to author
0 new messages