]> pintos-os.org Git - pspp/commitdiff
properly fix x-axis labeling
authorBen Pfaff <blp@cs.stanford.edu>
Tue, 14 Jul 2026 22:06:01 +0000 (15:06 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Tue, 14 Jul 2026 22:06:01 +0000 (15:06 -0700)
rust/pspp/src/spv/read/graph.rs
rust/pspp/src/spv/testdata/graph5.expected.svg

index 78699f82ffec9688730e561f00b093a8a2a281cc..dabe3ab6c9ef8107d35adef6686c774a7f607f95 100644 (file)
@@ -49,7 +49,7 @@ use svg::{
 };
 
 use crate::{
-    data::{Datum, OwnedDatum},
+    data::Datum,
     format::{Type, UncheckedFormat},
     locale::{Item, Locale, data::EN},
     output::{
@@ -675,7 +675,7 @@ impl Visualization {
             &mut axis_domains,
             styles,
         )?;
-        dbg!(&axis_domains);
+        //dbg!(&axis_domains);
         let elements = self.pass(
             &graph,
             locale,
@@ -685,7 +685,7 @@ impl Visualization {
             &mut axis_domains,
             styles,
         )?;
-        dbg!(&axis_domains);
+        //dbg!(&axis_domains);
 
         let font_metrics = FontMetrics::new();
         let font_height = font_metrics.measure("0")[Axis2::Y];
@@ -1682,6 +1682,7 @@ impl<'a> AxisDomain<'a> {
         }
     }
     fn ticks(&self) -> Vec<(f64, String)> {
+        dbg!(&self.domain);
         let mut ticks = Vec::new();
         match &self.domain {
             Domain::Interval {
@@ -1714,21 +1715,19 @@ impl<'a> AxisDomain<'a> {
                     if self.domain.lookup(value).is_some() {
                         let left = index as f64 / values.len() as f64;
                         let right = (index + 1) as f64 / values.len() as f64;
-                        let value = left.midpoint(right);
+                        let fraction = left.midpoint(right);
                         ticks.push((
-                            value,
-                            label.clone().unwrap_or({
-                                self.formatter
-                                    .display(&OwnedDatum::Number(Some(value)))
-                                    .to_string()
-                            }),
+                            fraction,
+                            label
+                                .clone()
+                                .unwrap_or_else(|| self.formatter.display(value).to_string()),
                         ));
                     }
                 }
             }
             _ => (),
         };
-        ticks
+        dbg!(ticks)
     }
 }
 
index 07bf487766bfe248b0e858a0ac5d9b7d6b8a8a5e..4afd31b926cf2e200b330d54cf5589f7ee174a56 100644 (file)
@@ -50,16 +50,16 @@ V11-2
 <line stroke="black" x1="294.6875" x2="294.6875" y1="0" y2="10"/>
 <line stroke="black" x1="410.5625" x2="410.5625" y1="0" y2="10"/>
 <text dominant-baseline="hanging" text-anchor="middle" x="57.9375" y="10">
-.25
+101.10
 </text>
 <text dominant-baseline="hanging" text-anchor="middle" x="173.8125" y="10">
-.75
+102.10
 </text>
 <text dominant-baseline="hanging" text-anchor="middle" x="294.6875" y="10">
-.25
+101.10
 </text>
 <text dominant-baseline="hanging" text-anchor="middle" x="410.5625" y="10">
-.75
+102.10
 </text>
 <text dominant-baseline="hanging" text-anchor="middle" x="234.25" y="33">
 Variable 4