This code demonstrates how to set up a canvas in vanilla js, if it is what you asked. I have commented it so that it is easier to understand what it is doing. I haven't tested if the code actually works, but it should. If someone notices it doesn't work, please inform me.
Edit: of course this is a bit complicated way, but if you take a deeper look at it and use google a little, you'll be able to understand it.
It depends on what you are trying to do with the canvas, so overall, whether you are doing geographic work, your goal is to estimate the grapheque on the canvas, or if your work is working on three-dimensional images. For all of this, there are several solutions to expect. For example, some map servers such as MapBpox or Google themselves use canavas for GIS-related tasks. Some sources in this area may help you, like https://canvasjs.com/. If you ask your question more clearly and express the scope, you may also receive an answer. Thank you.