Skip to content

Commit

Permalink
Zoomen in die Region, wo sich Brush befand
Browse files Browse the repository at this point in the history
  • Loading branch information
julia221501 committed Aug 3, 2023
1 parent 9d426d5 commit 6b07c10
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/components/NetworkMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -463,9 +463,23 @@ export default defineComponent({
];
if (extent) {
const { x, y, k } = d3.zoomIdentity
.translate(-extent[0][0], -extent[0][1])
.scale(212 / (extent[1][0] - extent[0][0]));
// Calculate the width and height of the brush
const x0 = extent[0][0];
const y0 = extent[0][1];
const x1 = extent[1][0];
const y1 = extent[1][1];
const width = x1 - x0;
const height = y1 - y0;
// Calculate the scale depending on the size of the brush extent
const maxExtent = Math.max(width, height);
const maxBrushExtent = 212;
const scaleFactor = maxBrushExtent / maxExtent;
// Apply the new zoom transformation to the mapContainer
const x = -x0 * scaleFactor;
const y = -y0 * scaleFactor;
const k = scaleFactor;
const mapContainer = d3.select("#mapContainer");
mapContainer
Expand Down

0 comments on commit 6b07c10

Please sign in to comment.