Skip to content

test: add geom_bar regression test for update_axes limitation#319

Open
AZ9tumas wants to merge 1 commit intoanimint:masterfrom
AZ9tumas:add-update-axes-geom-bar-test
Open

test: add geom_bar regression test for update_axes limitation#319
AZ9tumas wants to merge 1 commit intoanimint:masterfrom
AZ9tumas:add-update-axes-geom-bar-test

Conversation

@AZ9tumas
Copy link
Copy Markdown

@AZ9tumas AZ9tumas commented Mar 30, 2026

update_axes test for geom_bar

Through this PR I aim to add a test documenting the current update_axes issue for geom_bar.

While going through pr #48, I traced the current compiler-side domain computation and found that compute_domains() behaves differently for geom_bar and geom_point since they require different columns to compute domains.

From my understanding, in this code section

domain_cols <- list(bar=c(paste0(axes, "min"), paste0(axes, "max")),
ribbon=if(axes=="x"){c(axes)}
else{c(paste0(axes, "min"), paste0(axes, "max"))},
rect=c(paste0(axes, "min"), paste0(axes, "max")),
tallrect=if(axes=="x")
{c(paste0("xmin"), paste0("xmax"))}
else{NULL},
point=c(axes),
path=c(axes),
text=c(axes),
line=c(axes),
segment=c(axes, paste0(axes, "end")))

for geom_point it uses x and y but for geom_bar it uses xmin, xmax, ymin, ymax.
The former is present in built_data but not the latter. This is connected to this code section:

animint2/R/z_animint.R

Lines 511 to 515 in 543d0d9

## Set up built_data to compute domains
built_data <-
ggplot.list[[p.name]]$built$plot$layers[[layer.i]]$data
built_data$PANEL <-
ggplot.list[[p.name]]$built$data[[layer.i]]$PANEL

Since the column names are not found, the else if block is executed and compute_domains returns NULL. I have also added a warning for the same:

  }else if(!all(use_cols %in% names(built_data))){
    missing <- use_cols[!use_cols %in% names(built_data)]
    warning(paste0(
    "Cannot compute axis domain for geom_", geom_name,
    ": column(s) ", paste(missing, collapse=", "),
    " not found in the pre-stat layer data."), call. = FALSE)
    return(NULL)
  }

My implementation approach

  • OO approach as suggested and continue working on the Geom class refactor from Refactor draw_geom() and turn into a Geom class for scalability #107.
  • Add geom-level domain computation in the renderer from the available data (.tsv)
  • Handle geom-specific logic cleanly in the corresponding geom class rather than in compiler-side helper code.
  • Modify update_scales() so it uses renderer-computed domains instead of relying only on compiler-saved axis_domains
  • Eventually generalize to other geoms that currently use different domain columns.
  • More tests that check for axes updates after clicks throughout other geoms.

new warning for missing column in compute_domain
@AZ9tumas
Copy link
Copy Markdown
Author

AZ9tumas commented Mar 31, 2026

@tdhock @suhaani-agarwal Could you please review this and suggest? 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant