1
$\begingroup$

I can't seem to access a FrameTicks type option for setting the values of frame ticks on the axes of a Gauge. Below is an example, how can I change the ticks from seconds to minutes:

Clear[Countdown];
Countdown[sec_] := (RemoveScheduledTask[ScheduledTasks[]];
  $countdownTimer = sec;
      RunScheduledTask[$countdownTimer--, {1, sec}];
  RunScheduledTask[EmitSound[Play[Sin[1000 t^2], {t, 0, 1}]]; 
   CreateDialog[{TextCell[
      ToString[sec] <> " seconds complete :) Time up"], 
     DefaultButton[]}], {sec}];
  Dynamic@
   HorizontalGauge[$countdownTimer, {sec, 
         0}, GaugeStyle -> Hue[Rescale[$countdownTimer, {0, sec}, {0, 0.3}]], 
    GaugeMarkers -> "GlassRectangle", ScaleDivisions -> 10, 
    ImageSize -> {700}, ScalePadding -> None, 
    Background -> RGBColor[0, 0, 0, 0]])
$\endgroup$
4
  • $\begingroup$ By the way, the simplest workaround is orizontalGauge[$countdownTimer/60, {sec, 0}/60, ...] $\endgroup$
    – ybeltukov
    Jan 28, 2015 at 20:26
  • 1
    $\begingroup$ Related: mathematica.stackexchange.com/questions/28348/… $\endgroup$
    – Szabolcs
    Jan 28, 2015 at 20:28
  • $\begingroup$ If you make Frame->True you'll see that the gauge ticks/markers are not part of the frame. A horizontal gauge lies along an x axis but those ticks are not used either. Instead the tick marks you see are Insets. $\endgroup$ Jan 28, 2015 at 20:31
  • $\begingroup$ @ybeltukov good point, @MikeHoneychurch, thanks, could DynamicModule[] be used here to better enclose things? $\endgroup$
    – M.R.
    Jan 29, 2015 at 13:17

1 Answer 1

1
$\begingroup$

You simply need to scale your gauge to display timer value in seconds by dividing by 60. Here is a 3-minute gauge.

With[{val = 100, sec = 180}, 
  HorizontalGauge[val/60, {sec/60, 0}, 
    GaugeStyle -> Hue[Rescale[val, {0, sec}, {0, 0.3}]], 
    GaugeMarkers -> "GlassRectangle",
    ScaleDivisions -> 3,
    ImageSize -> 500,
    ScalePadding -> None,
    Background -> RGBColor[0, 0, 0, 0]]]

gauge

$\endgroup$

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.