2

I have tried to simplify this issue as much as I can at the moment: it looks like a bug to me but perhaps I've missed something obvious.

I am trying to build an interactive scheduler using TimelinePlot and I find that the following code reports that I've tried to plot an invalid dataset:

Manipulate[Column@{DatePlus[{2019, 1, 15}, sdate],
TimelinePlot[{{Labeled[{2011, 1, 1}, "hello"], {2012, 1, 1}, {2013, 1, 1}}, 
    {Labeled[Interval[{{2011, 3, 1}, {2012, 7, 7}}], mylabel], 
     Interval[{{2012, 9, 12}, {2013, 12, 21}}]}, {Labeled[
     Interval[{DatePlus[{2011, 3, 1}, sdate], 
     DatePlus[{2012, 7, 7}, sdate]}], "Moving interval"], 
     Labeled[Interval[{{2012, 9, 12}, {2013, 12, 21}}], "Range"]}}]}, 
  {sdate, 0, 200, 1}, 
  {mylabel, {"la", "lb", "lc"}}]

Mathematica graphics

but this works fine

Manipulate[Column@{DatePlus[{2019, 1, 15}, sdate],
TimelinePlot[{{{2011, 1, 1}, {2012, 1, 1}, {2013, 1, 1}}, 
{Labeled[
   Interval[{{2011, 3, 1}, {2012, 7, 7}}], mylabel], 
   Interval[{{2012, 9, 12}, {2013, 12, 21}}]}, 
{Labeled[
   Interval[{DatePlus[{2011, 3, 1}, sdate], 
     DatePlus[{2012, 7, 7}, sdate]}], "Moving interval"], 
   Labeled[Interval[{{2012, 9, 12}, {2013, 12, 21}}], 
   "Range"]}}]}, {sdate, 0, 200, 1}, 
{mylabel, {"la", "lb", "lc"}}]

Mathematica graphics

as well as this:

With[{sdate = 1, mylabel = "foo"},
 Column@{DatePlus[{2019, 1, 15}, sdate],
 TimelinePlot[{{Labeled[{2011, 1, 1}, "hello"], {2012, 1, 1}, {2013,
    1, 1}}, {Labeled[Interval[{{2011, 3, 1}, {2012, 7, 7}}], 
   mylabel], 
  Interval[{{2012, 9, 12}, {2013, 12, 21}}]}, {Labeled[
   Interval[{DatePlus[{2011, 3, 1}, sdate], 
     DatePlus[{2012, 7, 7}, sdate]}], "Moving interval"], 
  Labeled[Interval[{{2012, 9, 12}, {2013, 12, 21}}], "Range"]}}]}]

Mathematica graphics

fairflow
  • 1,028
  • 5
  • 18

1 Answers1

1

Looks like a bug. Two smaller examples exhibiting two aspects of the issue:

(1) TimelinePlot[{{Labeled[{2011, 3, 1}, "Label"]}}] works as expected but Manipulate[TimelinePlot[{{Labeled[{2011, 3, 1}, "Label"]}}], {sdate, 0, 200, 1}] gives an error.

(2) Although TimelinePlot[{{{2011, 3, 1}, Interval[{{2011, 3, 1}, DatePlus[{2011, 3, 1}, 100]}]}}] works fine, inside Manipulate it gives an error message. In general, if any element of datai in TimeLinePlot[{data1, ..., datan}] is a date list ({y,m,d,...}) without wrappers all elements of datai should be date lists without wrappers.

A work-around: Wrap the date lists with DateObject (or DateList or AbsoluteTime), that is, use

{Labeled[DateObject@{2011, 1, 1}, "hello"], DateObject@{2012, 1, 1}, DateObject@{2013, 1, 1}}

in the first sublist of your input data to get

enter image description here

kglr
  • 394,356
  • 18
  • 477
  • 896