Skip to content

Commit

Permalink
ordering: relocating functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jbkunst committed Aug 31, 2017
1 parent fd85c6d commit baa449d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 48 deletions.
48 changes: 48 additions & 0 deletions R/api-hc-helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -318,3 +318,51 @@ tooltip_chart <- function(
JS(jsss)

}

#' Helper for make table in tooltips
#'
#' Helper to make table in tooltips for the \code{pointFormat}
#' parameter in \code{hc_tooltip}
#'
#' @param x A string vector with description text
#' @param y A string with accessors example: \code{point.series.name},
#' \code{point.x}
#' @param title A title tag with accessors or string
#' @param img Image tag
#' @param ... html attributes for the table element
#'
#' @examples
#'
#' x <- c("Income:", "Genre", "Runtime")
#' y <- c("$ {point.y}", "{point.series.options.extra.genre}",
#' "{point.series.options.extra.runtime}")
#'
#' tooltip_table(x, y)
#'
#' @importFrom purrr map2
#' @importFrom htmltools tags tagList
#' @export
tooltip_table <- function(x, y,
title = NULL,
img = NULL, ...) {

assertthat::assert_that(length(x) == length(y))

tbl <- map2(x, y, function(x, y){
tags$tr(
tags$th(x),
tags$td(y)
)
})

tbl <- tags$table(tbl, ...)

if (!is.null(title))
tbl <- tagList(title, tbl)

if (!is.null(img))
tbl <- tagList(tbl, img)

as.character(tbl)

}
48 changes: 0 additions & 48 deletions R/helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -165,54 +165,6 @@ highcharts_demo <- function() {

}

#' Helper for make table in tooltips
#'
#' Helper to make table in tooltips for the \code{pointFormat}
#' parameter in \code{hc_tooltip}
#'
#' @param x A string vector with description text
#' @param y A string with accessors example: \code{point.series.name},
#' \code{point.x}
#' @param title A title tag with accessors or string
#' @param img Image tag
#' @param ... html attributes for the table element
#'
#' @examples
#'
#' x <- c("Income:", "Genre", "Runtime")
#' y <- c("$ {point.y}", "{point.series.options.extra.genre}",
#' "{point.series.options.extra.runtime}")
#'
#' tooltip_table(x, y)
#'
#' @importFrom purrr map2
#' @importFrom htmltools tags tagList
#' @export
tooltip_table <- function(x, y,
title = NULL,
img = NULL, ...) {

assertthat::assert_that(length(x) == length(y))

tbl <- map2(x, y, function(x, y){
tags$tr(
tags$th(x),
tags$td(y)
)
})

tbl <- tags$table(tbl, ...)

if (!is.null(title))
tbl <- tagList(title, tbl)

if (!is.null(img))
tbl <- tagList(tbl, img)

as.character(tbl)

}

#' Create vector of color from vector
#'
#' @param x A numeric, character or factor object.
Expand Down

0 comments on commit baa449d

Please sign in to comment.