-1

I Want to filter data by click on data points of plot in Shiny, like we have in powerbi. i have developed a dashboard in powerbi i want to have a same effect in shiny, like if i click the data point of plot in shiny dashboard the other plots should drill down in response to that point, i have build a complete dashboard in shiny but i need to add these function. there can also be multiple data points drill down like if i want to know the february(datapoint) month sales of John(datapoint).

geekzeus
  • 785
  • 5
  • 14

1 Answers1

1

In the UI, you should add, click,doubleclick or hover:

 plotOutput("plot1", click = "plot_click")

And in the Server will be input$plot_click, X and Y coordinates

Here a Shiny explanation: https://shiny.rstudio.com/articles/plot-interaction.html

And I wrote for you a simple example:

library(shiny)
library(ggplot2)
library(MASS)

ui<- shinyUI(
       fluidPage(
                plotOutput("grafica", hover="clickGrafica"),    
                tableOutput("miverbatini")                      
        )
)
server<- shinyServer(function(input,output) {

        output$grafica <- renderPlot({

                ggplot(mpg,aes(x=cty, y=hwy)) +   
                        geom_point()
        })

        output$miverbatini <- renderTable({  
                nearPoints(mpg,input$clickGrafica, threshold = 10)  # near points 20  
        })
})
shinyApp(ui, server)
  • thanks for the response, but this is not what i am looking for.,please have a look at powerbi app that i have provided.I need to change the other plots in response to the data points of plot i have clicked. – geekzeus Oct 30 '18 at 09:50
  • This is the boilerplate you need. Probably you want to make reactive the data in the other plots and then observeEvent changes in input$clickGrafica – Carlos Vecina Tebar Oct 30 '18 at 10:24