Hi
I need to change the appearance of dygraph legend dependent on input checkbox which switches highlighting on/off:
if highlighting off, legend of all series should appear, if highlighting on, only the selected (highlighted) value should appear in the legend.
I tried to achieve this by the method shown in the example code below, but it does not work.
(The idea is to apply the dyCSS to the dygraph only if the inputcheckbox has the value "True")
How can I solve this?
woec
library(shiny)
library(dygraphs)
lungDeaths <- cbind(ldeaths, mdeaths, fdeaths)
ui <- fluidPage(
checkboxInput("hL","Highlight",value = F),
br(),br(),
dygraphOutput("dg")
)
server <- function(input,output,session){
output$dg <- renderDygraph({
g <- dygraph(lungDeaths, main = "Deaths from Lung Disease (UK)")
if(input$hL) {
g <- g %>% dyHighlight() %>% dyCSS(textConnection("
.dygraph-legend > span { display: none; }
.dygraph-legend > span.highlight { display: inline; }
"))
}
g
})
}
shinyApp(ui,server)