From: Ben Pfaff Date: Wed, 24 Jun 2026 16:42:36 +0000 (-0700) Subject: fix ticks and labels X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=82d26ba7d76fc77fa470038459460b81e89547da;p=pspp fix ticks and labels --- diff --git a/rust/pspp/src/spv/read/graph.rs b/rust/pspp/src/spv/read/graph.rs index 19ad654079..2d8bfe6d61 100644 --- a/rust/pspp/src/spv/read/graph.rs +++ b/rust/pspp/src/spv/read/graph.rs @@ -811,24 +811,32 @@ impl Visualization { // X axis. let y = rect.0[Axis2::Y].1; let x_span = rect.0[Axis2::X]; - graph_svg.append( + /*graph_svg.append( Line::new() .set("x1", x_span.0) .set("x2", x_span.1) .set("y1", y) .set("y2", y) .set("stroke", "black"), - ); - for (frac, _label) in axis_domains[Axis3::X].ticks() { + );*/ + for (frac, label) in axis_domains[Axis3::X].ticks() { let svg_x = rect.0[Axis2::X].frac(frac); - graph_svg = graph_svg.add( - Line::new() - .set("x1", svg_x) - .set("x2", svg_x) - .set("y1", y) - .set("y2", y + 10.0) - .set("stroke", "black"), - ); + graph_svg = graph_svg + .add( + Line::new() + .set("x1", svg_x) + .set("x2", svg_x) + .set("y1", y) + .set("y2", y + 10.0) + .set("stroke", "black"), + ) + .add( + svg::node::element::Text::new(dbg!(&label)) + .set("x", svg_x) + .set("y", y + 10.0) + .set("dominant-baseline", "hanging") + .set("text-anchor", "middle"), + ); } } } @@ -838,7 +846,7 @@ impl Visualization { // Y axis. let x = subrect.0[Axis2::X].0; let y_span = subrect.0[Axis2::Y]; - graph_svg.append( + /*graph_svg.append( Line::new() .set("y1", y_span.0) .set("y2", y_span.1) @@ -846,17 +854,25 @@ impl Visualization { .set("x2", x) .set("stroke", "black") .set("c:description", format!("Y axis {y_index}")), - ); - for (frac, _label) in axis_domains[Axis3::Y].ticks() { + );*/ + for (frac, label) in axis_domains[Axis3::Y].ticks() { let svg_y = subrect.0[Axis2::Y].frac(1.0 - frac); - graph_svg = graph_svg.add( - Line::new() - .set("y1", svg_y) - .set("y2", svg_y) - .set("x1", x) - .set("x2", x - 10.0) - .set("stroke", "black"), - ); + graph_svg = graph_svg + .add( + Line::new() + .set("y1", svg_y) + .set("y2", svg_y) + .set("x1", x) + .set("x2", x - 10.0) + .set("stroke", "black"), + ) + .add( + svg::node::element::Text::new(label) + .set("y", svg_y) + .set("x", x - 10.0) + .set("dominant-baseline", "middle") + .set("text-anchor", "end"), + ); } } diff --git a/rust/pspp/src/spv/testdata/graph5.xml b/rust/pspp/src/spv/testdata/graph5.xml index ef25f454d0..4f06ca6e33 100644 --- a/rust/pspp/src/spv/testdata/graph5.xml +++ b/rust/pspp/src/spv/testdata/graph5.xml @@ -63,14 +63,14 @@ - + - + - +