I have got some clue from this link: 17 Server-side linking with shiny | Interactive web-based data visualization with R, plotly, and shiny
library(shiny)
library(plotly)
ui <- fluidPage(
selectizeInput(
inputId = "cities",
label = "Select a city",
choices = unique(txhousing$city),
selected = "Abilene",
multiple = TRUE
),
plotlyOutput(outputId = "p")
)
server <- function(input, output, ...) {
output$p <- renderPlotly({
plot_ly(txhousing, x = ~date, y = ~median) %>%
filter(city %in% input$cities) %>%
group_by(city) %>%
add_lines()
})
}
shinyApp(ui, server)
But I would like to further enhance it by:
adding different colors to the plots, such that the color of the plot would the same as the color of the words highlighted in the "Select a City", is it possible? so that we know which plot belongs to which city..
any help would be greatly appreciated.
Thanks.