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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:59:46+00:00 2026-06-04T07:59:46+00:00

I am trying to put two Google charts on a single web-page but can

  • 0

I am trying to put two Google charts on a single web-page but can only get it to plot the first one and not the other. Can anyone look and see what I am doing wrong?

I am using two different divs for plotting, which I thought was the important step. I tried also using two different functions for the different plots but still could not get it to work.

I would be very thankful for useful suggestions.

thanks!!

Ayesha

<!--To change this template, choose Tools | Templates and open the template in the editor.-->
<!DOCTYPE html>
<html>
<head>
    <script type='text/javascript' src='http://www.google.com/jsapi'></script>
    <script type='text/javascript'>
        google.load('visualization', '1', {'packages':['annotatedtimeline']});
        google.setOnLoadCallback(drawChart1);
        function drawChart1() {

            var data1 = new google.visualization.DataTable();
            data1.addColumn('date', 'Date');
            data1.addColumn('number', 'Sold Pencils');
            data1.addColumn('string', 'title1');
            data1.addColumn('string', 'text1');
            data1.addColumn('number', 'Sold Pens');
            data1.addColumn('string', 'title2');
            data1.addColumn('string', 'text2');
            data1.addRows([
                [new Date(2008, 1 ,1), 30000, undefined, undefined, 40645, undefined, undefined],
                [new Date(2008, 1 ,2), 14045, undefined, undefined, 20374, undefined, undefined],
                [new Date(2008, 1 ,3), 55022, undefined, undefined, 50766, undefined, undefined],
                [new Date(2008, 1 ,4), 75284, undefined, undefined, 14334, 'Out of Stock','Ran out of stock on pens at 4pm'],
                [new Date(2008, 1 ,5), 41476, 'Bought Pens','Bought 200k pens', 66467, undefined, undefined],
                [new Date(2008, 1 ,6), 33322, undefined, undefined, 39463, undefined, undefined]
            ]);

            var chart1 = new google.visualization.AnnotatedTimeLine(document.getElementById('chart_div1'));
            chart1.draw(data1, {displayAnnotations: true});

            var data2 = google.visualization.arrayToDataTable([
                ['Year', 'Sales', 'Expenses'],
                ['2004',  1000,      400],
                ['2005',  1170,      460],
                ['2006',  660,       1120],
                ['2007',  1030,      540]
            ]);

            var options = {
                title: 'Company Performance',
                vAxis: {title: 'Year',  titleTextStyle: {color: 'red'}}
            };

            var chart2 = new google.visualization.BarChart(document.getElementById('chart_div2'));
            chart2.draw(data2, options);

        }
    </script>
</head>

<body>
    <p> Testing Google line chart tool </p>
    // Note how you must specify the size of the container element explicitly!
    <div id='chart_div1' style='width: 700px; height: 240px;'></div>

    <br> <br> <br> 

    <p> Testing another chart </p>
    <div id='chart_div2' style='width: 700px; height: 240px;'></div>

</body>
</html>

Ayesha

  • 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-04T07:59:47+00:00Added an answer on June 4, 2026 at 7:59 am

    Include corechart when loading the packages.

    google.load('visualization', '1', 
    {'packages':['annotatedtimeline','corechart']});
    

    See here: http://jsfiddle.net/Ng7ne/

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

Sidebar

Related Questions

Im trying to put in two sign up forms on a single page, but
I'm trying to put two sliders in the same form ; but I can't
I'm trying to take one group and put it in two different columns. I
I'm trying to put two web projects that needs to be installed in different
Hey. I'mm trying to put two points on a single map with same div
I am trying to put two different UIPopovers in one view. I'm fairly new
I'm trying to put two blocks into one fixed-height block to create the following
I am trying to put a Google Plus One and a Facebook Like button
I am trying to put two scatter plots next to each other with a
Simply put I'm trying to sync two slideshows created using widgetkit lib in a

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.