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

  • Home
  • SEARCH
  • 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 8587053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:28:20+00:00 2026-06-11T22:28:20+00:00

I am trying to construct google charts using a ajax response form PHP file.

  • 0

I am trying to construct google charts using a ajax response form PHP file. Following is the output of alert in my javascript

{"cols":[{"id":"5","label":"LISTING","type":"number"}],"rows":[{"c":[{"v":"1"}]}]}

When I used the following code to construct the graph i get the error Data table is not defined.

function drawBarChartAll(totalclientstatus) {
        alert(totalclientstatus);
        //eval ( 'var jsonobject = totalclientstatus;'); 
        //var json = google.visualization.DataTable.toJSON(totalclientstatus)
        var data = google.visualization.DataTable(totalclientstatus);

        var options = {
            'width':670,
            'height':310,

            hAxis: {title: 'Year',  titleTextStyle: {color: 'red'}}
            //chartArea:{left:20,top:20,width:"70%",height:"100%"}
        };


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

What am i doing wrong ? I am using the following php to construct the JSON

while ($row = mysqli_fetch_array($agent_result, MYSQL_ASSOC))
    {
        $columns = array();
        $reports['cols'][] = array(id => "{$row['statusid']}"
            , label => "{$row['status']}"
            , type => "number");
        $columns['c'][] = array(v => $row['total']);
        $reports['rows'][] = $columns;
    }
 return json_encode($reports);

The ajax response is

{"totalclientstatus":"{\"cols\":[{\"id\":\"5\",\"label\":\"LISTING\",\"type\":\"number\"}],\"rows\":[{\"c\":[{\"v\":\"1\"}]}]}"}
  • 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-11T22:28:22+00:00Added an answer on June 11, 2026 at 10:28 pm

    I guess you missed the ‘new’ :

    var data = new google.visualization.DataTable( …

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

Sidebar

Related Questions

I'm trying to access Gmail by using three-legged Oauth PHP code provided by Google
I'm trying to load the Google calendar API which comes in PHP, but firstly
I am trying to load a StageWebView with the Google Maps Javascript API inside
I'm fetching some line charts using Google's Chart API and placing it in a
I am trying to create an object that handles Google Maps Api as following:
Using the LightOpenID class, I am trying to get Google's login integrated with my
I am trying to construct a regular expression to detect a keyword in google
Trying to construct a Request with Network.HTTP.Conduit package. The instructions are: The constructor for
Am trying to construct a simple update query in my model class Model_DbTable_Account extends
I am trying to construct a customized map in raphaeljs , in this i

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.