I have created a graph with radiobuttons that should change the graph based on three choices, but only the first (selected choice) shows up, and I can not open the other two choices. Here is the link to the app: https://iurif.shinyapps.io/mtfd/
It is the "Fuel Consumption" graph. Those three icons next to the title should work, one is for downloading the data, and the third one for changing variable options.
Below are my codes:
div(class = "col-xs-12 col-sm-12 col-md-6 col-lg-6",
boxPlus_edited(id= "plotly_box",
width= "100%",
title="Fuel Consumption",
closable = FALSE,
status = "danger",
collapsible = FALSE,
enable_sidebar = TRUE,
sidebar_background = "#7a0019",
sidebar_width = 20,
sidebar_start_open = FALSE,
enable_dropdown = TRUE,
dropdown_icon = "file-alt",
dropdown_menu = boxDropdown(
boxDropdownItem(name= "Source: File T"),
dropdownDivider(),
boxDropdownItem(url= "https://docs.google.com/spreadsheets/d/1wLau3tkAm-bTwOKZpg-73S5UiAx74quo/edit#gid=296023288", name= "Download here.")),
sidebar_content = (
radioButtons("fueltype2", "Select Fuel Type",
choices= c("Total Fuel"= "Tot_fuel_mil",
"Gas"= "Gas_mil",
"Special Fuel"="Spec_fuel_mil"),
selected= "Tot_fuel_mil")
),
plotlyOutput('mt32') %>%
withSpinner(type = 8, color="#7a0019"))
)),
server <- function(input, output) {
output$mt32 <- renderPlotly({
t3 <- t %>%
mutate(
fuelchoice= t[[input$fueltype2]])
ggplotly(
ggplot(t3, aes(x= Year, y= fuelchoice, group= 1, text= paste0("Year: ", Year, "<br>","Gallons (Millions): ", prettyNum(round(fuelchoice, digits = 1), big.mark = ","))))+
geom_line(size=1.5, color= "#1f78b4")+
theme_minimal()+
scale_x_continuous(breaks = c(1988, 1998, 2008, 2018))+
scale_y_continuous(limits=c(0,4000)) +
labs(
x= "",
y= "Millions of Gallons")+
guides(color=guide_legend(override.aes=list(fill=NA)))+
theme(plot.title = element_text(size = 16, hjust= 0.5),
panel.grid.minor = element_blank(),
panel.grid.major = element_line(colour="light grey"),
axis.title.x = element_text(size=20),
axis.text.y = element_text(size=13, color = "black"),
axis.text.x = element_text(size= 13, color = "black"),
axis.title.y= element_text(size=13, color="black"),
legend.key = element_blank())
, tooltip = "text") %>%
style(hoverlabel = list(bgcolor = "white"), hoveron = "fill") %>%
layout(xaxis=list(fixedrange=TRUE)) %>%
layout(yaxis=list(fixedrange=TRUE)) %>%
config(displayModeBar = FALSE)
})
shinyApp(ui = ui, server = server)