Help with Chart Visualization

24 views
Skip to first unread message

Rodydl

unread,
Jun 28, 2016, 6:28:47 PM6/28/16
to Google Visualization API
I am trying to create a dashboard to represent some data I have in a google spreadsheet and I have followed the charts guides the best I know how since I am no programmer. I have come up with the script below which is not working and I would like some help in getting it to work.

The link to my speadsheet:

The data I am trying to show as a column chart is in Sheet2 (Data2) columns D and E (highlighted), and I added that range to the url query "range=D:E"

The code that I have come up with is below. I just want to get it to show the chart. Any help is appreciated.

<html>
  <head>
    <!--Load the AJAX API-->
    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
    <script type="text/javascript">

      // Load the Visualization API and the corechart package.
      google.charts.load('current', {'packages':['corechart']});

      // Set a callback to run when the Google Visualization API is loaded.
      google.charts.setOnLoadCallback(drawChart);

      // Callback that creates and populates a data table,
      // instantiates the pie chart, passes in the data and
      // draws it.
      
function drawSheetName() {
      var queryString = encodeURIComponent('SELECT D, E');

      var query = new google.visualization.Query(
      query.send(handleSampleDataQueryResponse);
    }

    function handleSampleDataQueryResponse(response) {
      if (response.isError()) {
        alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
        return;
      }

      var data = response.getDataTable();
      var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
      chart.draw(data, { height: 400 });
    }
}

Reply all
Reply to author
Forward
0 new messages