Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

280
Views
¿Cómo puedo calcular una transformación de objeto de zoom después de la selección de zoom?

En realidad, estoy usando d3js para implementar un gráfico gráfico complejo con comportamiento de zoom. pero durante algunos días me enfrento a un problema real al hacer zoom en el gráfico de líneas usando la selección del pincel de zoom. El error al que me enfrento es que no puedo calcular el buen objeto de transformación para obtener el dominio correcto en los ejes x e y que coincida con el dominio de selección de zoom.

Debajo está mi función de zoom, y lo que espero cuando el usuario hace una selección de zoom, la nueva transformación de zoom calculada mostrará el dominio x e y que el usuario desea.

 let xScale = graphXAxis?.xScale;//original scale let xScaleZoom = graphXAxis?.xScaleZoom;//scale after zoom let yScale = graphYAxis?.yScale;//original scale let yScaleZoom = graphYAxis?.yScaleZoom; // Calc distance on Axis-X to use in scale let totalX = Math.abs(selection.x2 - selection.x1); let totalY = Math.abs(selection.y2 - selection.y1); // Get current point [x,y] on canvas let originalPoint = [xScaleZoom.invert(selection.x1), 0]; if (!zone.isTOR()) { originalPoint = [xScaleZoom.invert(selection.x1), yScaleZoom.invert(selection.y1)]; } // Result in a zoom of 2 let ratioX = graphWidth / totalX; let ratioY = graphHeight / totalY; const t = d3.zoomIdentity.scale(Math.min(ratioX, ratioY) * zoomLastTransformForBrush.k); // Re-scale axis for the new transformation xScaleZoom = t.rescaleX(xScale); let transitionX = xScaleZoom(originalPoint[0]) * -1; let newTransform = null; yScaleZoom = t.rescaleY(yScale); newTransform = d3.zoomIdentity .translate(transitionX, yScaleZoom(originalPoint[1]) * -1) .scale(tk)
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!