jeudi 9 février 2017

R zoomChart Shiny

Vote count: 0

i've been trying to interactively zoom in certain parts of a chartSeries with zoomChart and shiny, but can't find the right solution. I would use dateRangeInput or a slider, but i'm not sure how to connect the zoomChart-option from quantmod with shiny. As you might have already assumed, I#m relatively new to shiny and very thankful for your advices!

MyCode:

library(quantmod)
library(shiny)
date_range <- as.POSIXct(index(data))
if (interactive()) {
  options(device.ask.default = FALSE)
  ui <- fluidPage(  
    titlePanel("Select Range to zoom-in:"),
    sidebarLayout(
      sidebarPanel(
        dateRangeInput("Range", "Choose Date Range:", min=first(date_range),
                   max=last(date_range), format = "dd-mm-yyyy")
      ),
      mainPanel(
        plotOutput("Plot")
      )
    )
  )
  server <- function(input, output) {
    output$Plot <- renderPlot({
      chartSeries(data, type = c("auto", "candlesticks", "matchsticks",   "bars","line"), 
              theme=chartTheme("white"), name=paste(start(data), end(data),sep = " ")) 
      zoomChart(dateRangeInput) 
    })
  }
   shinyApp(ui, server)
}

asked 17 secs ago

Let's block ads! (Why?)



R zoomChart Shiny

Aucun commentaire:

Enregistrer un commentaire