Dun*_*can 5 r ggplot2 shiny plotly r-plotly
我正在制作一个闪亮的仪表板应用程序。仪表板中的选项卡之一用于我的 Plotly 绘图。我能够很好地显示绘图,但是每当我将鼠标光标放在绘图上超过一秒时,就会出现一个巨大的工具提示,其长度与显示器一样长,显示的数据与我的数据一样多。能适应。这不是 Plotly 内置悬停文本的一部分,这实际上很有用。这就像当您将鼠标悬停在网络上的某些内容上时显示的工具提示。
显然这是不可接受的。特别是因为这个巨大的工具提示需要一秒钟或更长时间才能加载,所以它会让一切陷入困境。我该如何关闭此功能?这很烦人而且一点用处也没有。我认为解决方案与 JS 或 HTML 相关,但我不确定。任何帮助将不胜感激。提前致谢。
编辑:这是情节调用。我使用 ggplotly 是因为我比plotly更熟悉使用 ggplot 自定义绘图。
library(plotly)
plot <- ggplot(mydata) + geom_ribbon(aes(ymin = obsAcc25, ymax = obsAcc97, x = x), fill = "cadetblue3", alpha = 0.8)
+ geom_ribbon(aes(ymin = delAcc25, ymax = delAcc97, x = x), fill = "palegreen3", alpha = 0.8)
+ geom_ribbon(aes(ymin = actAcc25, ymax = actAcc97, x = x), fill = "dodgerblue4", alpha = 0.8)
+ theme(panel.grid.major = element_line(color = "grey58"), panel.grid.minor = element_line(color = "grey75"))
p <- ggplotly(plot)
Run Code Online (Sandbox Code Playgroud)
正如所建议的,这里是 dput(head(mydata, 10))
structure(list(actAcc25 = c(-12.8684282283388, -12.0304436152616,
-11.3150952252788, -10.6081847586627, -10.0552821849214, -9.55261456431379,
-9.04799817226408, -8.63169310666002, -8.21986707344882, -7.87700068972389
), obsAcc25 = c(-29.2405337619969, -28.8889501014795, -28.504360142198,
-28.1674808122894, -27.8980268120593, -27.5944378874029, -27.2407785909855,
-26.9557048837549, -26.8112580628704, -26.3946724698358), delAcc25 = c(-13.2454526253711,
-12.3943001876792, -11.7223680727026, -11.0627967149018, -10.5171275099291,
-10.0121757711887, -9.55927026173585, -9.15474795930365, -8.7615554644258,
-8.44377029372532), actAcc97 = c(20.5859080152232, 19.5383979476408,
18.5967498955669, 17.9042117055988, 17.1661035121933, 16.5672919339584,
16.0108793011971, 15.4856795165235, 15.0292972125609, 14.5904142938209
), obsAcc97 = c(39.5176394183119, 38.6324722217456, 37.9015992542866,
37.2607649650388, 36.681699119323, 36.1958973938439, 35.6469528390747,
35.336998047658, 34.9088544137054, 34.4801441415), delAcc97 = c(21.0663356298793,
20.103870882492, 19.2051147569388, 18.513845516169, 17.7970734480676,
17.1961361293244, 16.650452469565, 16.1799047501671, 15.7202776795709,
15.2788029123616), x = c(0.4486530314, 0.5103655236, 0.5760397998,
0.6456734834, 0.7192641994, 0.7968095744, 0.8783072362, 0.9637548142,
1.053149939, 1.146490243)), row.names = c(NA, 10L), class = "data.frame")
Run Code Online (Sandbox Code Playgroud)
编辑:这是 sessionInfo() 的输出
R version 3.5.0 (2018-04-23)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] dashboardthemes_1.0.2 plotly_4.7.1 ggplot2_2.2.1 shinydashboard_0.7.0 shiny_1.1.0
loaded via a namespace (and not attached):
[1] Rcpp_0.12.17 pillar_1.2.3 compiler_3.5.0 later_0.7.3 plyr_1.8.4 bindr_0.1.1 shinyjs_1.0 tools_3.5.0
[9] digest_0.6.15 viridisLite_0.3.0 jsonlite_1.5 tibble_1.4.2 gtable_0.2.0 pkgconfig_2.0.1 rlang_0.2.1 crosstalk_1.0.0
[17] yaml_2.1.19 bindrcpp_0.2.2 dplyr_0.7.5 httr_1.3.1 htmlwidgets_1.2 grid_3.5.0 tidyselect_0.2.4 glue_1.2.0
[25] data.table_1.11.4 R6_2.2.2 tidyr_0.8.1 purrr_0.2.5 magrittr_1.5 scales_0.5.0 promises_1.0.1 htmltools_0.3.6
[33] rsconnect_0.8.8 assertthat_0.2.0 mime_0.5 xtable_1.8-2 colorspace_1.3-2 httpuv_1.4.3 labeling_0.3 lazyeval_0.2.1
[41] munsell_0.5.0
Run Code Online (Sandbox Code Playgroud)
在深入研究我闪亮的应用程序的 HTML 后,使用右键单击 -> 检查,我能够看到我的 tabPanel 的标题以某种方式分配为我的全部数据。这就是为什么将光标悬停在它上面会导致它显示如此巨大的工具提示。在摆脱 tabPanel 并将我的绘图放入 tabItem 后,我能够解决问题,删除工具提示。