I am a bioinformatician who recently discovered Javascript and I have a question about the canvas element.
Without going into the biological details, according to a set of genes entered by the user, I want to generate a visualization of the position of the genes on each chromosome, here an example of one of the chromosomes (it's still summary, there are not yet legends):
the little black lines represents each gene, but as you can see, this view is very global and we cannot clearly see the genes (which are in reality black rectangle)
I added an another canvas element, the green stroke rectangle, and I want that when the user click to zoom on this fictive rectangle, there is a zoom on this region, exactly like on this exemple: https://canvasjs.com/docs/charts/basics-of-creating-html5-chart/zooming-panning/
I don't know if it's possible with canvas elements, i tried to use contexte.scale(2,2) but it just enlarges the image, without zooming in on it
function zoom() {
var path1 = new Path2D();
path1.rect(20, 150, 1160, 150);
context.stroke(path1);
canvas.addEventListener("click", function(e) {
var r = canvas.getBoundingClientRect(),
x = e.clientX - r.left,
y = e.clientY - r.top;
if (context.isPointInPath(path1, x, y)) {
contexte.scale(2,2)
;
};
})
}
path1 is the green rectangle, as you can see I'm far away to reproduce the exemple on the link (I wanted to try first with a simple click event)
I hope I have clearly expressed the problem
