Skip to content
Merged
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
23 changes: 11 additions & 12 deletions src/writer/vegalite/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,27 +349,19 @@ fn build_layer_encoding(
);
}

// Disable Vega-Lite's automatic stacking - we handle position adjustments ourselves
// This prevents Vega-Lite from applying its own stack/dodge logic on top of ours
// Set stack: null on both y and y2 channels (pos2 and pos2end in our terminology)
// Disable Vega-Lite's automatic stacking - we handle position adjustments ourselves.
// This prevents Vega-Lite from applying its own stack/dodge logic on top of ours.
// Only set stack: null on primary position channels (y/radius) — Vega-Lite does
// not support 'stack' on secondary channels (y2/radius2) and Altair rejects it.
let y_channel = match coord_kind {
CoordKind::Cartesian => "y",
CoordKind::Polar => "radius",
};
let y2_channel = match coord_kind {
CoordKind::Cartesian => "y2",
CoordKind::Polar => "radius2",
};
if let Some(y_enc) = encoding.get_mut(y_channel) {
if let Some(obj) = y_enc.as_object_mut() {
obj.insert("stack".to_string(), Value::Null);
}
}
if let Some(y2_enc) = encoding.get_mut(y2_channel) {
if let Some(obj) = y2_enc.as_object_mut() {
obj.insert("stack".to_string(), Value::Null);
}
}

// Apply geom-specific encoding modifications via renderer
let renderer = get_renderer(&layer.geom);
Expand Down Expand Up @@ -2703,8 +2695,15 @@ mod tests {
enc.get("axis").is_none(),
"{channel} should not have 'axis': {enc}"
);
assert!(
enc.get("stack").is_none(),
"{channel} should not have 'stack': {enc}"
);
}
}
}

// The spec must also pass Vega-Lite schema validation
assert_valid_vegalite(&json_str);
}
}
Loading