Skip to content

Commit 953f673

Browse files
authored
Various rect fixes (#262)
1 parent ecbba24 commit 953f673

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

doc/syntax/layer/type/rect.qmd

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,11 @@ DRAW rect
6666
If `x` is continuous, then `width` can be variable. Likewise for `y` and `height`.
6767

6868
```{ggsql}
69-
SELECT *, Temp / (SELECT MAX(Temp) FROM ggsql:airquality) AS norm_temp
69+
SELECT
70+
*,
71+
CAST(Temp AS REAL) / (SELECT MAX(Temp) FROM ggsql:airquality) AS norm_temp
7072
FROM ggsql:airquality
73+
7174
VISUALISE Day AS x, Month AS y, Temp AS colour
7275
DRAW rect
7376
MAPPING norm_temp AS width, norm_temp AS height

src/execute/layer.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//! This module handles building SQL queries for layers, applying pre-stat
44
//! transformations, stat transforms, and post-query operations.
55
6-
use crate::plot::aesthetic::AestheticContext;
6+
use crate::plot::aesthetic::{self, AestheticContext};
77
use crate::plot::layer::is_transposed;
88
use crate::plot::layer::orientation::{flip_positional_aesthetics, resolve_orientation};
99
use crate::plot::{
@@ -579,6 +579,20 @@ where
579579
let original_name = consumed_original_names
580580
.get(aesthetic)
581581
.cloned()
582+
.or_else(|| {
583+
// For variant positional aesthetics (e.g., pos1min, pos2max),
584+
// fall back to the primary aesthetic's original name (pos1, pos2).
585+
// This ensures rect's expanded min/max aesthetics inherit the
586+
// original column name from the user's x/y mapping.
587+
aesthetic::parse_positional(aesthetic).and_then(|(slot, suffix)| {
588+
if !suffix.is_empty() {
589+
let primary = format!("pos{}", slot);
590+
consumed_original_names.get(&primary).cloned()
591+
} else {
592+
None
593+
}
594+
})
595+
})
582596
.or_else(|| Some(stat.clone()));
583597

584598
let value = AestheticValue::Column {

0 commit comments

Comments
 (0)