Commit 63fc3689 authored by Paul Asmuth's avatar Paul Asmuth
Browse files

implement arbitrary legend positioning

parent 92d85e68
Loading
Loading
Loading
Loading
+24 −2
Original line number Diff line number Diff line
@@ -253,10 +253,32 @@ ReturnCode legend_draw(
      return rc;
    }

    border_box.x = parent_box.x;
    border_box.y = parent_box.y;
    border_box.h = std::min(eh, parent_box.h);
    border_box.w = std::min(ew, parent_box.w);

    switch (config->position_horiz) {
      case HAlign::LEFT:
        border_box.x = parent_box.x;
        break;
      case HAlign::CENTER:
        border_box.x = parent_box.x + parent_box.w * 0.5 - border_box.w * 0.5;
        break;
      case HAlign::RIGHT:
        border_box.x = parent_box.x + parent_box.w - border_box.w;
        break;
    }

    switch (config->position_vert) {
      case VAlign::TOP:
        border_box.y = parent_box.y;
        break;
      case VAlign::CENTER:
        border_box.y = parent_box.y + parent_box.h * 0.5 - border_box.h * 0.5;
        break;
      case VAlign::BOTTOM:
        border_box.y = parent_box.y + parent_box.h - border_box.h;
        break;
    }
  }

  auto content_box = layout_margin_box(
+15 −0
Original line number Diff line number Diff line
(set width 900px)
(set height 600px)
(set font-size 14pt)

(legend
  position (bottom center)
  items (
    (legend/item label "Fnord Test 1" color #06c)
    (legend/item label "Fnord Test 2" color #c06)
    (legend/item label "Fnord Test 3" color #c06)
    (legend/item label "Fnord Test 4" color #c06)
    (legend/item label "Fnord Test 5" color #6c0)))


+17 −0
Original line number Diff line number Diff line
<svg xmlns="http://www.w3.org/2000/svg" width="900.000000" height="600.000000" viewBox="0 0 900 600">
  <rect width="900.000000" height="600.000000" fill="#ffffff"/>
  <path stroke-width="1.000000" stroke="#333333" fill="none" d="M359.68 400.422 L540.32 400.422 "/>
  <path stroke-width="1.000000" stroke="#333333" fill="none" d="M540.32 400.422 L540.32 575.111 "/>
  <path stroke-width="1.000000" stroke="#333333" fill="none" d="M359.68 575.111 L540.32 575.111 "/>
  <path stroke-width="1.000000" stroke="#333333" fill="none" d="M359.68 400.422 L359.68 575.111 "/>
  <text x="411.946701" y="437.333333" fill="#333333" font-size="18.666667" font-family="Arial,Helvetica,'Helvetica Neue',sans-serif">Fnord Test 1</text>
  <path fill="#0066cc" d="M396.547 430.833 M382.547 430.833 a7 7 0 1 0 14 0 a7 7 0 1 0 -14 0 "/>
  <text x="411.946701" y="465.800000" fill="#333333" font-size="18.666667" font-family="Arial,Helvetica,'Helvetica Neue',sans-serif">Fnord Test 2</text>
  <path fill="#cc0066" d="M396.547 459.3 M382.547 459.3 a7 7 0 1 0 14 0 a7 7 0 1 0 -14 0 "/>
  <text x="411.946701" y="494.266667" fill="#333333" font-size="18.666667" font-family="Arial,Helvetica,'Helvetica Neue',sans-serif">Fnord Test 3</text>
  <path fill="#cc0066" d="M396.547 487.767 M382.547 487.767 a7 7 0 1 0 14 0 a7 7 0 1 0 -14 0 "/>
  <text x="411.946701" y="522.733333" fill="#333333" font-size="18.666667" font-family="Arial,Helvetica,'Helvetica Neue',sans-serif">Fnord Test 4</text>
  <path fill="#cc0066" d="M396.547 516.233 M382.547 516.233 a7 7 0 1 0 14 0 a7 7 0 1 0 -14 0 "/>
  <text x="411.946701" y="551.200000" fill="#333333" font-size="18.666667" font-family="Arial,Helvetica,'Helvetica Neue',sans-serif">Fnord Test 5</text>
  <path fill="#66cc00" d="M396.547 544.7 M382.547 544.7 a7 7 0 1 0 14 0 a7 7 0 1 0 -14 0 "/>
</svg>
 No newline at end of file
+14 −0
Original line number Diff line number Diff line
(set width 900px)
(set height 600px)
(set font-size 14pt)

(legend
  position (bottom left)
  items (
    (legend/item label "Fnord Test 1" color #06c)
    (legend/item label "Fnord Test 2" color #c06)
    (legend/item label "Fnord Test 3" color #c06)
    (legend/item label "Fnord Test 4" color #c06)
    (legend/item label "Fnord Test 5" color #6c0)))

+17 −0
Original line number Diff line number Diff line
<svg xmlns="http://www.w3.org/2000/svg" width="900.000000" height="600.000000" viewBox="0 0 900 600">
  <rect width="900.000000" height="600.000000" fill="#ffffff"/>
  <path stroke-width="1.000000" stroke="#333333" fill="none" d="M24.8889 400.422 L205.529 400.422 "/>
  <path stroke-width="1.000000" stroke="#333333" fill="none" d="M205.529 400.422 L205.529 575.111 "/>
  <path stroke-width="1.000000" stroke="#333333" fill="none" d="M24.8889 575.111 L205.529 575.111 "/>
  <path stroke-width="1.000000" stroke="#333333" fill="none" d="M24.8889 400.422 L24.8889 575.111 "/>
  <text x="77.155556" y="437.333333" fill="#333333" font-size="18.666667" font-family="Arial,Helvetica,'Helvetica Neue',sans-serif">Fnord Test 1</text>
  <path fill="#0066cc" d="M61.7556 430.833 M47.7556 430.833 a7 7 0 1 0 14 0 a7 7 0 1 0 -14 0 "/>
  <text x="77.155556" y="465.800000" fill="#333333" font-size="18.666667" font-family="Arial,Helvetica,'Helvetica Neue',sans-serif">Fnord Test 2</text>
  <path fill="#cc0066" d="M61.7556 459.3 M47.7556 459.3 a7 7 0 1 0 14 0 a7 7 0 1 0 -14 0 "/>
  <text x="77.155556" y="494.266667" fill="#333333" font-size="18.666667" font-family="Arial,Helvetica,'Helvetica Neue',sans-serif">Fnord Test 3</text>
  <path fill="#cc0066" d="M61.7556 487.767 M47.7556 487.767 a7 7 0 1 0 14 0 a7 7 0 1 0 -14 0 "/>
  <text x="77.155556" y="522.733333" fill="#333333" font-size="18.666667" font-family="Arial,Helvetica,'Helvetica Neue',sans-serif">Fnord Test 4</text>
  <path fill="#cc0066" d="M61.7556 516.233 M47.7556 516.233 a7 7 0 1 0 14 0 a7 7 0 1 0 -14 0 "/>
  <text x="77.155556" y="551.200000" fill="#333333" font-size="18.666667" font-family="Arial,Helvetica,'Helvetica Neue',sans-serif">Fnord Test 5</text>
  <path fill="#66cc00" d="M61.7556 544.7 M47.7556 544.7 a7 7 0 1 0 14 0 a7 7 0 1 0 -14 0 "/>
</svg>
 No newline at end of file
Loading