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 9104591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:54:21+00:00 2026-06-17T01:54:21+00:00

I use google visualization api! I know that All Google visualization constructs accept an

  • 0

I use google visualization api!
I know that All Google visualization constructs accept an instance of the Javascript object google.visualization.DataTable, which can be instantiated in one of two ways.

So I use the second way in which my data table in constructed with JSON of a certain structure and using specific attributes.
The problem is as you see I want to add a specific number of rows using for cycle and when I try to do this it gives me the mentioned above error

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
        <title>
          Google Visualization API Sample
        </title>
        <script type="text/javascript" src="http://www.google.com/jsapi"></script>
        <script type="text/javascript">
          google.load('visualization', '1', {packages: ['table']});
        </script>
        <script>

        function drawVisualization()
        {
         var data = new google.visualization.DataTable
         (
           {
           cols: [
           {id: 'task',  label: 'Task',          type: 'string'},
           {id: 'hours', label: 'Hours per Day', type: 'number'},
            {id: 'E',   label: 'Action',          type:  'string'}
                  ],
                  for (i=0;i<3;i++) 
                  {
                    rows: [ 
                    {c:[{v: 'Work'},     {v: 5},     {v: '<input type="button" value="my button" onclick="alert(\'I was clicked!\');"/>'}]},
                    {c:[{v: 'Eat'},      {v: 2}]}
                           ]                     
                   }
             }         

         );



        visualization = new google.visualization.Table(document.getElementById('table'));
        visualization.draw(data, null);
        }
      google.setOnLoadCallback(drawVisualization);
        </script>
        </head>
        <body>
        <div id="table"></div>
        </body>
        </html>
  • 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-17T01:54:22+00:00Added an answer on June 17, 2026 at 1:54 am

    Your syntax is not valid. You will need to construct the object step-by-step, first the static part, then add the rest with the for loop:

    var rawData = {
        cols: [
            {id: 'task',  label: 'Task',          type: 'string'},
            {id: 'hours', label: 'Hours per Day', type: 'number'},
            {id: 'E',     label: 'Action',        type:  'string'}
        ],
        rows: []
    };
    
    for (var i = 0; i < 3; i++)  {
        rawData.rows.push({
            c:[{v: 'Work'}, {v: 5}, {v: '<input type="button" value="my button" onclick="alert(\'I was clicked!\');"/>'}]
        });
        rawData.rows.push({
            c:[{v: 'Eat'}, {v: 2}, {v: ''}]
        });
    }
    
    var data = new google.visualization.DataTable(rawData);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to use google drawVisualization API. Example: var data = new google.visualization.DataTable(); data.addColumn('string');
I'm reading the Terms of use which can be found here: http://code.google.com/apis/visualization/terms.html But I
I use Google Visualization API to plot Line Chart. Here are the codes: google.load(visualization,
I am trying to use the google chart tools (from the visualization api; not
I'm trying to use Google Visualization API to generate Pie charts. My implementation is
I am trying to use the Google Charts API to create a chart that
i want to use google chart map which is a piece of javascript code
To use Google Maps API you fetch their api js file with: <script type=text/javascript
I'm trying to use google visualization api in jboss seam 2 project. I have
I use, google.load('visualization', '1', {'packages': ['columnchart']}); //google.setOnLoadCallback(drawChart); function drawChart(response) { alert(response.customerlist); var data =

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.