February 2019
Beginner to intermediate
284 pages
6h 20m
English
The type property should be scatter. Scatter charts support the same properties as line charts, but instead of an array of numbers, the data property should contain an array of point objects with the following structure:
{ x: number, y: number }
The following example creates a simple scatter chart with a single dataset. The data values consist of a sequence of numbers generated for the x property, and the sine function of each number for the y property:
const dataset = []; for(let i = 0; i <= 360; i+= 5) { const point = { x: i, y: Math.sin(i * Math.PI / 180) } dataset.push(point); } const dataObj = { datasets: [ { data: dataset, pointRadius: 2, backgroundColor: 'red' } ] } const chartObj = { type: "scatter", data: ...Read now
Unlock full access