plotly / plotly/plotly.R

geom_line() with text mapping and without group mapping doesn't render

Ouverte
#1,371 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

bug ggplotly
Langage dominant
R
Étoiles
2.7k
Forks
641
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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.

  1. When adding a text argument to the additional line, the line is not showing up, but when I hover over the pot, the labels of the line show.
  2. When uncommenting the text argument (line 28), the line shows, but no hovering tooltips, as expected.
  3. When removing the tooltip = "text" from the ggplotly call (line 33), the line and the tooltips shows up, but the formatting is not like I want it to be.

1 - kopie

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)

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par l’exemple Shiny fourni, en vous concentrant sur le mappage du texte de geom_line et sur l’appel ggplotly(p) avec tooltip="text". Reproduisez le cas où la ligne est masquée mais où ses libellés apparaissent, puis déterminez quel comportement permet de rendre simultanément la ligne et des info-bulles de survol correctement formatées.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
r
Domaine
data-visualization
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.