Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LDAvis clash #77

Closed
Tixierae opened this issue Mar 11, 2019 · 3 comments
Closed

LDAvis clash #77

Tixierae opened this issue Mar 11, 2019 · 3 comments

Comments

@Tixierae
Copy link

Tixierae commented Mar 11, 2019

Just a minor thing: when scatterD3 is used with LDAvis (install.packages("LDAvis")), the symbols disappear from the legend (they still show fine in the plot). In the reproducible example below, commenting out visOutput('ldavis') makes the symbols re-appear in the legend.
I'm comparing ldavis.js to scatterD3-legend.js to see if there is any variable conflict.

library(shiny)
library(LDAvis)
library(scatterD3)

myjson = readChar('https://www.dropbox.com/s/xnraaj2vfn4dnkf/ldavis.json?dl=1', nchars=206627)
mtcars$names = rownames(mtcars)

ui = shinyUI(
  fluidPage(
    fluidRow(
      visOutput('ldavis'),
      br()
    ),
    fluidRow(
      scatterD3Output('scatterd3')
    )
  )
  )
server = shinyServer(function(input, output, session) {
  output$ldavis <- renderVis({
    myjson
  })
  output$scatterd3 = renderScatterD3({
    scatterD3(data = mtcars, x = wt, y = mpg, lab = names,
              col_var = cyl, symbol_var = am,
              xlab = "Weight", ylab = "Mpg", col_lab = "Cylinders",
              symbol_lab = "Manual transmission")
  })
})
shinyApp(ui=ui, server=server)
@Tixierae
Copy link
Author

Tixierae commented Mar 12, 2019

I compared ldavis.js to scatterD3-legend.js, but couldn't identify any conflict. Do you have an idea where the problem could come from? Even if you don't have time to fix it, that would save me a lot of time, and maybe I could try to fix it myself :)

@juba
Copy link
Owner

juba commented Mar 12, 2019

Yep, that was not a JavaScript but a CSS conflict. LDAvis includes the following rule :

path {
   fill: none;
   stroke: none;
}

which will apply to all path SVG elements and remove their drawing and fill color. That's why symbols in legend are invisible.

A fix is to add a custom CSS rule in your shiny app, for example with this code in your UI definition :

    tags$style(HTML("
      .symbol-legend path {
        fill: #000000;
      }
    ")),

But it would be better for LDAvis not to include such a general CSS rule. Maybe you could open an issue there ?

@Tixierae
Copy link
Author

Tixierae commented Mar 12, 2019

Thanks for the very fast answer as always! I've filed an issue there: cpsievert/LDAvis#96

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants