Created
June 21, 2018 09:04
-
-
Save levvsha/e5a2c09b9f2bd0a15adabeac3b064d14 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function zoomed() { | |
| const transformation = d3.event.transform; | |
| const rightEdge = Math.abs(transformation.x) / transformation.k + width / transformation.k; | |
| const bottomEdge = Math.abs(transformation.y) / transformation.k + height / transformation.k; | |
| if (rightEdge > width) { | |
| transformation.x = -(width * transformation.k - width); | |
| } | |
| if (bottomEdge > height) { | |
| transformation.y = -(height * transformation.k - height); | |
| } | |
| rescaledX = transformation.rescaleX(x); | |
| rescaledY = transformation.rescaleY(y); | |
| xAxisElement.call(xAxis.scale(rescaledX)); | |
| yAxisElement.call(yAxis.scale(rescaledY)); | |
| linesContainer.selectAll('path') | |
| .attr('d', regionId => { | |
| return d3.line() | |
| .defined(d => d.percent !== 0) | |
| .x(d => rescaledX(d.date)) | |
| .y(d => rescaledY(d.percent))(regions[regionId].data); | |
| }); | |
| voronoiGroup | |
| .attr('transform', transformation); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment