You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
168 lines
5.9 KiB
168 lines
5.9 KiB
|
|
revplotUI<- function(id,filtervalues){
|
|
ns<- NS(id)
|
|
tagList(
|
|
fluidRow(
|
|
# Add to select inputs side by side
|
|
column(width = 3,
|
|
selectizeInput(inputId = ns("geo"), label="Select Geography", choices= c("Aruba","Bonair","Poland",
|
|
"Curacao", "Netherlands"),
|
|
selected=c("Aruba","Bonair","Poland",
|
|
"Curacao", "Netherlands"), multiple=T)),
|
|
column(width = 3,
|
|
selectizeInput(inputId = ns("role"), label="Select Role", choices= c("Customer","Customer - Influencer","Poland",
|
|
"Financer", "Influencer"),
|
|
c("Customer","Customer - Influencer","Poland",
|
|
"Financer", "Influencer"), multiple=T)),
|
|
column(width = 6,
|
|
shinycssloaders::withSpinner(valueBoxOutput(ns("selfinfo"))),
|
|
shinycssloaders::withSpinner(valueBoxOutput(ns("othinfo"))),
|
|
shinycssloaders::withSpinner(valueBoxOutput(ns("totinfo"))),
|
|
)
|
|
),
|
|
fluidRow(
|
|
column(width = 4,
|
|
shinycssloaders::withSpinner(highchartOutput(ns("revselfbar")) , image = "https://media.giphy.com/media/RLsct1jsRVsVFupW7a/giphy.gif", image.height ="200px",hide.ui = T)
|
|
),
|
|
column(width = 4,
|
|
shinycssloaders::withSpinner(highchartOutput(ns("revothbar")) , image = "https://media.giphy.com/media/RLsct1jsRVsVFupW7a/giphy.gif", image.height ="200px",hide.ui = T)
|
|
),
|
|
column(width = 4,
|
|
shinycssloaders::withSpinner(highchartOutput(ns("revtotbar")) , image = "https://media.giphy.com/media/RLsct1jsRVsVFupW7a/giphy.gif", image.height ="200px",hide.ui = T)
|
|
)
|
|
)
|
|
)
|
|
}
|
|
|
|
revplotServer<- function(id, df, xtitle="", ytitle=""){
|
|
moduleServer(
|
|
id,
|
|
function(input, output, session){
|
|
|
|
sel.geo<-reactive({
|
|
print(input$geo)
|
|
input$geo
|
|
})
|
|
sel.role<-reactive({
|
|
print(input$role)
|
|
input$role
|
|
})
|
|
summarized.df <- reactive(summarizer(df, sel.geo(), sel.role(), self=TRUE))
|
|
summarized.df.oth <- reactive(summarizer(df, sel.geo(), sel.role(), self=FALSE))
|
|
output$revselfbar<- renderHighchart({
|
|
print(summarized.df())
|
|
hchart(summarized.df(),
|
|
"column",
|
|
hcaes(x=Year,y=Revenue)) |>
|
|
hc_title(text="Revenue from self purchase") |>
|
|
# hc_yAxis(title = list(text = ytitle)) |>
|
|
#hc_plotOptions(column = list(stacking = "normal")) |>
|
|
hc_tooltip(shared = TRUE, valueDecimals = 0) |>
|
|
#hc_brush(enabled = TRUE) |>
|
|
hc_credits(enabled = FALSE) |>
|
|
hc_exporting(enabled = TRUE)
|
|
|
|
}
|
|
)
|
|
|
|
output$revothbar<- renderHighchart({
|
|
print(summarized.df.oth())
|
|
hchart(summarized.df.oth(),
|
|
"column",
|
|
hcaes(x=Year,y=Revenue)) |>
|
|
hc_title(text="Revenue from purchase by influencer") |>
|
|
# hc_yAxis(title = list(text = ytitle)) |>
|
|
#hc_plotOptions(column = list(stacking = "normal")) |>
|
|
hc_tooltip(shared = TRUE, valueDecimals = 0) |>
|
|
#hc_brush(enabled = TRUE) |>
|
|
hc_credits(enabled = FALSE) |>
|
|
hc_exporting(enabled = TRUE)
|
|
|
|
}
|
|
)
|
|
|
|
output$revtotbar<- renderHighchart({
|
|
summarized.df.tot<-df |>
|
|
filter(Location %in% sel.geo()) |>
|
|
filter(Role %in% sel.role()) |>
|
|
summarize(yr.1=sum(Self.Purchase1)+sum(Other.Purchase1),
|
|
yr.2=sum(Self.Purchase2)+sum(Other.Purchase2),
|
|
yr.3=sum(Self.Purchase3)+sum(Other.Purchase3)
|
|
) |>
|
|
pivot_longer(c(yr.1,yr.2,yr.3)) |>
|
|
rename(Year=name, Revenue=value)
|
|
hchart(summarized.df.tot,
|
|
"column",
|
|
hcaes(x=Year,y=Revenue)) |>
|
|
hc_title(text="Total Revenue") |>
|
|
# hc_yAxis(title = list(text = ytitle)) |>
|
|
#hc_plotOptions(column = list(stacking = "normal")) |>
|
|
hc_tooltip(shared = TRUE, valueDecimals = 0) |>
|
|
#hc_brush(enabled = TRUE) |>
|
|
hc_credits(enabled = FALSE) |>
|
|
hc_exporting(enabled = TRUE)
|
|
|
|
}
|
|
)
|
|
|
|
|
|
selfinfo.df<- reactive({
|
|
snapshot(df, sel.geo(), sel.role(), item="self")
|
|
})
|
|
|
|
otherinfo.df<- reactive({
|
|
snapshot(df, sel.geo(), sel.role(), item="other")
|
|
})
|
|
|
|
totalinfo.df<- reactive({
|
|
snapshot(df, sel.geo(), sel.role(), item="total")
|
|
})
|
|
|
|
output$selfinfo<- renderValueBox({
|
|
delta<-round((selfinfo.df()$current.year-selfinfo.df()$last.year)*100/selfinfo.df()$last.year)
|
|
if(delta<0){
|
|
icon<-icon("arrow-down")
|
|
} else {
|
|
icon<-icon("arrow-up")
|
|
}
|
|
valueBox(
|
|
value = paste0(delta," %"),
|
|
subtitle = "Self",
|
|
icon = icon,
|
|
color = ifelse(delta>0, "green", "red")
|
|
)
|
|
})
|
|
|
|
output$othinfo<- renderValueBox({
|
|
delta<-round((otherinfo.df()$current.year-otherinfo.df()$last.year)*100/otherinfo.df()$last.year)
|
|
if(delta<0){
|
|
icon<-icon("arrow-down")
|
|
} else {
|
|
icon<-icon("arrow-up")
|
|
}
|
|
valueBox(
|
|
value = paste0(delta," %"),
|
|
subtitle = "Other",
|
|
icon = icon,
|
|
color = ifelse(delta>0, "green", "red")
|
|
)
|
|
})
|
|
|
|
output$totinfo<- renderValueBox({
|
|
delta<-round((totalinfo.df()$current.year-totalinfo.df()$last.year)*100/totalinfo.df()$last.year)
|
|
if(delta<0){
|
|
icon<-icon("arrow-down")
|
|
} else {
|
|
icon<-icon("arrow-up")
|
|
}
|
|
valueBox(
|
|
value = paste0(delta," %"),
|
|
subtitle = "Total",
|
|
icon = icon,
|
|
color = ifelse(delta>0, "green", "red")
|
|
)
|
|
})
|
|
|
|
}
|
|
)
|
|
}
|