6
$\begingroup$

I want to do something that can be simplified into the following toy example: I want to dynamically show the count down to a future date on an AngularGage. The following code works,

x = Dynamic[Refresh[DateDifference[Now,FutureDate,"Minute",UpdateInterval->0.1]
Dynamic[AngularGauge[x,{0,1000}]

but the gauge displays an unwanted second hand. How do I get rid of it? The deeper question is about the complicated nature of dynamic variables, as demonstrated in the TreeForm image below. How do you use these kind of variables?

enter image description here

enter image description here

$\endgroup$

2 Answers 2

3
$\begingroup$

Don't know why but if you have a Quantity[513.2441798845927, "Minutes"] wrapped with Dynamic, then AngularGauge can't handle it and shows two inputs, 513.23 and "Minutes" (blue one).

I also don't know if that's suppose to happen but here's a work around:

Use QuantityMagnitude:

Dynamic[AngularGauge[
   Dynamic[Refresh[
     QuantityMagnitude @ DateDifference[Now, Tomorrow, "Minute"], 
     UpdateInterval -> 0.1
   ]], 
 {0, 1000}]
]

Or don't use the inner Dynamic since there is one outside anyway:

Dynamic[AngularGauge[
  Refresh[DateDifference[Now, Tomorrow, "Minute"], 
   UpdateInterval -> 0.1], {0, 1000}]]

The former method gives you more flexibility I think.

$\endgroup$
3
  • $\begingroup$ So, I guess one of the underlying questions is how to return just the numerical part of a dynamic value that is returned with the unit it is expressed in ... $\endgroup$ Apr 25, 2016 at 14:21
  • $\begingroup$ @GeorgeWolfe As shown above, you can use QuantityMagnitude and AngularGuge will digest it well. $\endgroup$
    – Kuba
    Apr 25, 2016 at 14:22
  • $\begingroup$ Oh, ok - QuantityMagnitude $\endgroup$ Apr 25, 2016 at 14:23
3
$\begingroup$

It can also be done this way. I recommend it because it avoids passing any complicated dynamic expression to AngularGauge.

Dynamic[
  AngularGauge[
    Quantity[DateDifference[Now, Tomorrow, "Minute"]], 
    {Quantity[0, "Minute"], Quantity[800, "Minute"]}, 
    GaugeLabels -> "Unit"], 
  UpdateInterval -> 1]

timer

The tooltip confirms that the gauge is dynamically updating.

$\endgroup$
1
  • $\begingroup$ I appreciate these answers. I'm learning more than I expected. $\endgroup$ Apr 25, 2016 at 21:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.