% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/highdir-package.R
\docType{package}
\name{highdir-package}
\alias{highdir}
\alias{highdir-package}
\title{highdir: Backend-Agnostic Figure Builder for Helsedirektoratet}
\description{
\strong{highdir} provides a unified API for building interactive figures with
\strong{highcharter} or static figures with \strong{ggplot2}.  A figure is described
once as a data-mapping object (\link{hd_spec}) and an optional presentation
object (\link{hd_opts}), then rendered to either backend without changing the
calling code.
\subsection{Core workflow}{

\if{html}{\out{<div class="sourceCode r">}}\preformatted{library(highdir)

# -- 1. Sample data --------------------------------------------------------
df <- data.frame(
  age = rep(c("18-24", "25-34", "35-44", "45-54"), each = 2),
  sex = rep(c("Male", "Female"), 4),
  pct = c(42, 38, 55, 61, 48, 52, 60, 57),
  n   = c(120, 115, 200, 210, 180, 175, 160, 155)
)

# -- 2. Describe the data mapping (once) ----------------------------------
spec <- hd_spec(df, x = "age", y = "pct", group = "sex", n = "n",
                 ylab = "Percentage (\%)")

# -- 3. Describe the presentation (reusable across specs) -----------------
opts <- hd_opts(title    = "Health survey results",
                 subtitle = "Source: FHI 2024",
                 caption  = "Tall om helse",
                 ylim     = c(0, 80))

# -- 4. Render — swap backend without touching spec or opts ----------------
hd_make(spec, "column", opts)                        # interactive HC
hd_make(spec, "column", opts, backend = "ggplot2")   # static ggplot2
hd_make(spec, "line",   opts, smooth = TRUE)         # HC spline
hd_make(spec, "line",   opts, backend = "ggplot2")   # gg line
hd_make(spec, "scatter")                             # HC scatter

# Donut chart
hd_make(pie_spec, "pie", pie_opts, inner_size = "50\%")

# -- 5. Arearange (confidence intervals) ----------------------------------
df2   <- cbind(df, lo = df$pct - 5, hi = df$pct + 5)
spec2 <- hd_spec(df2, "age", "pct", group = "sex")
hd_make(spec2, "arearange", opts, ymin = "lo", ymax = "hi")

# -- 6. Save to disk -------------------------------------------------------
hd_save(hd_make(spec, "column", opts),               "chart.html")
hd_save(hd_make(spec, "column", opts, backend="ggplot2"), "chart.png")

# -- 7. Session-wide styling -----------------------------------------------
hd_set_theme(hc_theme = "economist",
             colors   = c("#025169","#7C145C","#C68803"))

# -- 8. Launch the Shiny GUI -----------------------------------------------
hd_app()
}\if{html}{\out{</div>}}
}

\subsection{Key functions}{\tabular{ll}{
   Function \tab Purpose \cr
   \code{\link[=hd_spec]{hd_spec()}} \tab Describe data mapping (x, y, group, n, labels) \cr
   \code{\link[=hd_opts]{hd_opts()}} \tab Describe presentation (title, ylim, colours, theme) \cr
   \code{\link[=hd_make]{hd_make()}} \tab Render spec + opts → highchart or ggplot \cr
   \code{\link[=hd_save]{hd_save()}} \tab Export to HTML / JSON / PNG / SVG / PDF \cr
   \code{\link[=hd_set_theme]{hd_set_theme()}} \tab Session-wide colour / font / theme defaults \cr
   \code{\link[=hd_theme]{hd_theme()}} \tab Build a highcharter theme object directly \cr
   \code{\link[=hd_add_js]{hd_add_js()}} \tab Inject custom JS into a highchart \cr
   \code{\link[=register_geom]{register_geom()}} \tab Add a custom geometry \cr
   \code{\link[=register_backend]{register_backend()}} \tab Add a custom rendering backend \cr
   \code{\link[=register_palette]{register_palette()}} \tab Add a named colour palette \cr
   \code{\link[=list_geoms]{list_geoms()}} \tab Show available geometries \cr
   \code{\link[=list_backends]{list_backends()}} \tab Show available backends \cr
   \code{\link[=list_palettes]{list_palettes()}} \tab Show available palettes \cr
   \code{\link[=hd_app]{hd_app()}} \tab Launch the Shiny GUI \cr
}

}
}
\seealso{
Useful links:
\itemize{
  \item \url{https://folkehelsestats.github.io/highdir/}
  \item \url{https://github.com/folkehelsestats/highdir}
  \item Report bugs at \url{https://github.com/folkehelsestats/highdir/issues}
}

}
\author{
\strong{Maintainer}: Yusman Kamaleri \email{ybkamaleri@gmail.com} (\href{https://orcid.org/0000-0001-5014-3665}{ORCID})

Authors:
\itemize{
  \item Yusman Kamaleri \email{ybkamaleri@gmail.com} (\href{https://orcid.org/0000-0001-5014-3665}{ORCID})
}

}
\keyword{internal}
