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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:57:54+00:00 2026-06-05T02:57:54+00:00

I am trying to fill a Dictionary (JavaScript object) and retrieve values (custom objects/classes)

  • 0

I am trying to fill a Dictionary (JavaScript object) and retrieve values (custom objects/classes) from it using a string index. Then once I get the value from the dictionary, I need to invoke a method on this object. Unfortunately, that does not work because once it is being retrieved from the Dictionary, it is just a simple object (typeof returns “object”).

So the thing I’m trying to do is to cast to the object type that was initially pushed into the dictionary, which is in my case: google.visualization.Gauge. (Reference)

I tried to use Object.create but that did not work for me. Below is my code:

var _gauges = {};

var methods = {
    init: function (options) {

        var containers = this;

        if (containers != null && containers != undefined && containers.length > 0) {
            containers.each(function (index, elem) {

                var id = $(elem).attr('id');
                var name = $(elem).data('name');
                var value = $(elem).data('value');

                var data = google.visualization.arrayToDataTable([
            ['Label', 'Value'],
            [name, value]
                ]);

                var options = {
                    width: 400, height: 120,
                    redFrom: 90, redTo: 100,
                    yellowFrom: 75, yellowTo: 90,
                    minorTicks: 5
                };
                var cont = document.getElementById(id);
                var chart = new google.visualization.Gauge(cont);
                _gauges[name] = chart;
                chart.draw(data, options);
            });
        }

    },
    setValue: function (gaugeName, newValue) {
        var thisGauge = _gauges[gaugeName];
        if (thisGauge) {
            thisGauge.setCell(0, 1, newValue);
            //var tmp = Object.create(google.visualization.Gauge, thisGauge);
            //tmp.setCell(0, 1, newValue);
        }
    }
  • 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-05T02:57:55+00:00Added an answer on June 5, 2026 at 2:57 am

    Well, two things:

    1. If one of those “Gauge” objects is really getting put into the array correctly, when you get it back out it will emerge unscathed and you can just use it directly; no “casting” necessary.
    2. According to the documentation you linked, there is no “setCell” method 🙂
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to fill object[] with List<string> but I cannot figure out how
I'm trying to fill a grid view using data from a db cursor using
I have some classes and I'm trying to fill the objects of this class.
I am trying to fill a RealVector (from Apache Commons Math) with values. I
I'm trying to store a Dictionary<string, string> in the ViewState of a custom control
I am trying to fill products with values parsed from a website. The process
I am trying to fill a javascript array beaches3 from a php request dynamically
I'm trying to fill an array of 20 ints with numbers from 1-20 in
I'm trying to fill some data from an xml feed we made into my
I am trying to fill gridpanel to get data from database through LINQ in

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.