Legend
Namespace: , the global options for the chart legend is defined in Chart.defaults.plugins.legend
.
WARNING
The doughnut, pie, and polar area charts override the legend defaults. To change the overrides for those chart types, the options are defined in Chart.overrides[type].plugins.legend
.
Position
Position of the legend. Options are:
'top'
'bottom'
'right'
'chartArea'
Alignment of the legend. Options are:
'start'
'end'
Defaults to 'center'
for unrecognized values.
Legend Label Configuration
Namespace: options.plugins.legend.labels
Namespace: options.plugins.legend.title
Legend Item Interface
The following example will create a chart with the legend enabled and turn all of the text red in color.
Custom On Click Actions
It can be common to want to trigger different behaviour when clicking an item in the legend. This can be easily achieved using a callback in the config object.
The default legend click handler is:
Lets say we wanted instead to link the display of the first two datasets. We could change the click handler accordingly.