Mercurial > gemma
comparison client/src/components/gauge/Waterlevel.vue @ 4228:b8d578e42b4b
pdfprint: generate a new transform object instead of manipulating the given one.
See https://github.com/d3/d3-zoom#zoomTransform
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Tue, 20 Aug 2019 10:10:21 +0200 |
parents | 6f0cd9a551b3 |
children | 0f0628189cd7 |
comparison
equal
deleted
inserted
replaced
4227:849d5ca7cc03 | 4228:b8d578e42b4b |
---|---|
946 }; | 946 }; |
947 zoom.on("zoom", () => { | 947 zoom.on("zoom", () => { |
948 if (d3.event.sourceEvent && d3.event.sourceEvent.type === "brush") | 948 if (d3.event.sourceEvent && d3.event.sourceEvent.type === "brush") |
949 return; // ignore zoom-by-brush | 949 return; // ignore zoom-by-brush |
950 let t = d3.event.transform; | 950 let t = d3.event.transform; |
951 // Set the last zoom level and recalculate x,y for pdf-export | |
952 if (zoomLevel) { | 951 if (zoomLevel) { |
953 t.x = (zoomLevel.x * dimensions.width) / zoomLevel.width; | 952 const tx = (zoomLevel.x * dimensions.width) / zoomLevel.width; |
954 t.k = zoomLevel.k; | 953 const k = zoomLevel.k; |
955 t.y = zoomLevel.y; | 954 const ty = zoomLevel.y; |
956 scaleForZoom(t); | 955 t = d3.zoomIdentity.translate(tx, ty).scale(k); |
957 // reset zoomming after drawing for pdf | |
958 t.k = 1; | |
959 t.x = 0; | |
960 t.y = 0; | |
961 } else { | |
962 scaleForZoom(t); | |
963 } | 956 } |
957 scaleForZoom(t); | |
964 }); | 958 }); |
965 zoom.on("start", () => { | 959 zoom.on("start", () => { |
966 svg.select(".chart-dot").style("opacity", 0); | 960 svg.select(".chart-dot").style("opacity", 0); |
967 svg.select(".chart-tooltip").style("opacity", 0); | 961 svg.select(".chart-tooltip").style("opacity", 0); |
968 }); | 962 }); |