Commit Graph
16 Commits
Author SHA1 Message Date
jared 2c7c9a6dbc Fix ggplot2 imports and polish utility functions for publication
R-CMD-check / R CMD check (push) Successful in 4m17s
Blocking issue #1: Replace all ggplot2::function() calls with bare
references in R/colors.R, R/logo.R, R/theme.R. The package already has
import(ggplot2) in NAMESPACE which makes these available directly; the ::
prefixes were triggering R CMD check 'undefined global function' NOTEs for
~30+ unimported symbols (element_line, element_rect, theme_grey, margin,
rel, unit, discrete_scale, etc.).

Suggestion #6: Replace class(x) == "character" with "character" %in% class(x)
in R/db.R (countCleanr and simpleCap). The == pattern breaks on S3 objects
with multiple class attributes.

Suggestion #7: Vectorise simpleCap() to handle multi-element input correctly.
Previously strsplit(x, ' ')[[1]] only processed the first element; now uses
unname(vapply()) to capitalise each vector element independently while
preserving the original scalar behaviour (no names attribute on output).

Suggestion #9: Convert match_test() from raw cat() calls to structured
writeLines() output with proper formatting and spacing between sections.
2026-08-09 14:35:09 -04:00
jared 6051e4bb5c Remove vendored headshots and add proportion CI tests
R-CMD-check / R CMD check (push) Successful in 4m37s
- Remove Knowles_Headshot_2019_good.jpg and Knowles_Headshot_2019_prisma.jpg
  from inst/img/ — personal headshot should not be distributed with the package
- Update plot_jpeg() roxygen example to use a generic placeholder instead of
  the removed headshot path; regenerate man/plot_jpeg.Rd accordingly
- Add comprehensive testthat coverage for clopper_pearson(), z_univariate(),
  waldInterval(), and agresti_coull_interval() in tests/testthat/test_propint.R

The propint module previously had zero tests. New tests cover: return types,
formula correctness (cross-validated against binom.test()), edge cases
(0/n and n/n), interval validity, confidence level behavior, and sign/direction
of z-scores.
2026-08-09 13:53:08 -04:00
jared 5fc8155965 feat(logo): add stamp_logo_png() to brand file-based PNG outputs
R-CMD-check / R CMD check (pull_request) Successful in 3m53s
civilytics_logo()/make_logo_grob() brand ggplot/grobs, but flextables and
other outputs are rendered to PNG first and can't use them. stamp_logo_png()
is the raster analogue: it resolves the SAME brand asset that make_logo_grob()
uses (via the type/variant switch) and composites it into a corner of an
existing PNG in place, so file-based tables stay visually consistent with
logo-branded plots.

Dependency-free by design — uses only png + grid + grDevices (all already
imported), no magick. Configurable type/variant/position/width/margin;
preserves the image's pixel dimensions. Adds tests (21 assertions).
2026-06-22 16:33:08 -04:00
jared 41fe2b6170 fix: use full-bleed background rect instead of opaque logo grob
R-CMD-check / R CMD check (push) Successful in 4m4s
The previous fix applied the plot's background to the logo grob
directly, which made it opaque and covered caption/axis text that
overlaps into the logo area via negative margins.

Instead, wrap the entire arrangeGrob composition in a grobTree with
a background rectGrob behind it. This fills transparent areas (logo
strip, padding gaps) with the plot's background color while keeping
the logo grob itself transparent so overlapping text remains visible.
2026-05-19 22:12:03 -06:00
jared ac8e3eb60e fix: inherit plot background color in logo compositing
R-CMD-check / R CMD check (push) Successful in 3m41s
The logo grob uses theme_void() (transparent background), so when
arrangeGrob() composites it with a dark-themed plot, the logo strip
falls back to the device default (white). Extract the plot's
plot.background fill and apply it to the logo grob before compositing.

Fixes the issue where theme_civilytics_dark(font_size = 16) piped to
civilytics_logo(variant = "dark") would show a light background in
the logo/caption area.
2026-05-19 16:47:36 -06:00
jaredandClaude Opus 4.6 328d9d2fd6 feat: add position argument to civilytics_logo() for corner placement
R-CMD-check / R CMD check (push) Successful in 3m37s
Supports "bottom-right" (default), "bottom-left", "top-right", and
"top-left". The position controls both horizontal alignment of the logo
grob and whether it is placed above or below the plot.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-19 15:44:18 -06:00
jared 31d3e2886d feat: bump title sizes, add font_scale to logo functions, ship SVGs
R-CMD-check / R CMD check (push) Successful in 3m36s
- Change rel_large default from 16/14 to 20/14 (~1.43x) to match the
  Civilytics editorial design system. Subtitle now renders at 1.0x base
  instead of 0.86x.
