I have Html canvas code that draws the following graph. Is there an easy way of zooming the area that is outlined with red rectangle without rewriting the code? This area is always top right quarter of the graph and I also would like to leave some space for the axis.
Asked
Active
Viewed 199 times
1 Answers
0
So, I found the solution:
- Draw two times bigger original canvas
Retrieve and put the region image on new canvas:
var imgData = ctx.getImageData(canvas.width/2 - 20, 0, canvas.width/2 + 20, canvas.width/2 + 20); ctx.clearRect(0, 0, canvas.width, canvas.height); canvas.width /= 2 canvas.height /= 2 canvas.height += 20 ctx.putImageData(imgData, 0, 0);

bvk256
- 1,837
- 3
- 20
- 38