From: Ben Pfaff Date: Sat, 25 Jul 2026 15:38:36 +0000 (-0700) Subject: add axes X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b7a098f7028a0dfb43aa51efbd6b7112c1f4969c;p=pspp add axes --- diff --git a/rust/pspp/src/spv/read/graph.rs b/rust/pspp/src/spv/read/graph.rs index 8d5b29f4dc..bf033c0e19 100644 --- a/rust/pspp/src/spv/read/graph.rs +++ b/rust/pspp/src/spv/read/graph.rs @@ -753,6 +753,9 @@ impl Visualization { for (y_index, y_facet) in y_facets.clone().enumerate() { let rect = inner.subrect(x_index, nx_facets, y_index, ny_facets); + // If the graph has a colored cell style, outline the whole + // graph in a rectangle with that style. Otherwise, draw X and + // Y axes. if cell_style.color.is_some() { graph_svg.append( Rectangle::new() @@ -766,6 +769,31 @@ impl Visualization { cell_style.color2(Color::BLACK).display_css().to_string(), ), ); + } else { + graph_svg.append( + Line::new() + .set("x1", rect.0[Axis2::X].0) + .set("y1", rect.0[Axis2::Y].0) + .set("x2", rect.0[Axis2::X].0) + .set("y2", rect.0[Axis2::Y].1) + .set("fill", cell_style.fill(&mut patterns)) + .set( + "stroke", + cell_style.color2(Color::BLACK).display_css().to_string(), + ), + ); + graph_svg.append( + Line::new() + .set("x1", rect.0[Axis2::X].0) + .set("y1", rect.0[Axis2::Y].1) + .set("x2", rect.0[Axis2::X].1) + .set("y2", rect.0[Axis2::Y].1) + .set("fill", cell_style.fill(&mut patterns)) + .set( + "stroke", + cell_style.color2(Color::BLACK).display_css().to_string(), + ), + ); } for element in &elements { @@ -1638,6 +1666,9 @@ impl<'a> AxisDomain<'a> { } fn ticks(&self) -> Vec<(f64, String)> { let mut ticks = Vec::new(); + if self.major_ticks.is_none() { + return ticks; + } match &self.domain { Domain::Interval { min: Some(min), diff --git a/rust/pspp/src/spv/testdata/graph2.expected.svg b/rust/pspp/src/spv/testdata/graph2.expected.svg index c343ab61ab..64f75595b1 100644 --- a/rust/pspp/src/spv/testdata/graph2.expected.svg +++ b/rust/pspp/src/spv/testdata/graph2.expected.svg @@ -3,154 +3,57 @@ Title + + - + - + - - - - - -10 - - -15 - - + + + V2 - - -0 - - -10 - - -20 - - -30 - - -40 - - -50 - - -60 - - - - - - - - - + + + - + - + - - - - - - -0.575 - - -0.58 - - -0.585 - - + + + V1 - - -0 - - -10 - - -20 - - -30 - - -40 - - -50 - - - - - - - - + + + - + - + - - - - - - -30 - - -35 - - -40 - - + + + V3 - - -0 - - -10 - - -20 - - -30 - - - - - - +