daattali / timevis

📅 Create interactive timeline visualizations in R
http://daattali.com/shiny/timevis-demo/
Other
652 stars 157 forks source link

Feature request: allow timezone to be specified #67

Closed daattali closed 5 years ago

daattali commented 5 years ago

By default, the timeline displays times in local time, but it's possible to use moment.js to specify it to show in a different timezone; see https://github.com/daattali/timevis/issues/66

daattali commented 5 years ago

@IkerrSC @jpara3 FYI

JesusPF1981 commented 5 years ago

What is intended to be is that the table that is shown in the timevis table gets the same time as the timeline shows.

Not sure if being able to enable

    var options{
        moment: function(date){
                      return vis.moment(date).utc();

          }
      }

will be enought

daattali commented 5 years ago

To do that, you would use timezone=0. But I didn't like that as much, I prefer the user being able to choose what timezone the timeline is displayed in (in the majority of cases, the user doesn't need to retrieve any data back so they don't even realize or care that it comes back in UTF. Most of the times it's only used for rendering, so it's good to choose what timezone it should be displayed in)

JesusPF1981 commented 5 years ago

But where I have to do it? In timevis function?

          timevis(data,options=list(timezone=0)?

And to add for example, UTC+1?

               timevis(data,options=list(timezone=1)?

Thanks!

daattali commented 5 years ago

As the documentation says, it's a parameter of timevis. timevis(data, ..., timezone=1). It couldn't be used as an option because it required such specialized code, it's too much to expect a user to add moment: function(date){return vis.moment(date).utc();} so instead it's just a simple parameter

JesusPF1981 commented 5 years ago

I have tried with

  timevis(data,.....,timezone=1) 

And I have get: Unused argument timezone=1

I have tried also

  timevis(data,.....,timezone=1) 

And it did not work Also I have tried adding

  var options{
          moment: function(date){
                   return vis.moment(date).utc();

         }
      }

And also not working!

daattali commented 5 years ago

Did you install the latest version from github in the past 30 minutes?


Dean Attali President & CEO AttaliTech Ltd http://AttaliTech.com http://attalitech.com

On Thu, 17 Jan 2019 at 00:35, jpara3 notifications@github.com wrote:

I have tried with

timevis(data,.....,timezone=1)

And I have get: Unused argument timezone=1

I have tried also

timevis(data,.....,timezone=1)

And it did not work Also I have tried adding

var options{ moment: function(date){ return vis.moment(date).utc();

     }
  }

And also not working!

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/daattali/timevis/issues/67#issuecomment-455058904, or mute the thread https://github.com/notifications/unsubscribe-auth/AA6IFJf41R7wfFSMPFxwXoS4s10W6Wxuks5vEBmhgaJpZM4aELOF .

JesusPF1981 commented 5 years ago

I have tried with it, but not working

 Couldn't normalize path in `addResourcePath`, with arguments: `prefix` = 'jquery-1.11.3'; `directoryPath` = '

Here my app code:


library(timevis)
library(shiny)

data <- data.frame(id=1,
  start=c("2019-01-10","2019-01-11"),
  end =  c("2019-01-11","2019-01-12")
  )

ui <- fluidPage(
  br(),
  br(),
  timevisOutput("timeline"),
  tableOutput("table")
)

server <- function(input,output){
  output$timeline <- renderTimevis(

    timevis(data,options=list(editable=TRUE,stack=FALSE),timezone=1)
  )

  output$table <- renderTable(
    input$timeline_data

  )

}

shinyApp(ui,server)
daattali commented 5 years ago

I tried installing the package just now on 3 different computers and did not have an issue. Try restarting your R session and reinstalling the package.

If you still see a problem with timevis and you think there's a bug, please submit a new issue separate from this

JesusPF1981 commented 5 years ago

OK,

Now its working but only if I set the timezone=0. With this there is no problem (but the data are shown with one hour of delay: imagen

But if I want to use a timezone, for example +1, then the timeline and the table show discrepancies: imagen

daattali commented 5 years ago

What you're seeing is correct. For example, in the second example that you show, you're asking timevis to render as if it's in UTC+1, so in that timezone it's 00:00. If it's 00:00 in UTC+1, then in UTC it's 23:00. As I said a few times, timevis can only return information to shiny in UTC (that's what the Z means in the timestamp), so the return value of 23:00:00Z is correct because in UTC it is 23:00 when the timevis shows 00:00

If you still believe there is a bug, please submit a new issue for better organization

JesusPF1981 commented 5 years ago

OK

Thanks for all!