Legends and labels

Legends are displayed by default in bar, line, pie and doughnut charts. They appear as a list of labeled, colored boxes that relate to the color of the lines, bars, or slices represented by a dataset, and they are rendered on the screen even when there is a single dataset. In such cases, you may wish to hide them. You can also tune several other properties and callbacks. The most important properties are listed as follows:

Property

Value

Description

Display

true or false

Shows or hides the legend of the chart. The default is true.

Position

'top', 'bottom', 'left', 'right'

Selects the position of the label in relation to the chart. The default is 'top'.

Reverse

true or false

Reverses the order ...

Get Learn Chart.js now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.