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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:07:22+00:00 2026-05-31T09:07:22+00:00

Firstly, the Google Chart API example from Google (it is javascript) actually <script type=text/javascript>

  • 0

Firstly, the Google Chart API example from Google (it is javascript) actually

<script type="text/javascript">
      // There is of coz some thing else but i just ignore them, just focus on the data here
      function drawChart() {
        var data = new google.visualization.DataTable();
        data.addColumn('string', 'Year');
        data.addColumn('number', 'Sales');
        data.addColumn('number', 'Expenses');
        data.addRows([
          ['2004', 1000, 400],
          ['2005', 1170, 460],
          ['2006', 660, 1120],
          ['2007', 1030, 540]
        ]);
    </script>

Now i modify to become this

<script type="text/javascript">
      function drawChart(reading) {
        var data = new google.visualization.DataTable();
        data.addColumn('string', 'Year');
        data.addColumn('number', 'Sales');
        data.addColumn('number', 'Expenses');
        data.addRows([reading]);
    </script>

(I implement in servlet)
Now, i wish to pass my own data ( after reading from database) and make it to a string. pass it to the modified javascript by calling drawChart(reading)

//After some action retrieving data from db and make it to a data string like this
        String reading = "['2011',1000,400],['2009',800,200]";
        out.println("<body onload=\"drawChart("+reading");\">");
            //drawing is here
            out.println("</body>");

However, it seems that JS can’t accept such string variable, what kind of format should i pass the variable to the JS? Or i shouldn’t use String reading but others? But there isn’t such kind of variable type in Java..

  • 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-31T09:07:23+00:00Added an answer on May 31, 2026 at 9:07 am

    Just let Java print exactly the same data as you would write in plain vanilla JavaScript. You do not need to convert the data at all. Java doesn’t execute JavaScript. Java just generates JavaScript code which get executed later when arrived at webbrowser.

    String reading = "[['2004', 1000, 400],['2005', 1170, 460],['2006', 660, 1120],['2007', 1030, 540]]";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Firstly, I was wondering if there was some kind of built in function that
Firstly,I use google static map API to get the image to display on html/wml.
I'm trying to load the Google calendar API which comes in PHP, but firstly
I am trying to request JSON from Google Places API, but I am still
Firstly, I've done some Google'ing and found the IE 'conditional comment' and understand it's
Firstly, here's my script: #!/usr/bin/python import sys, os sys.path.append('/home/username/python') sys.path.append(/home/username/python/flup) sys.path.append(/home/username/python/django) # more path
Firstly I know that there are many question and solutions to correct thread marshalling
Firstly, sorry for my English (I'm from China). By reading this article( how to
I've been working for a few weeks now with the Google Maps API v3,
Having trouble with a couple of display issues in IE7. Firstly, my large text

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.