R/criteriaPlot.R

#' Criteria Plot
#'
#' Generate a treemap of selected criteria
#'
#' @param criteria
#'
#' @return A d3 treemap javascript widget
criteriaPlot <- function(criteria){
  d3tm::renderZtm({

    if("Category" %in% names(criteria$static)){
      df <- criteria$static %>%
        dplyr::filter(`Pass/Fail` == FALSE) %>%
        dplyr::select("Category", "Description", "Weight")
      helptext <- " - Click on a Square to Zoom"

    } else{
      df <- criteria$static %>%
        dplyr::filter(`Pass/Fail` == FALSE) %>%
        dplyr::select("Description", "Weight")
      helptext <- ""
    }

    df_nest <- d3tm::d3_nest2(df, value_col = "Weight", root = "Criteria Weightings")

    d3tm::ztm(df_nest,
              background = "rgb(202,208,214)",
              header_background = "rgb(79,33,58)",
              tooltip_background = "rgb(228, 231, 234)",
              zoom_in_helptext = helptext)
  })
}
lajh87/tessa documentation built on July 6, 2019, 12:06 a.m.