Canvas in JS - smallQuerty/canvas_charts GitHub Wiki

Add in html

A canvas is a rectangular area on an HTML page. By default, a canvas has no border and no content.

in html file you must always create specific canvas for work

<canvas id="myCanvas" width="200" height="100"></canvas>

Note: Always specify an id attribute (to be referred to in a script), and a width and height attribute to define the size of the canvas. To add a border, use the style attribute.

Add a JavaScript

After creating the rectangular canvas area, you must add a JavaScript to do the drawing. Expale for calling your canvas:

<script> let content=document.getElementById("canvas").getContext("2d"); </script>

⚠️ **GitHub.com Fallback** ⚠️