changeset 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 c86a8e70b40f
children 8c96b7379aea
files client/src/components/fairway/AvailableFairwayDepth.vue client/src/components/fairway/AvailableFairwayDepthLNWL.vue
diffstat 2 files changed, 22 insertions(+), 2 deletions(-) [+]
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)");
--- a/client/src/components/fairway/AvailableFairwayDepthLNWL.vue	Mon May 20 16:36:19 2019 +0200
+++ b/client/src/components/fairway/AvailableFairwayDepthLNWL.vue	Mon May 20 16:54:52 2019 +0200
@@ -363,8 +363,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;
 
-      this.pdf.doc.setFontSize(10);
+      // 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.setTextColor(color);
       this.pdf.doc.setDrawColor("rgb(255, 133, 94)");
       this.pdf.doc.setFillColor("rgb(255, 133, 94)");