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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:10:17+00:00 2026-05-31T08:10:17+00:00

What I am doing is to display a graph when a user clicks a

  • 0

What I am doing is to display a graph when a user clicks a button. The chart is being fetched from a PHP file using javascript. Here is the code what i am actually doing.

This is the javascript function that fetches graph and attaches it to HTML DOM

function draw_graph(num) {

   var xmlhttp;
   if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
       xmlhttp=new XMLHttpRequest();
   } else { // code for IE6, IE5
       xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }

   xmlhttp.onreadystatechange = function() {
       if (xmlhttp.readyState==4 && xmlhttp.status==200) {
        var output = xmlhttp.responseText;
        document.getElementById('script_content').innerHTML = output;
       }
   }
   xmlhttp.open("GET","includes/getgraphdata.php?type="+num+"&mode=day",true);
   xmlhttp.send();

}

This is the PHP code, I am trying to draw a simple graph with dummy data

    <?php

echo "
    <script type=\"text/javascript\" src=\"https://www.google.com/jsapi\"></script>
        <script type=\"text/javascript\">                   
                        google.load('visualization', '1', {packages:['corechart']});
                        google.setOnLoadCallback(drawChart);
                        function drawChart() {
                            var data = new google.visualization.DataTable();
                            data.addColumn('string', 'Date');
                            data.addColumn('number', 'Sell');
                            data.addColumn('number', 'Purchase');
                            data.addRows([
                              ['12-03-2012', 150, 300],
                              ['12-04-2012', 250, 500]
                            ]);

                            var options = {
                              title: 'Graph'
                            };
                            var chart = new google.visualization.LineChart.(document.getElementById('temp'));
                            chart.draw(data, options);
                        }
                    </script>
    ";

The above code attached with the HTML DOM correctly, but graph is not displaying.

  • 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-05-31T08:10:18+00:00Added an answer on May 31, 2026 at 8:10 am

    this line

     var chart = new google.visualization.LineChart.(document.getElementById('temp'));
    

    Remove . after LineChart. Hence, it is LineChart(document.getElementById('temp'));

    Also place an alert("statement reached"); between the above line and the next line to track the error. If the error takes place, next line may not get executed, and thus use it as a debug advantage.

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

Sidebar

Related Questions

What am I doing wrong here folks? <?php include 'header.php'; /** * Display a
I'm using the Graph Api on PHP to fetch the albums for an user.
If you are using ASP.NET MVC how are you doing grid display? Rolled your
My requirement is to display tables from database in Graph format and I am
I am trying to display a real time graph using the data which is
I'm trying to display data on a line graph using Google Charts. The data
I'm looking to display only certain states using Polymaps. I'm using the Unemployment graph
Im trying to learn php by doing a little project using apache server. I
I am using SSRS to display reports what i doing technically is I am
I'm using a bit of JSON to parse information from facebook pages to display

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.