Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

165
Vistas
JS canvas zoom and pan with large data (100k-1M objects)

I want to implement fast and high-res zooming and panning on my Canvas. As you may already read in the title, I have a lot of data, so using CanvasRenderingContext2D.scale() and CanvasRenderingContext2D.translate() with redrawing isn't an option, because it is way to laggy. I already tried using Images, but I want to see all the data-points while zooming and panning. Drawing only the data-points that are visible is a good start, but this makes the zooming and panning only possible on a very close zoom, but I actually want to be able to zoom out until I can see all the data points. The data points are drawn with circles and are very close together if that helps you in any way. I appreciate every suggestion on how to handle this.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

I think You should try one of these:

  1. WebGL (it is something line OpenGL for web browesers)
    materials: khronos group web page repo: GitHub
  2. three.js materials: three.js web page repo: GitHub

I sugested them because they are able towork with 2D also (not only wth 3D) and they have tolls to work with big textures. You can create static camera which will just change the distance to the surface (with texture) - zoom.

With Three.js there is a way to load bitmaps progressively with mipmap chains or with "Prefiltered, Mipmapped Radiance Environment Map: PMREMGenerator.

about 4 years ago · Juan Pablo Isaza Denunciar

0

An alternative approach that worked for me was having a (hidden) canvas for drawing and a viewport canvas the user could see. Drawing on the hidden canvas allows you to draw a bigger image, and then simply update the viewport by redrawing the canvas to view only the middle part (you can use viewportContext.drawImage(sourceCanvas, -canvasWidth / 2, -canvasHeight / 2) to draw from one canvas to another).

To implement zooming and panning, I would simply store the image from the source canvas at the beginning (on mouseDown or scroll) and redraw it according to new mouse position/scroll (simply translating it or changing its dimensions will work) to the source canvas.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda