diff client/src/components/fairway/AvailableFairwayDepth.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 707d4435aff3
children 80ed54cd4210
line wrap: on
line diff
--- a/client/src/components/fairway/AvailableFairwayDepth.vue	Thu May 16 11:00:19 2019 +0200
+++ b/client/src/components/fairway/AvailableFairwayDepth.vue	Thu May 16 11:28:44 2019 +0200
@@ -62,6 +62,7 @@
  * Author(s):
  * Thomas Junk <thomas.junk@intevation.de>
  * Markus Kottländer <markus.kottlaender@intevation.de>
+ * Fadi Abbud <fadi.abbud@intevation.de>
  */
 import * as d3 from "d3";
 import app from "@/main";
@@ -123,7 +124,7 @@
           {
             type: "diagramtitle",
             position: "topleft",
-            offset: { x: 20, y: 20 },
+            offset: { x: 70, y: 20 },
             fontsize: 20,
             color: "steelblue"
           },
@@ -255,11 +256,13 @@
               break;
             }
             case "diagramtitle": {
+              let title = `Available Fairway Depth: ${this.featureName}`;
               this.addDiagramTitle(
                 e.position,
                 e.offset || defaultOffset,
                 e.fontsize || defaultFontSize,
-                e.color || defaultColor
+                e.color || defaultColor,
+                title
               );
               break;
             }
@@ -356,26 +359,6 @@
       var imgData = canvas.toDataURL("image/png");
       this.pdf.doc.addImage(imgData, "PNG", x, y, width, height);
     },
-    addDiagramTitle(position, offset, size, color) {
-      let x = offset.x,
-        y = offset.y;
-      let title = `Available Fairway Depth: ${this.featureName}`;
-      let width =
-        (this.pdf.doc.getStringUnitWidth(title) * 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(title, x, y, { baseline: "hanging" });
-    },
     addDiagramLegend(position, offset, color) {
       let x = offset.x,
         y = offset.y;