0
我有一個閃亮的應用程序與時間序列和懸停事件的圖形輸出當前懸停的價值的日期和價值。奇怪的是,它輸出的日期格式,我不能把我的手指。例如2013-05-03
變成1.369267e+12
。有人可以解釋這個嗎?閃亮的懸停 - 奇怪的日期格式
這裏有一個工作示例:
ui.r
shinyUI(fluidPage(
sidebarLayout(
position = "left",
sidebarPanel(
selectizeInput("fund", label = NULL, selected = "", choices = c('', LETTERS[1:6]), options = list(placeholder = "Choose something"), width = "350px"),
verbatimTextOutput("hover")
),
mainPanel(
plotlyOutput("tsplot")
)
)
))
server.r
require(shiny)
require(ggplot2)
require(plotly)
shinyServer(function(input, output) {
PFobj <- reactive({
pf <- input$fund
ts_info <- list(a = "x", b = "y")
ts_data <- data.frame(Dat = seq(Sys.Date() - 200, Sys.Date(), 1), Val = cumsum(c(100, rnorm(200))))
list(pf = pf, nav = ts_info, data = ts_data)
})
observe({
if(input$fund != '') {
output$tsplot <- renderPlotly({
p <- ggplot(PFobj()$data, aes(x = Dat, y = Val, group = 1, text = paste("</br>Date: ", Dat, "</br>Value: ", Val))) +
geom_line(colour = "red")
ggplotly(p, tooltip = c("text"))
})
}
})
output$hover <- renderPrint({
d <- event_data("plotly_hover")
if (!is.null(d)) {cat(d$x, d$y); b <<- d$x}
})
})
'verbatimTextOutput(「hover」)'「字段是否也輸出正確? – sedsiv
哈哈,哦對。我剛剛截圖並沒有看到輸出。是的,它被擰了。我的錯 –