Skip to content

Commit 49f42fd

Browse files
teunbrandclaude
andcommitted
Add opacity as material aesthetic requiring segmentation
Treat opacity like stroke: varying opacity within partition groups triggers segmentation. This ensures each segment can have its own opacity value. Behavior: - Only opacity varies → line mark, segmented - Opacity + linewidth → trail mark, segmented - Opacity + stroke → line mark, segmented - All three → trail mark, segmented Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 946e72e commit 49f42fd

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/writer/vegalite/layer.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ fn aesthetic_varies_within_groups(
425425

426426
/// Renderer for line geom - preserves data order for correct line rendering
427427
///
428-
/// Automatically detects when continuous material aesthetics (stroke, linewidth) vary
428+
/// Automatically detects when continuous material aesthetics (stroke, linewidth, opacity) vary
429429
/// within partition groups and converts to segmented rendering using detail encoding.
430430
/// Discrete material aesthetics (linetype, or discrete stroke) already define groups
431431
/// via partition_by and don't require special handling.
@@ -441,7 +441,7 @@ impl GeomRenderer for LineRenderer {
441441
) -> Result<PreparedData> {
442442
// Continuous material aesthetics that can trigger segmentation
443443
// (linetype is always discrete and already handled via partition_by)
444-
let material_aesthetics: &[&'static str] = &["stroke", "linewidth"];
444+
let material_aesthetics: &[&'static str] = &["stroke", "linewidth", "opacity"];
445445

446446
// Start with existing partition_by (includes discrete material aesthetics already)
447447
let partition_columns: Vec<String> = layer.partition_by.clone();
@@ -544,8 +544,8 @@ impl GeomRenderer for LineRenderer {
544544
}
545545
}
546546

547-
// Handle varying stroke: apply segmentation
548-
if !varying_aesthetics.contains(&"stroke") {
547+
// Handle varying stroke/opacity: apply segmentation
548+
if !varying_aesthetics.contains(&"stroke") && !varying_aesthetics.contains(&"opacity") {
549549
// Only linewidth varies, trail mark handles it natively
550550
return Ok(vec![layer_spec]);
551551
}

0 commit comments

Comments
 (0)