@lindsayjorgenson putting this here because I don't have permissions to make a PR.
Here's the function
#' Logo
#'
#' Add logo to exported charts.
#'
#' @param hc a highcharter chart
#' @param path path to logo
#' @param top top margin of logo
#' @param left left margin of logo
#' @param width width of logo
#' @param height height of logo
#'
#' @export
add_logo <- function(hc, path, top = 80L, left = 10L, width = 100L, height = 100L){
if(missing(path))
stop("path is required")
hc$x$hc_opts$chart$events <- list(
load = htmlwidgets::JS(
sprintf("function() {
if (!this.options.chart.forExport) return;
this.renderer.image('%s', %s, %s, %s, %s).add();
}",
path,
top,
left,
width,
height
)
),
beforePrint = htmlwidgets::JS(
sprintf("function() {
let img = this.renderer.image('%s', %s, %s, %s, %s).add();
img.addClass('image');
}",
path,
top,
left,
width,
height
)
),
afterPrint = htmlwidgets::JS("function(){
$('.hc-image').hide();
}")
)
hc
}
@lindsayjorgenson putting this here because I don't have permissions to make a PR.
Here's the function
And here is an example of how to use it.