diff client/src/lib/mixins.js @ 4809:b6d8570b8480

client: image-export: add diagram legend
author Fadi Abbud <fadi.abbud@intevation.de>
date Tue, 29 Oct 2019 16:29:29 +0100
parents db450fcc8ed7
children 660147046ddd
line wrap: on
line diff
--- a/client/src/lib/mixins.js	Tue Oct 29 11:04:14 2019 +0100
+++ b/client/src/lib/mixins.js	Tue Oct 29 16:29:29 2019 +0100
@@ -191,7 +191,7 @@
       diagramContainer.querySelector("svg").setAttribute("width", clientWidth);
       diagramContainer
         .querySelector("svg")
-        .setAttribute("height", clientHeight + 70);
+        .setAttribute("height", clientHeight + 180);
       const svg = diagramContainer.querySelector("svg").outerHTML;
       const canvas = document.createElement("canvas");
       canvg(canvas, svg, { offsetY: 70 });
@@ -206,6 +206,11 @@
       ctx.textAlign = "center";
       ctx.fillText(title, clientWidth / 2, 35);
       ctx.closePath();
+      // Add diagramlegend
+      this.addLegendToCanvas(ctx, {
+        height: clientHeight + 100,
+        width: clientWidth
+      });
 
       const imgData = canvas.toDataURL("image/png");
       document.getElementById(elementName).setAttribute("href", imgData);