Reproducible example below.
When trying to make layer_arcs, it seems that they don't resize as the window is resized. I'm trying to get it to be scalable, so that when the window is expanded, so is the arc. I've tried adjustments to the innerRadius and outerRadius, making them to scale (:=), or in pixels (=), but it doesn't seem to work. Am I missing something obvious, or is this a potential bug?
library(shiny)
library(ggvis)
library(tidyverse)
shinyApp(
ui = bootstrapPage(
div(style = "width:800px; height:800px; background: #ffffff;",
ggvisOutput("p"),
uiOutput("p_ui")
)
),
server = function(input, output, session) {
window.size <- 800 #Window size in Px
# Data frame of 5 rows, starts and ends in radians, even sizes.
data.in <- data.frame(Items = LETTERS[1:5]) %>%
mutate(size.factor = nrow(.),
end = cumsum((size.factor / sum(as.numeric(size.factor)))),
end = (2*pi)*end/(max(end)),
start = lag(end),
start = ifelse(is.na(start),0,start))
Vis <- reactive({
data.in %>%
ggvis(~0.5,~0.5) %>%
layer_arcs(startAngle = ~start, endAngle = ~end,
innerRadius := (window.size / 2) * 0.8, outerRadius := (window.size / 2) * 0.95,
stroke :="white", fill := "black", fill.hover := "red") %>%
set_options(resizable=TRUE, keep_aspect = TRUE, width = 800, height = 800) %>%
scale_numeric("x", domain = c(0,1)) %>%
scale_numeric("y", domain = c(0,1)) %>%
scale_numeric("radius", domain = c(0.5, 0.5))
})
Vis %>% bind_shiny("p", "p_ui")
}
)
Reproducible example below.
When trying to make layer_arcs, it seems that they don't resize as the window is resized. I'm trying to get it to be scalable, so that when the window is expanded, so is the arc. I've tried adjustments to the innerRadius and outerRadius, making them to scale (:=), or in pixels (=), but it doesn't seem to work. Am I missing something obvious, or is this a potential bug?