February 2019
Beginner to intermediate
284 pages
6h 20m
English
The main data structure you will use to store one-dimensional data is the JavaScript array. It's used as the main dataset format in most chart types in Chart.js. An array of values is all you need to make a simple bar chart. You can create an array by declaring a list of items within brackets, or simply a pair of opening-closing brackets if you want to start with an empty array:
const colors = ["red", "blue", "green"];const geocoords = [27.2345, 34.9937];const numbers = [1,2,3,4,5,6];const empty = [];
You can then access the items of an array using an array index, which starts counting from zero:
const blue = colors[1];const latitude = geocoords[0];
Each array has a length property that returns the number of elements. It's very useful ...
Read now
Unlock full access