How to use correctly iplot of library(ichimoku) in r shiny

Viewed 31

Good evening. I would like to use the ichimiko package for an interactive visualization in r shiny. I would like that every time the user choose a sticker, the graphic can change automatically. When I put the code in the ui interface I get the following error ('cloud not existing').

But if I save the code of the cloud (here stock = "AAPL") before running the shinyApp, the code work Well. I get the graphic but the plot is very great 0

ichimoku(getSymbols("AAPL", src = "yahoo", from=start_date, to=end_date, auto.assign=F))-> cloud

Below is the code.

library(ichimoku)
library(shiny)
library(quantmod)

start_date <- Sys.Date()-365
end_date <- Sys.Date()

ui <- fluidPage("Stock market",
                titlePanel("Stop market App"),
                
                sidebarLayout(
                  sidebarPanel(
  textInput("Stock","Input Stock"),
  selectInput("Stock", label = "Stock :", choices = c("DIA",
                                   "MSFT",
                                   "FB",
                                   "AAPL",
                                   "GOOG"), selected = "AAPL", multiple = FALSE),
  actionButton("GO","GO")),
  mainPanel(br(),
  h2(align = "center", strong("ICHIMOKU CLOUD PLOT")),
  iplot(cloud, width = 1000, height = 1000)
)))

server <- function(input, output, session){
  cs <- new.env()
  data <- eventReactive(input$GO,{
    req(input$Stock)
    getSymbols(input$Stock, src = "yahoo", 
               from=start_date, to=end_date, auto.assign=F)
  })
  
  cloud1 <- reactive({
    dt<- data()
    cloud <- ichimoku(dt)
  })
  cloud <- ichimoku(cloud1(), ticker = input$Stock)
  
}

shinyApp(ui = ui, server = server)

IS it also possible to fix the bslib at the left and down side?

1 Answers

Try to create the "iplot()" object in the server and call it in the ui with plotOutput()?

Related