Hello,
Please I am trying to put an action button and I want it to wait for the people to complete their choices in the checkboxgroupinput to output the data in the ggplot -> geom_col to make an hist.
For now, when you click the checkboxgroup it refresh automatically, I want it to not refresh and then when the person click on the actionbutton, the plot refresh with the data.
Please someone help me I am going crazy,
Thank you
Code :
library(shiny)
library(dplyr)
library(ggplot2)
library(lubridate)
library(DBI)
library(extrafont)
library(RColorBrewer)
impala <- config::get("ImpalaEDH")
con_im <- dbConnect(odbc::odbc(),
DSN = impala$dsn,
UID = impala$uid,
PWD = stringi::stri_reverse(impala$pwd))
tv <- dbGetQuery(con_im, "select interval_start_dt, channeltitle, cast(events_qty as integer) events_qty from pvranst.orange_tv_app")
ui <- shinyUI(fluidPage(titlePanel("Volume of views by channels over a period of time"),
actionButton("goButton", "Go!"),
checkboxGroupInput("checkgroup","Channels list",
choices =list ("La Une HD",
"La Deux HD",
"La Trois HD",
"RTL TVI HD",
"Club RTL HD",
"TF1 HD",
"AB3 HD",
"13ème Rue HD",
"SyFy HD",
"Disney Channel",
"Disney XD",
"vtm HD",
"Q2 HD",
"één HD",
"Canvas HD",
"VIER HD",
"VIJF HD",
"Discovery Vl HD",
"Nat Geo HD",
"Ketnet",
"Disney VL",
"Vitaya"),
selected = "Ketnet"),
dateRangeInput("daterange", "Choose a date range : ",
start = "2018-09-01",
end = "2018-09-31",
min = "2018-01-01",
max = "2018-12-31",
format = "dd/mm/yy",
separator = " - "),
plotOutput(outputId = "tv", width = "auto", height = "500px", click = NULL,
dblclick = NULL, hover = NULL, hoverDelay = NULL,
hoverDelayType = NULL, brush = NULL, clickId = NULL, hoverId = NULL,
inline = FALSE))
)
server <- function(input, output)
{
eventReactive(input$goButton, ignoreNULL = FALSE {input$checkgroup}),
x<-1:20
y<-x^2
output$tv <- renderPlot({
dist <- isolate(rnorm(input$channeltitle))
checkboxGroupInput(dist)
tv_data <- tv %>%
filter(channeltitle%in%input$checkgroup,
interval_start_dt > input$daterange[1],
interval_start_dt > input$daterange[2])
ggplot(tv_data, aes(x = interval_start_dt, y = events_qty, fill = channeltitle )) +
geom_col() +
geom_text(aes(label=events_qty), vjust=-0.4, color = "white", size=5) +
theme(legend.position="bottom")+
theme_minimal()+
ggtitle("Views by channels")+
theme(plot.title = element_text(size=30,lineheight=.8, face="bold",
margin = margin(10, 0, 10, 0),
vjust=0.5,family="Bauhaus 93"))+
labs(x="Date", y="Vues")+
theme(
axis.title.x = element_text(color="peachpuff4", vjust=-0.35, size = 20),
axis.title.y = element_text(color="peachpuff4" , vjust=0.35, size = 20))+
theme(axis.text.x=element_text(angle=50, size=20, vjust=0.5),
axis.text.y=element_text(angle=360, size=20, vjust=0.5))+
geom_point(color = "white")+
theme(panel.background = element_rect(fill = 'grey75'))+
geom_smooth(aes(fill = "channeltitle"), se = FALSE)
})
}
shinyApp(ui = ui, server = server)