Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion doc/syntax/layer/type/rect.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,11 @@ DRAW rect
If `x` is continuous, then `width` can be variable. Likewise for `y` and `height`.

```{ggsql}
SELECT *, Temp / (SELECT MAX(Temp) FROM ggsql:airquality) AS norm_temp
SELECT
*,
CAST(Temp AS REAL) / (SELECT MAX(Temp) FROM ggsql:airquality) AS norm_temp
FROM ggsql:airquality

VISUALISE Day AS x, Month AS y, Temp AS colour
DRAW rect
MAPPING norm_temp AS width, norm_temp AS height
Expand Down
16 changes: 15 additions & 1 deletion src/execute/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! This module handles building SQL queries for layers, applying pre-stat
//! transformations, stat transforms, and post-query operations.

use crate::plot::aesthetic::AestheticContext;
use crate::plot::aesthetic::{self, AestheticContext};
use crate::plot::layer::is_transposed;
use crate::plot::layer::orientation::{flip_positional_aesthetics, resolve_orientation};
use crate::plot::{
Expand Down Expand Up @@ -579,6 +579,20 @@ where
let original_name = consumed_original_names
.get(aesthetic)
.cloned()
.or_else(|| {
// For variant positional aesthetics (e.g., pos1min, pos2max),
// fall back to the primary aesthetic's original name (pos1, pos2).
// This ensures rect's expanded min/max aesthetics inherit the
// original column name from the user's x/y mapping.
aesthetic::parse_positional(aesthetic).and_then(|(slot, suffix)| {
if !suffix.is_empty() {
let primary = format!("pos{}", slot);
consumed_original_names.get(&primary).cloned()
} else {
None
}
})
})
.or_else(|| Some(stat.clone()));

let value = AestheticValue::Column {
Expand Down
Loading