R/set_pointrange_grob.R

Defines functions set_pointrange_grob

set_pointrange_grob <- function(loon.grob, pointsTreeName, glyphNames,
                                showArea, color, whichIsDeactive) {

  newGrob <- grid::getGrob(loon.grob, pointsTreeName)

  active <- setdiff(which(grepl(glyphNames, pattern = "pointrange")), whichIsDeactive)

  if(length(active) > 0) {

    lapply(active,
           function(i) {

             grobi <- newGrob$children[[i]]

             pointGrob <- grid::getGrob(grobi, "point")
             gp <- pointGrob$gp

             if(showArea) {

               pointGrob$pch <- 1
               gp$col <- color[i]
               gp$fill <- NA

             } else {

               pointGrob$pch <- 21
               gp$fill <- color[i]
               gp$col <- bounder_color()

             }

             newGrob$children[[i]] <<- grid::setGrob(
               gTree = grobi,
               gPath = "point",
               newGrob = grid::editGrob(
                 grob = pointGrob,
                 gp = gp
               )
             )
           }
    )

  } else NULL

  grid::setGrob(
    gTree = loon.grob,
    gPath = pointsTreeName,
    newGrob = newGrob
  )
}

Try the loon.shiny package in your browser

Any scripts or data that you put into this service are public.

loon.shiny documentation built on Oct. 8, 2022, 5:05 p.m.