% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/save.R
\name{hd_save}
\alias{hd_save}
\title{Save a Figure to Disk}
\usage{
hd_save(
  fig,
  file,
  type = "auto",
  width = 8,
  height = 5,
  dpi = 300,
  selfcontained = TRUE,
  ...
)
}
\arguments{
\item{fig}{A \code{highchart} or \code{ggplot} object (output of
\code{\link[=hd_make]{hd_make()}}).}

\item{file}{Character. Output path including extension.}

\item{type}{\code{"auto"} (infer from extension) or an explicit format
string. Default: \code{"auto"}.}

\item{width}{Numeric. Width in inches (ggplot2). Default: \code{8}.}

\item{height}{Numeric. Height in inches (ggplot2). Default: \code{5}.}

\item{dpi}{Numeric. Raster resolution for ggplot2. Default: \code{300}.}

\item{selfcontained}{Logical. Embed all JS/CSS in the HTML file.
Default: \code{TRUE}.}

\item{...}{Passed to \code{\link[ggplot2:ggsave]{ggplot2::ggsave()}} for ggplot2 figures.}
}
\value{
\code{file}, invisibly.
}
\description{
Exports a \code{highchart} or \code{ggplot} figure produced by \code{\link[=hd_make]{hd_make()}} to a
file. The output format is inferred from the file extension unless \code{type}
is supplied explicitly.
}
\details{
\tabular{ll}{
   Backend \tab Supported formats \cr
   highcharter \tab \code{html}, \code{json} \cr
   ggplot2 \tab \code{png}, \code{svg}, \code{pdf}, \code{jpeg}, \code{jpg}, \cr
    \tab \code{tiff}, \code{bmp}, \code{eps} \cr
}


To export a highcharter figure as an image, either save as \code{html} and
screenshot in a browser, or re-render with \code{backend = "ggplot2"} in
\code{\link[=hd_make]{hd_make()}} and save as \code{png}.
}
