我试图在我闪亮的应用程序中使用plotly交互式视觉效果.但是,在尝试向图表添加自定义工具提示时遇到问题.如果我设置tooltip参数ggplotly()然后geom_line()我的输出中忽略了我的工具提示工作.
这是一个MRE:
library(shiny)
library(ggplot2)
library(plotly)
library(tidyquant) #only using the palette_dark() function
library(magrittr)
graph <- data %>%
ggplot(aes(date, result, text = paste0("Site: ", site, "\n",
"Quarter: ", quarter, "\n",
"Year: ", year, "\n",
"Result: ", result))) +
facet_wrap(~site) +
geom_point(color = palette_dark()[1]) +
geom_line(color = palette_dark()[1]) +
theme_bw()
ggplotly(graph,
tooltip = "text")
Run Code Online (Sandbox Code Playgroud)
如果我移动data =,并aes()呼吁从ggplot调用个人geom当时的线条仍然没有显示:
graph <- ggplot() +
facet_wrap(~site) +
geom_point(data = data,
aes(date, result,
text …Run Code Online (Sandbox Code Playgroud) 我正在制作一个情节,首先在 ggplot 中,然后使其与 ggplotly 交互。
但我需要正确格式化 data.frame 中名为“precio_actual”的当前价格工具提示。
它在工具提示中显示为:1499。
应该是:S/ 1,4900.00。
数据:
dput(tail_tvs)
structure(list(ecommerce = c("wong", "wong", "wong", "wong",
"wong", "wong"), marca = c("sony", "samsung", "sony", "samsung",
"daewoo", "samsung"), producto = c("sony smart tv 55'' 4k uhd kd-55x750f android",
"samsung smart tv curvo 65'' 4k uhd 65nu7300", "sony smart tv 40'' full hd kdl-40w655d linux",
"samsung smart tv 55'' 4k uhd 55mu6103", "daewoo smart tv 43'' full hd l43s780bts",
"samsung …Run Code Online (Sandbox Code Playgroud)