Skip to the content.

Code 102: Class 12 Reading Notes

Readings: Readings: Chart.js, Canvas

ChartJS

Steps on how to download chartjs library like we did for lab 12. and how it can draw various charts such as pie, bar.

Basic Chart Usage

Interestingly you can stlye canvas like an image element. IT does have a default 300 width, and 150 height in pixels.

You can also give it fallback codes by giving it a closing canvas tag with descriptions of the chart, or a baisc fallback image to convey chart.

Drawing Shapes in Canvas

You can draw shapes in canvas such as rectangles, triangles, squares, even a scary smiley face, and lines

Scary Smiley Drawn with Canvas

Applying Styles and Colors

There are a lot of customizations to change color and styles, gradiants, etc.

Drawing Text

You can add text by including in the function: ctx.fillText(‘the text’); and can also style it

Things I want to learn more about

Out of all these articles the main thing I took away is I can draw a smiley face. I want to try.