Skip to content

Latest commit

 

History

History
43 lines (30 loc) · 2.4 KB

201-class12.md

File metadata and controls

43 lines (30 loc) · 2.4 KB

Class 201.12

Notes

Readings

Q&A's

JavaScript Canvas

  1. What does the <canvas> allow a developer to acheive?

The <canvas> element allows a developer to draw 2D graphics using JavaScript code. It provides a region that can be manipulated via a JavaScript interface.

  1. What is the importance of the closing </canvas> tag?

The closing </canvas> tag is important because the <canvas> element requires an opening and closing tag, (unlike the <img> element). Any content between the opening and closing tags is fallback content that will only display if the browser does not support the <canvas> element.

  1. Explain what the getContext() method does.

The getContext() method returns a rendering context object that provides methods and properties for drawing on the <canvas>. It takes one parameter, the context type such as '2d', and returns an instance of a context interface like CanvasRenderingContext2D. This context interface exposes methods like fillRect() and strokeRect() that can be used to draw different shapes and graphics. So getContext() provides the actual drawing API after it is called on a <canvas> element.

Chart.js

  1. What is Chart.js and how it can be brought into your project?

it's a charting library for javascript

  1. List 3 different Chart types you can create using Chart.js

Area, Bar, Bubble

  1. What are some advantages to displaying data via a chart over a table?

humans are visual, charts are more visual than tables

  1. How could Chart.js aid your previously created applications visually?

cookie-stand: we could see a bar graph of sales per location/hour at a glance odd-duck: we can visualize which products are ones we should prioritize

References

  • Google Bard and ChatGPT