When performance becomes a problem, switching to canvas can be an option. In this case, you can draw the canvas once. Subsequently, he was largely regarded as an image. Drawing can take some time, but you can scale it pretty quickly later. Note that you can draw SVG rendering on canvas using the context.drawImage method ( example ). That way, you can save the SVG generation code to create the SVG in the background, and then draw it on the canvas.
But keep in mind that it will not scale as beautifully as SVG once it is on canvas. When the user zooms in, they will be blurry or pixelated, depending on how the browser scales the graphics.
There are two ways to click events on the canvas. Or save an array of targeted clicks, and add an onclick event handler to the canvas. When a click occurs, iterate through the array and check which one is closest to the coordinates of the click.
Another option is to use delete areas . They must be defined as polygonal paths.
source share