diff --git a/crates/engine/src/cmd/graph/tests.rs b/crates/engine/src/cmd/graph/tests.rs index 5d734003b2..ef469f7dd9 100644 --- a/crates/engine/src/cmd/graph/tests.rs +++ b/crates/engine/src/cmd/graph/tests.rs @@ -6753,6 +6753,23 @@ fn default_fill_and_stroke_and_fill_to_stroke_on_an_axis_line_are_kept() { assert!(redrawn_line_looks(&mut s, id).iter().all(|l| l.0 == "#0000ff"), "the blue fill on the stroke"); } +/// Default Fill and Stroke on an axis line that already shows the default paint is kept for every axis line, in place of +/// the stroke the kind keeps from another line, and leaves the object opacity the kind keeps from another line. +#[test] +fn default_fill_and_stroke_on_an_axis_line_that_shows_it_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); + s.execute("paint.default", &json!({"ids": [lines[0].id.0]})).unwrap(); + s.execute("paint.setStroke", &json!({"ids": [lines[1].id.0], "color": "#ff0000"})).unwrap(); + s.execute("object.setProps", &json!({"ids": [lines[1].id.0], "opacity": 50})).unwrap(); + s.execute("paint.default", &json!({"ids": [lines[0].id.0]})).unwrap(); + let looks = redrawn_line_looks(&mut s, id); + assert!(looks.iter().all(|l| (l.0.as_str(), l.1) == ("#000000", 1.0)), "the 1 pt black default stroke: {looks:?}"); + assert!(looks.iter().all(|l| (l.2 - 0.5).abs() < 1e-6), "the kind keeps its 50% opacity: {looks:?}"); +} + #[test] fn pie_names_and_wedge_labels_keep_their_style() { let mut s = Session::new(); diff --git a/crates/engine/src/cmd/paint.rs b/crates/engine/src/cmd/paint.rs index 32e1a8bd38..264d23a737 100644 --- a/crates/engine/src/cmd/paint.rs +++ b/crates/engine/src/cmd/paint.rs @@ -1020,7 +1020,10 @@ fn default_paint(s: &mut Session, p: &Value) -> Result { } let kept = super::appearance::capture_series_writes(&before, d, &ids, (true, true), (true, true), false, false); let labels = super::graph::capture_label_changes(&before, d, &ids, false, None); - Ok(super::appearance::count_changed(d, &before, &ids) + usize::from(kept || labels)) + // The graph keeps the default fill and stroke rows for every line of a kind it reached, also when one already + // showed them; the object opacity the kind keeps stays. + let lines = super::graph::capture_line_fill_stroke_rows(d, &ids); + Ok(super::appearance::count_changed(d, &before, &ids) + usize::from(kept || labels || lines)) })?; } super::newart::reset(s); diff --git a/docs/mcp.md b/docs/mcp.md index fece2ab3a3..e32f35ad8e 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -899,7 +899,8 @@ line's rows even when the line already showed them. The other commands, an `appe included, store only what they change on a line's rows; the kind keeps its other attributes, also when the line still shows different ones until the graph is drawn again. An `appearance.copyFrom` that does not apply the object's transparency, and `graphicStyle.apply` with `add`, leave the object opacity and blend mode a kind keeps as they are, -also when the line still shows other ones. Rows equal to a kind's default stroke (0.5 pt black for axis lines and tick +also when the line still shows other ones. `paint.default` stores the default fill and stroke rows for a line's kind +even when the line already showed them, and leaves the object opacity and blend mode the kind keeps. Rows equal to a kind's default stroke (0.5 pt black for axis lines and tick marks, 0.25 pt gray for rings) are not saved. When one command reaches several lines of one kind, the frontmost line in paint order sets what the kind keeps, whatever order the `ids` are in. A gradient is stored without its placement, and each line fits it when the graph is drawn again. The graph saves the rows as `axisRows` and `ringRows` in its label