diff client/src/components/gauge/Waterlevel.vue @ 3285:aac1ca73e92a

client: diagram-template:(cleanup) move reusable pdf-functions to mixins.js
author Fadi Abbud <fadi.abbud@intevation.de>
date Thu, 16 May 2019 11:28:44 +0200
parents 3a7b6eb162db
children a409608dd6b3
line wrap: on
line diff
--- a/client/src/components/gauge/Waterlevel.vue	Thu May 16 11:00:19 2019 +0200
+++ b/client/src/components/gauge/Waterlevel.vue	Thu May 16 11:28:44 2019 +0200
@@ -235,7 +235,25 @@
               break;
             }
             case "diagramtitle": {
-              this.addDiagramTitle(e.position, e.offset, e.fontsize, e.color);
+              let gaugeInfo =
+                this.selectedGauge.properties.objname +
+                " (" +
+                this.selectedGauge.id
+                  .split(".")[1]
+                  .replace(/[()]/g, "")
+                  .split(",")[3] +
+                "):" +
+                " Waterlevel " +
+                this.dateFrom.toLocaleDateString() +
+                " - " +
+                this.dateTo.toLocaleDateString();
+              this.addDiagramTitle(
+                e.position,
+                e.offset,
+                e.fontsize,
+                e.color,
+                gaugeInfo
+              );
               break;
             }
             case "text": {
@@ -368,36 +386,7 @@
       this.pdf.doc.addImage(imgData, "PNG", x, y, width, height);
     },
     // Gauge info as a title for pdf
-    addDiagramTitle(position, offset, size, color) {
-      let gaugeInfo =
-        this.selectedGauge.properties.objname +
-        " (" +
-        this.selectedGauge.id
-          .split(".")[1]
-          .replace(/[()]/g, "")
-          .split(",")[3] +
-        "):" +
-        " Waterlevel " +
-        this.dateFrom.toLocaleDateString() +
-        " - " +
-        this.dateTo.toLocaleDateString();
-      let x = offset.x;
-      let y = offset.y;
-      this.pdf.doc.setTextColor(color);
-      this.pdf.doc.setFontSize(size);
-      this.pdf.doc.setFontStyle("bold");
-      let width = this.pdf.doc.getTextWidth(gaugeInfo) + size / 2;
 
-      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(1);
-      }
-      this.pdf.doc.text(gaugeInfo, x, y, {
-        baseline: "hanging"
-      });
-    },
     getTextHeight(numberOfLines) {
       return (
         numberOfLines *