-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Description
plot_click (shiny) now cannot get exact data coordinates
(I think this is not a shiny bug?)
Description
After updating to latest version of ggplot2_4.0.0, Shiny's plot_click no longer returns the coordinates relative to the data panel. Instead, the click positions (input$plot_click$x and input$plot_click$y) are normalized to the entire plot area (?). This breaks applications that rely on precise data coordinates from plot_click.
Reproduce
library(shiny)
library(ggplot2)
ui <- fluidPage(
plotOutput("plot", click = "plot_click"),
verbatimTextOutput("click_info")
)
server <- function(input, output, session) {
df <- data.frame(x = 1:10, y = 1:10)
output$plot <- renderPlot({
ggplot(df, aes(x, y)) +
geom_point()
})
output$click_info <- renderPrint({
input$plot_click
})
}
shinyApp(ui, server)- Run the app.
- Click a point in the plot.
- Observe that
input$plot_click$xandinput$plot_click$yare between 0 and 1, not the actual data coordinates.
Session Info
> sessionInfo()
R version 4.4.0 (2024-04-24)
Platform: x86_64-apple-darwin20
Running under: macOS 15.7.2
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.4-x86_64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.0
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
time zone: Asia/Shanghai
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets
[6] methods base
other attached packages:
[1] tidyr_1.3.1 igraph_2.1.4
[3] tidygraph_1.3.1 ggraph_2.2.1
[5] svglite_2.1.3 ggplot2_4.0.0
[7] dplyr_1.1.4 readr_2.1.5
[9] shinydashboard_0.7.2 shiny_1.10.0
loaded via a namespace (and not attached):
[1] viridis_0.6.5 sass_0.4.9
[3] generics_0.1.3 hms_1.1.3
[5] digest_0.6.37 magrittr_2.0.3
[7] grid_4.4.0 RColorBrewer_1.1-3
[9] fastmap_1.2.0 jsonlite_1.8.9
[11] ggrepel_0.9.6 gridExtra_2.3
[13] promises_1.3.2 purrr_1.0.2
[15] viridisLite_0.4.2 scales_1.4.0
[17] tweenr_2.0.3 textshaping_1.0.0
[19] jquerylib_0.1.4 cli_3.6.4
[21] crayon_1.5.3 rlang_1.1.5
[23] graphlayouts_1.2.2 polyclip_1.10-7
[25] bit64_4.6.0-1 withr_3.0.2
[27] cachem_1.1.0 parallel_4.4.0
[29] tools_4.4.0 tzdb_0.4.0
[31] memoise_2.0.1 httpuv_1.6.15
[33] vctrs_0.6.5 R6_2.6.1
[35] mime_0.12 lifecycle_1.0.4
[37] bit_4.5.0.1 vroom_1.6.5
[39] MASS_7.3-60.2 ragg_1.3.3
[41] fontawesome_0.5.3 pkgconfig_2.0.3
[43] bslib_0.8.0 pillar_1.10.2
[45] later_1.4.1 gtable_0.3.6
[47] rsconnect_1.3.4 glue_1.8.0
[49] Rcpp_1.0.14 ggforce_0.4.2
[51] systemfonts_1.2.1 tibble_3.2.1
[53] tidyselect_1.2.1 rstudioapi_0.17.1
[55] farver_2.1.2 xtable_1.8-4
[57] htmltools_0.5.8.1 labeling_0.4.3
[59] compiler_4.4.0 S7_0.2.0 Metadata
Metadata
Assignees
Labels
No labels