Changing a Thermometer's current value via the "Set()" method

Share RGraph:   Share or Like RGraph on Facebook!

« Back to message list

Enter your email address to get email updates on this topic. You can stop receiving updates by clicking the link in the update email messages.

Posted by gng on 15th November 2012
Can anyone give an example of how to change a thermometer's current value by calling the appropriate set method ?

I've tried :-

thermometer.Set(value, 78);

thermometer.Set("value", 78);

thermometer.Set("currentValue", 78);

etc but it has no effect.

Thanks for any help !
Posted by RGraph support on 15th November 2012
Hi,

You can take a look at this page:

www.rgraph.net/examples/thermometer.html

The first (green) thermometer is adjustable (with a Grow effect). The relevant code is (put this after you've made and drawn the thermometer):

myThermometer.canvas.onmousedown = function (e)
{
     var obj = e.target.__object__;
     var value = obj.getValue(e);

     obj.value = value;
     RGraph.Effects.Thermometer.Grow(obj);
}
Posted by Lisp on 23rd November 2012
Hi,
sorry but i don't understand, i want change value of thermo by clicking a button that call a function where i declare the object, something like this:

     <script >
      function changevalue(newvalue) {
        thermometer.setvalue(newvalue);
        thermometer.Draw();
         }
     </script>

is it possible to do something like this ?
Posted by gradtje on 24th November 2012
Hi there,

I`ve just spend yestrday`s evening with exact the same problem. I`m not very experienced with js...

Try thermometer.value = newvalue...

Then you need to clear and redraw of course.

Good luck !
Posted by RGraph support on 26th November 2012
Hi,

Yes - as the the post above mentions - you set the value , clear and redraw. So wrapping that up in a function:

function SetValue (thermometer, value)
{
     thermometer.value = value;

     // There's a few ways to redraw your canvas - this is the easiest
     RGraph.Redraw();
}

Add a reply




« Back to message list