Legend
The chart legend displays data about the datasets that are appearing on the chart.
Namespace: options.plugins.legend
Display¶
Is the legend shown? Default true
.
Position¶
Position of the legend. Default top
.
Align¶
Alignment of the legend. Default center
.
MaxHeight¶
Maximum height of the legend, in pixels.
MaxWidth¶
Maximum width of the legend, in pixels.
FullSize¶
Marks that this box should take the full width/height of the canvas (moving other boxes).
This is unlikely to need to be changed in day-to-day use. Default true
.
OnClick¶
A callback that is called when a click event is registered on a label item.
Arguments: [event, legendItem, legend]
.
OnHover¶
A callback that is called when a 'mousemove' event is registered on top of a label item.
Arguments: [event, legendItem, legend]
.
OnLeave¶
A callback that is called when a 'mousemove' event is registered outside of a previously hovered label item.
Arguments: [event, legendItem, legend]
.
Reverse¶
Legend will show datasets in reverse order. Default false
.
Rtl¶
true
for rendering the legends from right to left.
TextDirection¶
This will force the text direction 'rtl'
or 'ltr'
on the canvas for rendering the legend,
regardless of the css specified on the canvas.
Title Settings¶
Color¶
Display¶
Is the legend title displayed. Default false
Font¶
Padding¶
Padding around the title.
See padding configuration.Text¶
The string title.
Labels Settings¶
BoxWidth¶
Width of coloured box. Default 40
BoxHeight¶
Height of the coloured box. Default font.size
Color¶
Color of label and the strikethrough.
Font¶
Padding¶
Padding between rows of colored boxes. Default 10
GenerateLabels¶
Generates legend items for each thing in the legend. Default implementation returns the text + styling for the color box. See Legend Item for details.
Filter¶
Filters legend items out of the legend. Receives 2 parameters, a Legend Item and the chart data.
Sort¶
Sorts legend items. Type is: sort(a: LegendItem, b: LegendItem, data: ChartData): number;
.
Receives 3 parameters, two Legend Items and the chart data.
The return value of the function is a number that indicates the order of the two legend item parameters.
The ordering matches the return value of Array.prototype.sort()
PointStyle¶
If specified, this style of point is used for the legend. Only used if usePointStyle is true. Default 'circle'
TextAlign¶
Horizontal alignment of the label text. Options are: 'left'
, 'right'
or 'center'
. Default 'center'
UsePointStyle¶
Label style will match corresponding point style (size is based on pointStyleWidth
or the minimum value between boxWidth
and font.size
).
Default false
PointStyleWidth¶
If usePointStyle
is true
, the width of the point style used for the legend.
UseBorderRadius¶
Label borderRadius will match corresponding borderRadius. Default false
BorderRadius¶
Override the borderRadius to use.