Function Reference

Complete index of all exported functions

This page provides a complete index of all exported functions in cpaltemplates, organized by category. Use the navigation below to jump to specific sections, or browse the full list for function signatures and descriptions.

Ready to use In development Under review


Quick Navigation


Color System

Core Color Functions

Status Function Description
cpal_colors() Main entry point for accessing CPAL colors and palettes
cpal_color() Get a single color by name
cpal_colors_primary() Returns 5 core brand colors
cpal_colors_extended() Returns all 17+ colors including shades
cpal_get_color() Get single color by exact name
cpal_get_primary_color() Returns primary brand color (teal)
cpal_palette() Internal palette wrapper for scale functions

Palette Access

Status Function Description
cpal_palettes() Unified accessor for all palettes
cpal_palettes_sequential() Returns 6 sequential palettes
cpal_palettes_diverging() Returns 3 diverging palettes
cpal_palettes_categorical() Returns 7 categorical palettes
list_cpal_palettes() List all available palette names
view_cpal_palettes() Visual display of palettes
quick_palette() Quick console preview

Color Validation

Status Function Description
validate_color_contrast() Check WCAG contrast requirements
validate_brand_colors() Check all colors for accessibility

Color Interpolation

Status Function Description
cpal_color_ramp() Generate gradient between two colors
cpal_color_gradient() Create gradient through multiple colors

ggplot2 Scales

Status Function Description
scale_color_cpal() Discrete/continuous color scale
scale_fill_cpal() Discrete/continuous fill scale
scale_color_cpal_c() Continuous color scale
scale_fill_cpal_c() Continuous fill scale
scale_color_cpal_d() Discrete color scale
scale_fill_cpal_d() Discrete fill scale
scale_colour_cpal() British spelling alias

Theme System

ggplot2 Themes

Status Function Description
theme_cpal() Main CPAL theme with full customization
theme_cpal_minimal() Minimal variant with reduced elements
theme_cpal_classic() Traditional styling with axis lines
theme_cpal_dark() Dark background variant
theme_cpal_print() Print-optimized theme
theme_cpal_map() Geographic visualization theme
theme_cpal_auto() Thematic-compatible auto theme

Theme Switching (Shiny)

Status Function Description
theme_cpal_switch() Returns light or dark theme based on mode
make_theme_reactive() Creates reactive theme for Shiny apps

Theme Management

Status Function Description
set_theme_cpal() Set CPAL theme as session default
preview_cpal_themes() Visual comparison of all themes

Table Functions

Status Function Description
cpal_table_gt() Styled GT table (static)
cpal_table_reactable() Styled Reactable (interactive)

Highcharter Functions

Theme Functions

Status Function Description
hc_theme_cpal_light() Highcharter theme for light mode
hc_theme_cpal_dark() Highcharter theme for dark mode
hc_theme_cpal_switch() Returns appropriate theme based on mode
hc_cpal_theme() Apply CPAL theme to a chart

Color Functions

Status Function Description
hc_colors_cpal() Apply CPAL color palette to chart series
hc_colorAxis_cpal() Apply sequential/diverging gradient to color axis

Formatting Helpers

Status Function Description
hc_cpal_number_format() Set global Highcharts number formatting
hc_tooltip_cpal() Create formatted tooltips with prefix/suffix
hc_yaxis_cpal() Format y-axis with scaling and labels
hc_linetype_cpal() Toggle between line and spline styles

Chart Type Helpers

Status Function Description
hc_histogram_cpal() Create CPAL-styled histogram with auto-binning
hc_lollipop_cpal() Create lollipop chart (stem + dot)
hc_dumbbell_cpal() Create dumbbell chart (compare two values)
hc_boxplot_style_cpal() Apply CPAL styling to boxplot series
hc_waterfall_colors_cpal() Auto-color waterfall chart data
hc_treemap_data_cpal() Build hierarchical treemap data with CPAL colors
hc_treemap_style_cpal() Apply CPAL level styling to treemaps

Logo & Branding

Status Function Description
hc_add_cpal_logo() Add CPAL logo to Highcharts widget

Map Functions

Status Function Description
cpal_mapgl() Create styled mapgl map
add_cpal_popup_style() Apply CPAL styling to popup container
cpal_popup_html() Generate basic popup HTML content
cpal_popup_html_metrics() Generate popup HTML with metrics
cpal_legend_style() Get styled legend options for mapgl

Project Scaffolding

Note

Template files generated by scaffolding functions are under review and may be updated.

Main Function

Status Function Description
start_project() Create new project with CPAL structure

Component Adders

Status Function Description
use_quarto_report() Add Quarto report to existing project
use_quarto_slides() Add Quarto slides template
use_quarto_web() Add Quarto website structure
use_shiny_dashboard() Add full-featured dashboard
use_shiny_app() Add simple Shiny app
use_shiny_theme() Add CPAL CSS theme files
use_targets() Add targets pipeline

Brand & Asset Management

Status Function Description
use_cpal_brand() Copy _brand.yml to project
validate_cpal_brand() Validate brand configuration
get_cpal_asset() Get path to package asset
update_cpal_assets() Update project assets

Utility Functions

Font Management

Status Function Description
cpal_font_family() Get best available CPAL font
cpal_font_family_fallback() Get system fallback font
setup_cpal_google_fonts() Download and register fonts

Plot Utilities

Status Function Description
save_cpal_plot() Save with standard dimensions
add_cpal_logo() Add CPAL logo to ggplot2 plots
check_plot_accessibility() Check accessibility issues

Shiny/Dashboard Functions

Status Function Description
cpal_dashboard_theme() bslib theme for dashboards
cpal_shiny() Initialize Shiny with CPAL theme
cpal_add_scss_enhancements() Add custom SCSS to theme
cpal_export_scss() Export SCSS variables

Deprecated Functions

Function Replacement
cpal_interactive() Use Highcharter’s hchart() with hc_cpal_theme()
cpal_point_interactive() Use Highcharter scatter charts
cpal_line_interactive() Use Highcharter line/spline charts
cpal_col_interactive() Use Highcharter column/bar charts
cpal_polygon_interactive() Use Highcharter or mapgl for polygons
cpal_mapgl_layer() Use mapgl’s native layer functions

See Also