Mercurial > gemma
diff client/src/components/fairway/Fairwayprofile.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 | 246754028bf4 |
children | de0d0685a17b |
line wrap: on
line diff
--- a/client/src/components/fairway/Fairwayprofile.vue Thu May 16 11:00:19 2019 +0200 +++ b/client/src/components/fairway/Fairwayprofile.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 { mapState, mapGetters } from "vuex"; @@ -297,7 +298,18 @@ break; } case "diagramtitle": { - this.addDiagramTitle(e.position, e.offset, e.fontsize, e.color); + let fairwayInfo = + this.selectedBottleneck + + " (" + + this.selectedSurvey.date_info + + ")"; + this.addDiagramTitle( + e.position, + e.offset, + e.fontsize, + e.color, + fairwayInfo + ); break; } case "image": { @@ -386,27 +398,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 fairwayInfo = - this.selectedBottleneck + " (" + this.selectedSurvey.date_info + ")"; - let width = - (this.pdf.doc.getStringUnitWidth(fairwayInfo) * 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(fairwayInfo, x, y, { baseline: "hanging" }); - }, // Diagram legend addDiagramLegend(position, offset, color) { let x = offset.x, @@ -432,13 +423,6 @@ this.pdf.doc.circle(x, y + 10, 2, "FD"); this.pdf.doc.text(x + 3, y + 11, "Ground"); }, - getTextHeight(numberOfLines) { - return ( - numberOfLines * - ((this.pdf.doc.getFontSize() * 25.4) / 80) * - this.pdf.doc.getLineHeightFactor() - ); - }, calcRelativeDepth(depth) { /* takes a depth value and substracts the delta of the relative waterlevel * say the reference level is above the current level, the ground is nearer,