วิธีที่ระบบนี้ทำงาน (app.R — โค้ดจริงที่ส่งมอบ)
library(shiny) library(bslib) library(plotly) library(DBI)
# ดึงข้อมูลจาก cloud
data <- dbGetQuery(con, "SELECT * FROM sales WHERE date >= ?", params)
# UI + Server
ui <- page_sidebar(sidebar = sidebar(selectInput("region", ...)),
card(plotlyOutput("sales_trend")), card(tableOutput("top_branches")))
server <- function(input, output, session) {
output$sales_trend <- renderPlotly({ ggplotly(ggplot(data, aes(month, revenue)) + geom_col()) })
}
shinyApp(ui, server)