Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

Arc resizing doesn't seem to be working. #475

Open
AndrewSkelton opened this issue Sep 14, 2017 · 0 comments
Open

Arc resizing doesn't seem to be working. #475

AndrewSkelton opened this issue Sep 14, 2017 · 0 comments

Comments

@AndrewSkelton
Copy link

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")
  }
)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant