dankelley / plan

R package for project planning
https://dankelley.github.io/plan/
33 stars 9 forks source link

Error in as.POSIXct.numeric(time1) : 'origin' must be supplied #18

Closed peti closed 6 years ago

peti commented 6 years ago

I tried the new release, but ran into the following issue when supplying POSIXct values for start and end:

>>> g <- new("gantt")
>>> g <- ganttAddTask(g, "foo", as.POSIXct("2018-05-30 15:12"), as.POSIXct("2018-05-30 15:20"))
>>> plot(g)
Error in as.POSIXct.numeric(time1) : 'origin' must be supplied

Is that to be expected? Is there another way to accomplish this?

peti commented 6 years ago

Another problem I've noticed is that

axis(1, at=ticks, labels=strftime(ticks, "%H:%M"))

will no longer work if ticks is of type POSIXct. I guess that the timestamps I have in that vector no longer match the value range used for the x axis internally?

dankelley commented 6 years ago

Re the first: you're right, that does not work. The docs for ganttAddTask say the times are character strings, though, and if you do example(ganttAddTask) I think it should work. (I can make it also work if you give POSIXt values instead of character strings, but of course that won't get into the CRAN release for many months, because they frown on frequent updates.)

On the second, can you supply a complete working example?

Thanks again.

peti commented 6 years ago

OK, I re-visited the code I wrote a while ago today and I was able to fix all issues by converting the POSIXct timestamps I had in my data via as.character() before passing them to ganttAddTask(). It feels a little strange that I have to do this, but it works fine if I do.

As for the axis-labeling issue, I was able to solve that by passing time.format="%H:%M" to my plot() call.

So all is well now. :-) Thank you very much for your help and for writing this fine library!