diff client/src/components/gauge/HydrologicalConditions.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 d91c1200dc6b
children de0d0685a17b
line wrap: on
line diff
--- a/client/src/components/gauge/HydrologicalConditions.vue	Thu May 16 11:00:19 2019 +0200
+++ b/client/src/components/gauge/HydrologicalConditions.vue	Thu May 16 11:28:44 2019 +0200
@@ -216,7 +216,22 @@
               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] +
+                "): Hydrological Conditions " +
+                this.longtermInterval.join(" - ");
+              this.addDiagramTitle(
+                e.position,
+                e.offset,
+                e.fontsize,
+                e.color,
+                gaugeInfo
+              );
               break;
             }
             case "diagramlegend": {
@@ -359,42 +374,6 @@
           });
       }
     },
-    // Gauge info as title
-    addDiagramTitle(position, offset, size, color) {
-      let x = offset.x,
-        y = offset.y;
-      let gaugeInfo =
-        this.selectedGauge.properties.objname +
-        " (" +
-        this.selectedGauge.id
-          .split(".")[1]
-          .replace(/[()]/g, "")
-          .split(",")[3] +
-        "): Hydrological Conditions " +
-        this.longtermInterval.join(" - ");
-      let width =
-        (this.pdf.doc.getStringUnitWidth(gaugeInfo) * size) / (72 / 25.6) +
-        size / 2;
-      // 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(1);
-      }
-      this.pdf.doc.setTextColor(color);
-      this.pdf.doc.setFontSize(size);
-      this.pdf.doc.setFontStyle("bold");
-      this.pdf.doc.text(gaugeInfo, x, y, { baseline: "hanging" });
-    },
-    getTextHeight(numberOfLines) {
-      return (
-        numberOfLines *
-        ((this.pdf.doc.getFontSize() * 25.4) / 80) *
-        this.pdf.doc.getLineHeightFactor()
-      );
-    },
     // Diagram legend
     addDiagramLegend(position, offset, color) {
       let x = offset.x,