Options for the Legend.

Hierarchy

  • LegendOptions

Properties

addEntriesAutomatically?: boolean

Whether legend entries should be automatically added and displayed.

Defaults to true for default legend and false for manually added legends (chart.addLegend).

autoHideThreshold?: number

The maximum allowed proportion of the viewport that the legend can occupy before it is automatically hidden. For example, a value of 0.75 means the legend will be hidden if it covers more than 75% of the viewport.

backgroundFillStyle?: FillStyle

Background FillStyle of the legend.

backgroundStrokeStyle?: LineStyle

Background LineStyle of the legend.

backgroundVisible?: boolean

Whether the legend background should be visible.

Default LegendEntryOptions for the entries.

entryMargin?: number

Margin between legend entries.

marginInner?: number

Margin from the main chart element to the legend.

marginOuter?: number | Partial<Margin>

Margin from the legend to the edge of the chart area.

orientation?: LegendOrientation

Legend orientation. By default, this is automatically dictated by configured position But it can be forced to a specific value, which can be useful when positioning legends at arbitrary locations.

 // Example syntax, arbitrary location
chart.legend.setOptions({
position: {
x: 0,
y: 0,
origin: UIOrigins.UIOrigins.LeftBottom
},
orientation: LegendOrientation.Horizontal
})
padding?: number | Partial<Margin>

Legend content padding.

position?: LegendPosition | {
    origin?: Point;
    x: number;
    y: number;
}

Position of the legend.

 // Example syntax, choose from preset options
const chart = lc.ChartXY({
legend: {
position: LegendPosition.RightCenter
}
})

Alternatively, arbitrary location as pixels relative to container bottom left corner can be specified:

 // Example syntax, arbitrary location
chart.legend.setOptions({
position: {
x: 0,
y: 0,
origin: UIOrigins.UIOrigins.LeftBottom
}
})

These coordinates are defined in coordsRelative coordinate system.

renderOnTop?: boolean

Whether the legend should be rendered on top of the chart.

title?: string

Title of the legend.

titleFillStyle?: FillStyle

FillStyle of the legend title.

titleFont?: Partial<FontSettings>

FontSettings of the legend title.

visible?: boolean

Whether the legend should be visible.