Interface: LegendOptions

Properties

align

align: "start" | "end" | "center"

Alignment of the legend.

default ‘center’

Defined in: index.esm.d.ts:2107LegendOptions - 图1 (opens new window)


display

display: boolean

Is the legend shown?

default true

Defined in: index.esm.d.ts:2097LegendOptions - 图2 (opens new window)


fullSize

fullSize: boolean

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

Defined in: index.esm.d.ts:2112LegendOptions - 图3 (opens new window)


labels

labels: object

Type declaration

NameTypeDescription
boxHeightnumberHeight of the coloured box. default fontSize
boxWidthnumberWidth of colored box. default 40
colorColorColor of label see Defaults.color
fontFontSpecFont of label see Defaults.font
paddingnumberPadding between rows of colored boxes. default 10
pointStylePointStyleOverride point style for the legend. Only applies if usePointStyle is true
textAlign?TextAlignText alignment
usePointStylebooleanLabel style will match corresponding point style (size is based on the minimum value between boxWidth and font.size). default false
filter(item: LegendItem, data: ChartData<“bar” | “line” | “scatter” | “bubble” | “pie” | “doughnut” | “polarArea” | “radar”, (number | ScatterDataPoint | BubbleDataPoint)[], unknown>) => boolean-
generateLabels(chart: Chart<“bar” | “line” | “scatter” | “bubble” | “pie” | “doughnut” | “polarArea” | “radar”, (number | ScatterDataPoint | BubbleDataPoint)[], unknown>) => LegendItem[]-
sort(a: LegendItem, b: LegendItem, data: ChartData<“bar” | “line” | “scatter” | “bubble” | “pie” | “doughnut” | “polarArea” | “radar”, (number | ScatterDataPoint | BubbleDataPoint)[], unknown>) => number-

Defined in: index.esm.d.ts:2131LegendOptions - 图4 (opens new window)


position

position: LayoutPosition

Position of the legend.

default ‘top’

Defined in: index.esm.d.ts:2102LegendOptions - 图5 (opens new window)


reverse

reverse: boolean

Legend will show datasets in reverse order.

default false

Defined in: index.esm.d.ts:2117LegendOptions - 图6 (opens new window)


title

title: object

Type declaration

NameTypeDescription
colorColorColor of title see Defaults.color
displaybooleanIs the legend title displayed. default false
fontFontSpecsee Fonts
padding?number | ChartArea-
position“start” | “end” | “center”-
textstringThe string title.

Defined in: index.esm.d.ts:2189LegendOptions - 图7 (opens new window)

Methods

onClick

onClick(e: ChartEvent, legendItem: LegendItem, legend: LegendElement): void

A callback that is called when a click event is registered on a label item.

Parameters

NameType
eChartEvent
legendItemLegendItem
legendLegendElement

Returns: void

Defined in: index.esm.d.ts:2121LegendOptions - 图8 (opens new window)


onHover

onHover(e: ChartEvent, legendItem: LegendItem, legend: LegendElement): void

A callback that is called when a ‘mousemove’ event is registered on top of a label item

Parameters

NameType
eChartEvent
legendItemLegendItem
legendLegendElement

Returns: void

Defined in: index.esm.d.ts:2125LegendOptions - 图9 (opens new window)


onLeave

onLeave(e: ChartEvent, legendItem: LegendItem, legend: LegendElement): void

A callback that is called when a ‘mousemove’ event is registered outside of a previously hovered label item.

Parameters

NameType
eChartEvent
legendItemLegendItem
legendLegendElement

Returns: void

Defined in: index.esm.d.ts:2129LegendOptions - 图10 (opens new window)