rdrr-io / rdrr-issues

rdrr.io issues
34 stars 7 forks source link

How to render iplot for each selected stock in r shiny app reactivity? #97

Closed Fredysessie closed 2 years ago

Fredysessie commented 2 years ago

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 before running the shinyApp, the code work Well. I get the graphic but the plot IS very great

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?
ihowson commented 2 years ago

Thanks for getting in touch!

This issue tracker is just for website issues. We're not able to provide technical support for individual packages. Sorry!