- Switch axis.text to rel() sizing so all text elements cascade from the
  root font_size, enabling uniform scaling.
- Add font_scale parameter (default 1.1) to civilytics_logo(),
  add_logo(), and add_logo_ga() — inflates text by ~10% before
  arrangeGrob composition to compensate for viewport shrinkage.
- Ship SVG logo variants (mark, wordmark, pulse) in inst/img/ for
  Quarto/HTML templates.
- Add "Maintaining brand assets" section to README documenting inst/img/
  file inventory and update workflow.
- Document full font size hierarchy in theme_civilytics() roxygen.
2026-05-19 12:51:23 -06:00
jared 099fff1d1d fix: correct pipe precedence docs — |> binds tighter than +
R-CMD-check / R CMD check (push) Successful in 2m46s
R's |> has higher precedence than +, so parentheses ARE required
around the ggplot chain before piping to civilytics_logo():

  (ggplot(df, aes(x, y)) + geom_point() + theme_civilytics()) |>
    civilytics_logo()

Updated docs, examples, and pipe test accordingly.
2026-05-17 22:54:53 -06:00
jared 7371069379 feat: rebrand logos with wordmark/mark variants and pipe-friendly API
R-CMD-check / R CMD check (push) Successful in 2m39s
- Replace old civilytics_logo.png/white.png/jpg/pdf with new rebrand
  assets: civilytics-wordmark.png, civilytics-wordmark-reverse.png,
  civilytics-mark.png, civilytics-mark-reverse.png (all transparent bg)
- make_logo_grob() now accepts type = c("wordmark", "mark") alongside
  variant = c("light", "dark") for 4 combinations
- New civilytics_logo() pipe-friendly convenience function:
    ggplot(df, aes(x, y)) + geom_point() + theme_civilytics() |>
      civilytics_logo()
  R's |> has lower precedence than +, so the full ggplot chain pipes
  through without parentheses
- Remove old icon/favicon assets no longer used
- Wrap showtext-dependent examples in \dontrun{} to prevent R CMD check
  failures in headless PostScript environments
2026-05-17 22:42:40 -06:00
jared c93c469267 feat: add brand color system, showtext fonts, and dark theme
R-CMD-check / R CMD check (push) Failing after 1m39s
- R/colors.R: civilytics_colors named vector (from --cv-* CSS vars on
  civilytics.com), three palettes (main/sequential/diverging),
  scale_color_civilytics() and scale_fill_civilytics() for ggplot2
- R/fonts.R: auto-loads Inter + Libre Franklin from Google Fonts via
  showtext in .onLoad(); exports civilytics_load_fonts() for manual retry
- R/theme.R: wires ggplot2 4.0 ink/paper/accent params into theme_grey()
  base, adds title_family + strip_color params; new theme_civilytics_dark()
  using navy_dark background and warm off-white text
- R/logo.R: make_logo_grob(variant) accepts "light"/"dark" to select the
  white logo for dark-background compositions
- DESCRIPTION: adds showtext, sysfonts; pins ggplot2 >= 4.0.0
- tests/testthat/test_theme.R: full test suite for colors, palettes,
  scales, both theme variants, and logo grob variants
2026-05-17 10:36:59 -06:00
jared 2d70d9aecf fix: clean up theme.R and logo.R before restyling
R-CMD-check / R CMD check (push) Successful in 1m45s
theme.R:
- Remove deprecated legend.text.align and legend.title.align (ggplot2 3.5.0)
- Remove stale @importFrom graphics plot (unused in theme function)

logo.R:
- Fix make_logo_grob() spurious two-row data frame (drop aes/data from canvas)
- Fix add_logo_ga() caption measurement always using first plot; now uses max
  across all plots with captions
- Fix add_logo_ga() ncol hardcoded to 2; now uses length(plot_list)
- Fix add_logo_ga() widths silently ignored in nrow > 1 path; now warns
- Replace deprecated qplot() in examples with ggplot() equivalents
- Fix native = T -> TRUE in plot_jpeg()
2026-05-17 10:01:35 -06:00
Jared Knowles 91dad76526 cleanup tests and build
Gitea Organization/civilyticsR/pipeline/head There was a failure building this commit
2022-10-16 19:30:05 -04:00
Jared Knowles 8b8dd50de3 fill out testing
Gitea Organization/civilyticsR/pipeline/head There was a failure building this commit
2022-10-16 19:08:06 -04:00
Jared Knowles 20f65a7126 install logo correctly 2020-07-06 11:48:10 -04:00
Jared Knowles f5f288974f add package doco skeleton and images 2020-02-13 17:09:03 -05:00
Jared Knowles 1f41a4560d initial commit 2020-02-13 16:48:38 -05:00