At least some legend properties go missing when rendered in Shiny
The well known problem of legends rendering on top of eachother can be fixed by setting at least one of the legends' properties, like
mtcars %>%
ggvis(x = ~wt, y = ~mpg, fill = ~gear, shape = ~as.factor(cyl) ) %>%
layer_points() %>%
add_legend("fill", properties = legend_props(legend = list(y = 150))) %>%
add_legend("shape", properties = legend_props(legend = list(y = 50)))
Which renders fine:

But when you render the same object in a Shiny the legends start in the correct positions, then whisk back up to the top right corner on top of eachother: https://peteratmbie.shinyapps.io/legend_props_eg/
Can you supply the source for your shiny app?
Sorry
https://github.com/nz-mbie/mbie-shiny-basic-egs/tree/master/legend_props_eg
or, for better convenience, pasted in here:
library(ggvis)
library(shiny)
server <- function(input, output) {
mtcars %>%
ggvis(x = ~wt, y = ~mpg, fill = ~gear, shape = ~as.factor(cyl) ) %>%
layer_points() %>%
add_legend("fill", properties = legend_props(legend = list(y = 150))) %>%
add_legend("shape", properties = legend_props(legend = list(y = 50))) %>%
bind_shiny("LegendProb")
}
ui <- shinyUI(fixedPage(
# Application title
titlePanel("Legend properties go missing"),
ggvisOutput("LegendProb"),
p("The legends are displaced (y = 50 and y = 150) in a straight R session, but
when rendered in Shiny they move both back up to the top right corner.")
)
)
shinyApp(ui = ui, server = server)
...
Sent from my HTC
----- Reply message -----
From: "Winston Chang" <[email protected]>
To: "rstudio/ggvis" <[email protected]>
Cc: "Peter Ellis" <[email protected]>
Subject: [ggvis] At least some legend properties go missing when rendered in Shiny (#347)
Date: Thu, Jan 22, 2015 9:43 AM
Can you supply the source for your shiny app?
—
Reply to this email directly or view it on GitHub.
Brief workaround that at least works on my system: add "set_options(duration=0) %>%" as follows
.... add_legend("fill", properties = legend_props(legend = list(y = 150))) %>% add_legend("shape", properties = legend_props(legend = list(y = 50))) %>%
set_options(duration = 0) %>%
bind_shiny("LegendProb") } ...
I experience the same behavior with multiple legends.