February 2019
Beginner to intermediate
284 pages
6h 20m
English
Charts are displayed inside the graphics context provided by an HTML Canvas object. There are many ways to create one; the simplest way is to use plain HTML. Place a <canvas> element somewhere inside <body>. It should have an ID attribute, as follows:
<canvas id="my-bar-chart" width="200" height="200"></canvas>
Chart.js graphics are responsive by default. The chart will fit in the available space: the height and width attributes won't affect the actual size of the chart (unless you change the defaults).
You can obtain a JavaScript handle to the canvas object using DOM (or JQuery) in any script block or file loaded by your HTML file, as shown in the following code snippet (the script block will be ignored in ...
Read now
Unlock full access