taucharts icon indicating copy to clipboard operation
taucharts copied to clipboard

add support for returning legend items

Open Tutuchan opened this issue 7 years ago • 0 comments

Hello,

I added some code so we can retrieve the value of the legend item after a click event. The Shiny input is the input specified in tauchart() with -legend added at the end (e.g. tauchart(inputId = "test") yields input[["test-legend"]]).

Please, let me know if you feel this is useful.

Some code to test:

library(shiny)
library(taucharts)

ui <- fluidPage(
  titlePanel("Hello Shiny!"),
  sidebarLayout(
    sidebarPanel(),
    mainPanel(
      tauchartsOutput(outputId = "tc"),
      h2("Selected"),
      textOutput(outputId = "leg")
    )
  )
)

server <- function(input, output) {

  output$tc <- renderTaucharts({
    tauchart(iris, inputId = "iris") %>%
      tau_point(x = "Petal.Width", y = "Sepal.Width", color = "Species") %>%
      tau_legend()
  })

  output$leg <- renderText(input[["iris-legend"]])
}

shinyApp(ui = ui, server = server)

Tutuchan avatar Jun 07 '18 15:06 Tutuchan