Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learn Chart.js

You're reading from   Learn Chart.js Create interactive visualizations for the Web with Chart.js 2

Arrow left icon
Product type Paperback
Published in Feb 2019
Publisher
ISBN-13 9781789342482
Length 284 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Helder da Rocha Helder da Rocha
Author Profile Icon Helder da Rocha
Helder da Rocha
Arrow right icon
View More author details
Toc

Table of Contents (9) Chapters Close

Preface 1. Introduction 2. Technology Fundamentals FREE CHAPTER 3. Chart.js - Quick Start 4. Creating Charts 5. Scales and Grid Configuration 6. Configuring Styles and Interactivity 7. Advanced Chart.js 8. Other Books You May Enjoy

Category scales


Typical bar and line charts use a category scale for the x axis, and a numeric scale for the y axis. Multiple datasets reuse the same category data. In these charts, the values used for the category axis are obtained from the labels property of the data object. If a dataset has a labels property, its x axis will automatically be defined as type:category.

Configuring the axes

Category scales share the same axis configuration as numeric charts, but support some additional properties in the axis and axis.ticks objects. The axis object has one additional property that can be used to override the data object labels for an axis:

Property

Value

Description

labels

Array of String

An array of labels to display. Overrides any other definition for labels, including data object properties: labels, xLabels, or yLabels.

Additional axis configuration for category scales

The following code fragment shows category labels defined in three different properties. Since the single x axis contains a labels...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime