% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/render.R
\name{ggsql_save}
\alias{ggsql_save}
\title{Save a ggsql spec to a file}
\usage{
ggsql_save(spec, file, width = 600, height = 400)
}
\arguments{
\item{spec}{A \code{Spec} object returned by \code{\link[=ggsql_execute]{ggsql_execute()}}.}

\item{file}{Output file path. Extension determines format: \code{.svg}, \code{.png}, or
\code{.json}.}

\item{width}{Width in pixels.}

\item{height}{Height in pixels.}
}
\value{
\code{file}, invisibly.
}
\description{
This function renders a specification and returns it either as a Vegalite
json string, an SVG or a PNG. For the latter two, the Vegalite JSON is
rendered to SVG using the V8 package and, potentially, converted to PNG using
the rsvg package.
}
\examples{
reader <- duckdb_reader()
ggsql_register(reader, mtcars, "cars")
spec <- ggsql_execute(reader,
  "SELECT * FROM cars VISUALISE mpg AS x, disp AS y DRAW point"
)
spec_file <- tempfile(fileext = ".json")
ggsql_save(spec, spec_file)

}
