]> pintos-os.org Git - pspp/commitdiff
fix ticks and labels
authorBen Pfaff <blp@cs.stanford.edu>
Wed, 24 Jun 2026 16:42:36 +0000 (09:42 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Wed, 24 Jun 2026 16:42:36 +0000 (09:42 -0700)
rust/pspp/src/spv/read/graph.rs
rust/pspp/src/spv/testdata/graph5.xml

index 19ad65407927bc85133b1242a86785ed0f17e765..2d8bfe6d61a59c459139a39684b7ab6ae16e4148 100644 (file)
@@ -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"),
+                    );
             }
         }
 
index ef25f454d01647198806d0c4a295530aa0c29ba1..4f06ca6e33dafb770fd5b0ba0b37ca44fc374d7a 100644 (file)
       </dimension>
     </coordinates>
     <faceting id="faceting_1332" method="cross">
-      <nest id="cross_1333">
+      <cross id="cross_1333">
         <variableReference ref="variable11" />
         <variableReference ref="variable12" />
-      </nest>
+      </cross>
     </faceting>
     <facetLayout id="facetLayout_1336" topDown="true">
       <facetLevel gap="2%" id="facetLabel_panel_1" level="1">
-             <axis id="axis_panel_1" combineAxisLabels="false" opposite="true" repeat="never" style="axis_panel_1s">
+        <axis id="axis_panel_1" opposite="true" repeat="never" style="axis_panel_1s">
           <label id="label_panel_1" style="style_1343" textFrameStyle="style_1341">
             <text id="text_1340">Variable 11</text>
           </label>