geom_line() with text mapping and without group mapping doesn't render
Abierto
Nadie ha tomado este issue todavía.
bug
ggplotly
- Lenguaje dominante
- R
- Estrellas
- 2.7k
- Forks
- 641
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
I have a base-barchart plot with working tooltips.
I want to add a line-chart by clicking a radioButton on top of the barchart, also with hovering tooltips, which is not working as I expected.
- When adding a
textargument to the additional line, the line is not showing up, but when I hover over the pot, the labels of the line show. - When uncommenting the
textargument (line 28), the line shows, but no hovering tooltips, as expected. - When removing the
tooltip = "text"from theggplotlycall (line 33), the line and the tooltips shows up, but the formatting is not like I want it to be.

library(shiny)
library(ggplot2)
library(plotly)
dfN <- data.frame(
time_stamp = seq.Date(as.Date("2018-04-01"), as.Date("2018-07-30"), 1),
val = runif(121, 100,1000),
col = "green", stringsAsFactors = F
)
ui <- fluidPage(
br(),br(),
checkboxInput("zus1", value = FALSE, label = HTML("add Line")),
plotlyOutput("plt")
)
server <- function(input, output, session) {
output$plt <- renderPlotly({
key <- highlight_key(dfN)
p <- ggplot() +
geom_col(data = key, aes(x = plotly:::to_milliseconds(time_stamp), y = val, fill=I(col),
text=paste("Datum: ", time_stamp, "<br>")))
if (input$zus1 == TRUE) {
p <- p + geom_line(data = dfN, aes(x = plotly:::to_milliseconds(dfN$time_stamp), y = val
## This text is not showing up, but hovering shows the labels
# , text=paste("Value: ", val)
), color="red")
}
## Removing tooltip = "text" shows the additional line and hover-labels but with horrible formatting.
ggplotly(p, source = "Src") %>%
highlight(selectize=F, on="plotly_click", off = "plotly_doubleclick", color = "blue") %>%
layout(xaxis = list(tickval = NULL, ticktext = NULL, type = "date"))
})
}
shinyApp(ui, server)
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza con el ejemplo de Shiny proporcionado, centrándote en el mapeo de texto de geom_line y en la llamada a ggplotly(p) con tooltip="text". Reproduce el caso en el que la línea está oculta pero sus etiquetas aparecen, y determina después qué comportamiento hace que la línea y los tooltips de hover correctamente formateados se rendericen juntos.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- r
- Área
- data-visualization
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100