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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:39:47+00:00 2026-06-04T19:39:47+00:00

I am trying to dynamically update a value in a Google Charts Gauge, but

  • 0

I am trying to dynamically update a value in a Google Charts Gauge, but when I try and use a variable as the value, it breaks.

var data = google.visualization.arrayToDataTable([
    ['Label', 'Value'],
    //Doesn't work:
    ['Barometer', x],
    //Works:
    [x, 28],
    //Works:
    ['Barometer', 28]
    ]);

The problem is the way that I am declaring the variable, I think, because when I just use var x=28, it works fine.
Here is the code I am using to get the variable: It uses Jquery to fetch a JSON file, and takes a value from the file:

var x
    $.getJSON('http://pipes.yahoo.com/pipes/pipe.run?_id=467a55b506ba06b9ca364b1403880b65&_render=json&textinput1=40.78158&textinput2=-73.96648&_callback=?',
        function(data){
            x = data.value.items[0].data[1].parameters.pressure.value;
        }
    )

I tried using x = eval(x), but it still didn’t wok at all. However, when I used x = eval(x+1-1) or x = x+1-1, the gauge showed up, but the value was NaN.

  • 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-04T19:39:50+00:00Added an answer on June 4, 2026 at 7:39 pm

    OK, solved it.

    I ended up defining the variable before loading the Google Charts API, and then, right before defining the variable, I added x = eval(x).

    So here is the final, simplified code:

    var x
    $.getJSON('insert JSON url here WITH QUOTES',
        function(data){
            x = path.to.something.in.JSON.file.here;
        }
    
    google.load('visualization', '1', {
        packages: ['gauge']
    });
    google.setOnLoadCallback(drawChart);
    
    function drawChart() {
    
        x = eval(x)
        var Data = google.visualization.arrayToDataTable([
            ['Label', 'Value'],
            ['Gauge', x],
            ]);
    
        var Options = {
        };
    
        var Chart = new google.visualization.Gauge(document.getElementById('insertGaugeContainerHere'));
        Chart.draw(Data, Options);
    }
    

    In case you’re wondering, the final product is located here.

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

Sidebar

Related Questions

I'm trying to update/save dynamically created html objects using jquery. But in one particular
I am trying to figure out how I can update my sql query dynamically.
I am trying to dynamically re-structure some data to be shown in a treeview
I'm trying to dynamically grab a Google Fonts css file so I can parse
I'm trying to dynamically add buttons to the userform, but the userform just comes
I'm trying to dynamically update a table of values using SocketStream. I have a
I am trying to use jQuery to update a URL (in a text field)
I'm trying to dynamically update the HTML5 placeholder attribute of a text field using
I am trying to get a UIWebView to update dynamically, sort of like a
I'm trying to create a dynamically-updated Prefuse graph, where nodes are added and deleted

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.