comparison client/src/lib/mixins.js @ 4456:acb21e7362ce

client: pdf-gen: fix diagram title for pdf (waterlevels, hydrologicalconditions) * refactor diagram title for pdf-generation * move isrsIfo function to mixins.js * remove unused gauginfo function
author Fadi Abbud <fadi.abbud@intevation.de>
date Mon, 23 Sep 2019 09:55:48 +0200
parents e58affd956c5
children 3543af71d04c
comparison
equal deleted inserted replaced
4455:112120ed510d 4456:acb21e7362ce
18 import locale2 from "locale2"; 18 import locale2 from "locale2";
19 import { mapState } from "vuex"; 19 import { mapState } from "vuex";
20 import { HTTP } from "@/lib/http"; 20 import { HTTP } from "@/lib/http";
21 import * as d3 from "d3"; 21 import * as d3 from "d3";
22 22
23 /*eslint no-unused-vars: ["error", { "varsIgnorePattern": "debugSVG" }]*/ 23 /*eslint no-unused-vars: ["error", { "varsIgnorePattern": "[debugSVG|_]" }]*/
24
25 const debugSVG = ({ svg, svgWidth, svgHeight }) => { 24 const debugSVG = ({ svg, svgWidth, svgHeight }) => {
26 d3.select(svg) 25 d3.select(svg)
27 .append("rect") 26 .append("rect")
28 .attr("width", svgWidth) 27 .attr("width", svgWidth)
29 .attr("height", svgHeight) 28 .attr("height", svgHeight)
214 return (dpi * length) / 25.4; 213 return (dpi * length) / 25.4;
215 }, 214 },
216 pixel2millimeter(pixels, dpi) { 215 pixel2millimeter(pixels, dpi) {
217 return (pixels * 25.4) / dpi; 216 return (pixels * 25.4) / dpi;
218 }, 217 },
219 gaugeInfo(selectedGauge) { 218 isrsInfo(gauge) {
220 // returns string with formatted gauge info 219 // See https://www.elwis.de/DE/Service/Daten-und-Fakten/RIS-Index/RIS-Index-node.html
221 return ( 220 const [
222 selectedGauge.properties.objname + 221 _,
223 " (" + 222 countryCode,
224 selectedGauge.id 223 loCode,
225 .split(".")[1] 224 fairwaySection,
226 .replace(/[()]/g, "") 225 orc,
227 .split(",")[3] + 226 hectometre
228 ")" 227 ] = gauge.properties.isrs_code.match(
228 /(\w{2})(\w{3})(\w{5})(\w{5})(\w{5})/
229 ); 229 );
230 return {
231 countryCode: countryCode,
232 loCode: loCode,
233 fairwaySection: fairwaySection,
234 orc: orc,
235 hectometre: hectometre
236 };
230 }, 237 },
231 generatePDF(params) { 238 generatePDF(params) {
232 // creates a new jsPDF object into this.pdf.doc 239 // creates a new jsPDF object into this.pdf.doc
233 // will call functions that the calling context has to provide 240 // will call functions that the calling context has to provide
234 // as specified in the templateData 241 // as specified in the templateData