I have the following code and it's set up so that any rows with allocated$time "future" have an alpha of 0.6 and any with an allocated$time "past" have an alpha of 1. This allows values in my geom_bar to show as slightly transparent on my "future" data, and completely solid on my "past" data.
However my issue is that when my input$date_range is between two dates in the past, all of my geom_bars are now at an alpha of 0.6 (the code is not assigning specific alpha values to specific $time values, which is what I want).
I tried creating a new $alpha column with specific integers to be used as alpha values however it just made my "future" data extremely opaque and I'm not sure why...
allocated <- Project Date value time
A 2017-05-15 4 past
B 2017-06-18 8 past
C 2017-07-25 3 past
D 2017-08-20 9 future
E 2017-09-14 4 future
ui <- dashboardPage(
dashboardSidebar(
sidebarMenu(
menuItem(
dateRangeInput('date_range', label = "Date Range",format = "mm/dd/yyyy", start = Sys.Date()-17, end = Sys.Date()+17, startview = "month", weekstart = 0, separator = " to ", width = 200)
)
)
),
fluidRow(
box(plotOutput("plot1", width = 1000, height = 500))
)
)
server <- function(input, output) {
output$plot1 <- renderPlot({
date_data <- reactive({
subset(allocated, variable >= input$date_range[1] & variable <= input$date_range[2], value != 0)
})
ggplot(data = date_data(), aes(x = variable, y = value, alpha = time, fill = Project)) +
geom_bar(stat = 'identity') +
scale_alpha_discrete(range = c(0.6, 1), guide = 'none')
})
}
shinyApp(ui, server)