Sorry for not provided data. i have added data in this code.
library(shiny)
library(shinydashboard)
library(highcharter)
library(tidyverse)
library(RMySQL)
library(shinyWidgets)
library(reprex)
reconstruct<-structure(list(YYYY = c(2018L, 2018L, 2018L, 2018L, 2018L, 2018L,
2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2019L, 2019L, 2019L,
2019L, 2019L, 2019L, 2019L, 2019L, 2019L, 2019L, 2019L, 2019L,
2020L, 2020L, 2020L, 2020L, 2020L, 2020L, 2020L, 2020L, 2020L,
2020L, 2020L, 2020L), MMM = c("January", "February", "March",
"April", "May", "June", "July", "August", "September", "October",
"November", "December", "January", "February", "March", "April",
"May", "June", "July", "August", "September", "October", "November",
"December", "January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"
), Count = c(0L, 0L, 0L, 15L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 12L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 10L, 0L, 0L, 0L, 0L, 0L), c_year = c("C 2018", "C 2018",
"C 2018", "C 2018", "C 2018", "C 2018", "C 2018", "C 2018", "C 2018",
"C 2018", "C 2018", "C 2018", "C 2019", "C 2019", "C 2019", "C 2019",
"C 2019", "C 2019", "C 2019", "C 2019", "C 2019", "C 2019", "C 2019",
"C 2019", "C 2020", "C 2020", "C 2020", "C 2020", "C 2020", "C 2020",
"C 2020", "C 2020", "C 2020", "C 2020", "C 2020", "C 2020")), class = "data.frame", row.names = c(NA,
-36L))
OpenPositiondb<-data.frame(reconstruct)
Last_Year <- as.integer(format(Sys.Date(), "%Y"))
Last_Year <- Last_Year - 1
ui <-
dashboardPage(
dashboardHeader(
title = HTML("Analytic view - Recruitment"),
titleWidth = 280
),
dashboardSidebar(disable = TRUE),
dashboardBody(fluidPage(fluidRow(
box(
title = fluidRow(
column(10, align = "left", "Open Positions"),
column(
2,
align = "right",
div(
style = "display: inline-block;padding-left:190px;color:black;",
dropdown(
# tags$h5("List of Input"),
sliderTextInput(
inputId = "Positions",
label = "Years",
grid = TRUE,
force_edges = TRUE,
choices = unique(OpenPositiondb$YYYY),
selected = c(Last_Year, as.integer(format(Sys.Date(
), "%Y"))),
),
selectInput(
"Open_PositionsThemes",
label = "Themes",
choices = c("Theme1", "Theme2"),
selected = 1
),
tags$head(tags$style(
HTML(
".selectize-input {height: 10px;wigth: 10px;font-size: 15px;text-align:left;}"
)
)),
tags$head(tags$style(
HTML(
".selectize-dropdown-content {font-size: 15px;text-align:left; }"
)
)),
tags$style(".fa-gear {color:black}"),
style = "simple",
icon = icon("gear"),
size = "md",
right = T,
status = "default",
width = "150px",
align = "left",
animate = animateOptions(
enter = animations$fading_entrances$fadeInLeftBig,
exit = animations$fading_exits$fadeOutRightBig
)
)
)
),
),
solidHeader = T,
width = 6,
collapsible = T,
highchartOutput("Open_Positions", height = "240px")
)
)))
)
server <- function(input, output, session) {
output$Open_Positions <- renderHighchart({
Theme1 <- c("#a35d6a", "#c26565", "#68b0ab", "#8fc0a9", "#c8d5b9")
Theme2 <- c("#b9ac92", "#ffa931", "#fecb89", "#ffa36c", "#fbe6d4")
gapminder <- data.frame(OpenPositiondb)
gapminder2007 <- gapminder
gapminder_column <- gapminder2007 %>%
filter(YYYY %in% input$Positions) %>%
group_by(YYYY) %>%
summarise(Count = sum(Count))
#gapminder_column$YYYY<-as.character(gapminder_column$YYYY)
gapminder_drilldown <- gapminder2007 %>%
group_nest(YYYY) %>%
mutate(
id = YYYY,
type = "column",
# in the drilldown we'll give the mapping via creating the columns
data = map(data, mutate, name = MMM, y = Count),
data = map(data, list_parse)
)
x <- c("Open Position : ")
y <- c("{point.Count}")
tt <- tooltip_table(x, y)
if (input$Open_PositionsThemes == "Theme1")
{
hchart(
gapminder_column,
"column",
hcaes(
x = YYYY,
y = Count,
drilldown = YYYY
),
name = "Year wise",
colorByPoint = TRUE
) %>%
hc_drilldown(allowPointDrilldown = TRUE,
series = list_parse(gapminder_drilldown)) %>%
hc_tooltip(
pointFormat = tt,
# "{point.name} {point.pop}"
useHTML = TRUE,
valueDecimals = 0
) %>%
hc_yAxis(
title = list(text = "Open positions"),
type = "logarithmic",
minorTickInterval = 'auto'
) %>%
hc_xAxis(title = "") %>%
hc_exporting(enabled = TRUE, filename = "Open-Positions") %>%
hc_colors(Theme1)
}
else
{
hchart(
gapminder_column,
"column",
hcaes(
x = YYYY,
y = Count,
drilldown = YYYY
),
name = "Year wise",
colorByPoint = TRUE
) %>%
hc_drilldown(allowPointDrilldown = TRUE,
series = list_parse(gapminder_drilldown)) %>%
hc_tooltip(
pointFormat = tt,
# "{point.name} {point.pop}"
useHTML = TRUE,
valueDecimals = 0
) %>%
hc_yAxis(
title = list(text = "Open positions"),
type = "logarithmic",
minorTickInterval = 'auto'
) %>%
hc_xAxis(title = "") %>%
hc_exporting(enabled = TRUE, filename = "Open-Positions") %>%
hc_colors(Theme2)
}
})
}
shinyApp(ui, server)