Graphs: an appearance moved to an axis line behind its source is kept

Move Appearance captured the cleared source and the targets together, and
graph lines are captured in paint order, so a source in front of its target
replaced the kept axis rows with its cleared ones. The targets are now
captured again after the source.
This commit is contained in:
dotCooCoo
2026-11-14 12:06:53 -08:00
parent a9b5bcc656
commit cc26358b9f
2 changed files with 18 additions and 2 deletions
+3 -2
View File
@@ -974,8 +974,9 @@ fn transfer(s: &mut Session, p: &Value) -> Result<Value> {
rows.extend(painted_rows(d, both_kinds(&targets)));
let painted = super::graph::capture_series_top_paints(d, &rows);
let object = super::graph::capture_series_object_opacity(d, &changed);
// The targets last: on two labels of one kind, the target's rows are the ones the kind keeps.
let labels = super::graph::capture_label_rows(d, &changed);
// The targets last: on two labels of one kind, the target's rows are the ones the kind keeps. Graph lines are
// taken in paint order, so the targets are captured again on their own, after a cleared source in front of them.
let labels = super::graph::capture_label_rows(d, &changed) | super::graph::capture_label_rows(d, &targets);
let all: Vec<NodeId> = from.iter().chain(&targets).chain(&group).copied().collect();
Ok(count_changed(d, &before, &all) + usize::from(kept || painted || object || labels))
})?;
+15
View File
@@ -6473,6 +6473,21 @@ fn the_frontmost_axis_line_sets_what_its_recolor_keeps() {
assert_eq!(kept.as_deref(), Some("#00ffff"), "the inverted red of the frontmost line");
}
/// An appearance moved from an axis line to one behind it is kept for every axis line, not the cleared source's.
#[test]
fn an_appearance_moved_to_an_axis_line_behind_is_kept() {
let mut s = Session::new();
s.execute("file.new", &json!({"width": 800, "height": 800})).unwrap();
let id = graph(&mut s, "column");
let lines = line_nodes(&s, id);
let (back, front) = (lines[0].id, lines[lines.len() - 1].id);
s.execute("paint.setStroke", &json!({"ids": [front.0], "color": "#ff0000"})).unwrap();
s.execute("appearance.transfer", &json!({"source": front.0, "target": back.0})).unwrap();
let kept = spec(&s, id).label_styles.axis_rows.unwrap().paint.stroke.and_then(|p| p.color()).map(|c| c.to_hex());
assert_eq!(kept.as_deref(), Some("#ff0000"), "the moved red, not the cleared source");
assert!(redrawn_line_looks(&mut s, id).iter().all(|l| l.0 == "#ff0000"));
}
/// A radar graph's spoke brought in front of its rings is still a spoke: what is set on it is kept for the spokes.
#[test]
fn a_radar_spoke_moved_in_front_of_the_rings_keeps_its_kind() {