Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8276535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:24:21+00:00 2026-06-08T08:24:21+00:00

I am currently using Google Charts with PHP to populate the data but the

  • 0

I am currently using Google Charts with PHP to populate the data but the interactivity of the chart ceases to work and I don’t know why.

The code is as follows:

<?php
// Connect to DB and execute while loop to get values
...
...

echo '<div id="chart_div"></div>';

?>

<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">

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

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

  // Callback that creates and populates a data table,
  // instantiates the pie chart, passes in the data and
  // draws it.
  function drawChart() {

    // Create the data table.
    var data = new google.visualization.DataTable();
    data.addColumn('string', 'Review Score');
    data.addColumn('number', 'Number of Reviews');
    data.addRows([
      ['1 Star Reviews', <?php echo $one; ?>],
      ['2 Star Reviews', <?php echo $two; ?>],
      ['3 Star Reviews', <?php echo $three; ?>],
      ['4 Star Reviews', <?php echo $four; ?>],
      ['5 Star Reviews', <?php echo $five; ?>]
    ]);

    // Set chart options
    var options = {'title':'Breakdown of Review Scores',
                   'is3D':true,
                   'width':600,
                   'height':400};

    // Instantiate and draw our chart, passing in some options.
    var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
    chart.draw(data, options);
  }

Even if I move the chart_div to after the javascript it doesn’t work.

Incase anyone asks the the js isn’t in the head tags it’s because I am also displaying a table populated with the results of the sql query and calculating totals based off those results for use in the chart.

I have since found this page but don’t see why that would alter anything:
https://developers.google.com/chart/interactive/docs/php_example

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T08:24:22+00:00Added an answer on June 8, 2026 at 8:24 am

    I meant to update a lot sooner but the problem lay elsewhere – Google Charts works perfectly fine when using php to populate the chart data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am populating my Google chart using JSON currently, but I need to customize
I am currently using a google visualisation pie chart. The legends of the chart
Currently using Google Analytics as a supplement to our paid tracking software, but neither
I have a Google Chart (using the Google Visualization API , not Google Charts
I am using Google charts api to draw a table chart. I am making
Using Google's new Charts is a wonderful way to build graphicial representations of data,
I am currently using Google API to point the position on Google map. this
I am currently using the google maps' reverse geocoding API to convert long/lat received
Note: I'm using Google Chrome Currently I have this test page http://www.evecakes.com/doodles/canvas_size_issue.htm It should
I am currently using free version of Google Apps for hosting my email.It works

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.