# HG changeset patch # User Fadi Abbud # Date 1558364092 -7200 # Node ID d5dbfba9faaed82cc51dc4f1ce954b4f9bb104f7 # Parent c86a8e70b40f8968b1b092add9bd996b3c362752 clinet: pdf-template: fix positioning of diagramlegend (FairwayAvailability,AvailableFairwayDepth) diff -r c86a8e70b40f -r d5dbfba9faae client/src/components/fairway/AvailableFairwayDepth.vue --- 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)"); diff -r c86a8e70b40f -r d5dbfba9faae client/src/components/fairway/AvailableFairwayDepthLNWL.vue --- 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)");