Skip to Main Content
Learn Chart.js
book

Learn Chart.js

by Helder da Rocha
February 2019
Beginner to intermediate content levelBeginner to intermediate
284 pages
6h 20m
English
Packt Publishing
Content preview from Learn Chart.js

Dataset configuration

Dataset-specific options can be applied to control attributes, such as color and width of each line. Adding a borderColor attribute to the dataset will set the color of the line (and legend box), as follows:

let dataObj = {     labels: labels,     datasets: [{         data: values,         borderColor: 'hsla(300,100%,50%,1)'         backgroundColor: 'transparent';     }] }

The following chart shows the effect of setting borderColor and backgroundColor for a dataset. This configuration only affects one dataset. You can also configure properties that affect all datasets. In this example, the legend was also removed using the options configuration (explained in a separate section). You can see the full code in LineArea/line-2.html, as shown in the following ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Pro D3.js: Use D3.js to Create Maintainable, Modular, and Testable Charts

Pro D3.js: Use D3.js to Create Maintainable, Modular, and Testable Charts

Marcos Iglesias

Publisher Resources

ISBN: 9781789342482OtherErrata PagePurchase Link