2
$\begingroup$

Here is a small prototype construct mimicking a more complex manipulate environment I am trying to build:

t = AbsoluteTime[];
Manipulate[nd, {{nd, 30, "Data included up to:"}, 24, 30, 1, 
  Labeled[Manipulator[##], 
    DateObject[t - 86400 (30 - nd), "Day", 
     DateFormat -> {"MonthName", " ", "Day", ", ", "Year"}]] &}]

So I want to have a slider moving in increments corresponding to single days (in a time series that has dates in it), and I want the control to show the date corresponding to these steps. The above construct kind of works, but there is the issue that I cannot drag the slider by more than one stop. After I have moved it by one stop, I need to let go, move the mouse away from the slider, pick it back up and move again.

In contrast, if I just do something like

t = AbsoluteTime[];
Manipulate[nd, {{nd, 30, "Data included up to:"}, 24, 30, 1, 
  Appearance -> "Labeled"}]

Then I can continue to move the slider if I just keep dragging, but I don't get a date displayed by the control.

Does anyone know what goes wrong in my first example? Any suggestion of an alternative way to get a properly formatted date label?

$\endgroup$
3
$\begingroup$

Try

t = AbsoluteTime[];

Manipulate[nd, 
 Column[{Control@{{nd, 30, "Data included up to:"}, 24, 30, 1, Appearance -> "Labeled"}, 
   Dynamic @ DateObject[t - 86400 (30 - nd), "Day", 
      DateFormat -> {"MonthName", " ", "Day", ", ", "Year"}]}, 
  Alignment -> Center]]

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ Excellent, thanks very much! $\endgroup$ – Pirx Apr 5 at 0:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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