diff client/src/components/fairway/AvailableFairwayDepth.vue @ 3333:d5dbfba9faae

clinet: pdf-template: fix positioning of diagramlegend (FairwayAvailability,AvailableFairwayDepth)
author Fadi Abbud <fadi.abbud@intevation.de>
date Mon, 20 May 2019 16:54:52 +0200
parents 0e442b547f6d
children cd745be63f71
line wrap: on
line diff
--- a/client/src/components/fairway/AvailableFairwayDepth.vue	Mon May 20 16:36:19 2019 +0200
+++ b/client/src/components/fairway/AvailableFairwayDepth.vue	Mon May 20 16:54:52 2019 +0200
@@ -372,8 +372,18 @@
     addDiagramLegend(position, offset, color) {
       let x = offset.x,
         y = offset.y;
+      this.pdf.doc.setFontSize(10);
+      let width =
+        (this.pdf.doc.getStringUnitWidth(">= LDC [h]") * 10) / (72 / 25.6) + 15;
+      // if position is on the right, x needs to be calculate with pdf width and
+      // the size of the element
+      if (["topright", "bottomright"].indexOf(position) !== -1) {
+        x = this.pdf.width - offset.x - width;
+      }
+      if (["bottomright", "bottomleft"].indexOf(position) !== -1) {
+        y = this.pdf.height - offset.y - this.getTextHeight(7);
+      }
 
-      this.pdf.doc.setFontSize(10);
       this.pdf.doc.setTextColor(color);
       this.pdf.doc.setDrawColor("rgb(255, 133, 94)");
       this.pdf.doc.setFillColor("rgb(255, 133, 94)");