daattali / timevis

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

Change format date of double click for Timevis #111

Closed Teolone88 closed 3 years ago

Teolone88 commented 3 years ago

Hi,

I have been trying to sync input$timeline_window[[1]] , from the timevis, with input$dygraph_date_window[[1]], from the dygraph, and it works, however, when I add a new item on the timevis, the screen start to flickering, like in a loop. Both time ranges have different date format and I think it creates some issues.

I just was wondering if you could help me change the format of the date of the new id with the double click function, without parsing the time but only the date, like the following format:

like this "18 Nov 2015" rather than like this "2015-11-02T17:25:14.620Z"

shinyServer(function(input, output, session) {

output$p_ARIMA_Custom <- renderTimevis({

    config <- list(
        editable = TRUE,
        align = "center",
        orientation = "top",
        snap = NULL,
        margin = list(item = 30, axis = 50),
        onAdd = htmlwidgets::JS('function(item, callback) {
  item.content = "Hello!<br/>" + item.content;
  callback(item);
}'),
        onUpdate = htmlwidgets::JS("function(item, callback) {
   item.content = prompt('Edit items text:', item.content);
if (item.content != null) {
  callback(item); // send back adjusted item
}
else {
  callback(null); // cancel updating the item
}

}"))

    timevis(options = config)) %>%
        setWindow("p_ARIMA_Custom", start = strftime(input$p_ARIMA_date_window[[1]], "%d %b %Y"), end = strftime(input$p_ARIMA_date_window[[2]], "%d %b %Y"))

})

})

daattali commented 3 years ago

timevis can only accept timedate objects in a very specific format ("18 Nov 2015" is a great format for humans but is not computer readable). I'm not an expert in converting time formats, I always just google "r convert time format"

Teolone88 commented 3 years ago

The problem is that I am not good with js. Would be possible to doubleclick to change content (label name) using js?

daattali commented 3 years ago

Technically yes, but that's out of scope for the package. I'm sorry but I do not have the time to help with individual help requests. Your best bet is to ask on online forums or pay for support.

D3SL commented 3 years ago

@Teolone88 If you're doing this in a shiny app would you be able to handle this server side? If you pass input$timeline_window[[1]] back the server and update the reactive data object both widgets are reading I think it will solve your problem. You can include code in the renderSomething({}) function for dygraph to process the data to whatever format you want

Teolone88 commented 3 years ago

Thank you for the heads up. I have actually managed by using some reactive values. However, the app glitch a bit once the input$timeline_window is changed, but still ok for the eye :)

Best, https://about.me/teolopiparo?promo=email_sig&utm_source=product&utm_medium=email_sig&utm_campaign=gmail_api&utm_content=thumb Teo Lo Piparo

Il giorno dom 1 ago 2021 alle ore 10:41 D3SL @.***> ha scritto:

@Teolone88 https://github.com/Teolone88 If you're doing this in a shiny app would you be able to handle this server side? If you pass input$timeline_window[[1]] back the server and update the reactive data object both widgets are reading I think it will solve your problem. You can include code in the renderSomething({}) function for dygraph to process the data to whatever format you want

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/daattali/timevis/issues/111#issuecomment-890477635, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIZV5FYODJVCXZDYARGUK33T2UCENANCNFSM4YM6BLZA .