Skip to main content
cngx-src documentation

CngxChartLegend

ComponentPrimaryOnPushNo encapsulationv0.1.0WCAG AA

projects/common/chart/legend/legend.component.ts

Import#

import { CngxChartLegend } from '@cngx/common/chart'

Description#

Presentational legend atom - a row (or column) of coloured swatches paired with labels. Decoupled from <cngx-chart> and the layer atoms by design: the consumer drives the items array, so the legend stays a pure rendering surface with zero opinions about series-discovery, visibility-toggling, or interaction.

Compose alongside a chart wherever a multi-layer composition needs a label key:

<cngx-chart [data]="series">
  <svg:g cngxLine [data]="traffic" style="--cngx-line-color: #3b82f6"></svg:g>
  <svg:g cngxLine [data]="errors" style="--cngx-line-color: #d2452f"></svg:g>
</cngx-chart>
<cngx-chart-legend
  [items]="[
    { label: 'Traffic', color: '#3b82f6' },
    { label: 'Errors',  color: '#d2452f' }
  ]"
/>

Theming via --cngx-chart-legend-gap, --cngx-chart-legend-swatch-size, --cngx-chart-legend-swatch-radius, --cngx-chart-legend-font-size. [orientation] flips between row and column; [align] aligns along the main axis (start, center, end).

Metadata#

Host#

Index#

Inputs#

align#"start" | "center" | "end"
input()
default 'start'
orientation#"horizontal" | "vertical"
input()
default 'horizontal'

HostBindings#

BindingExpression
[class.cngx-chart-legend--vertical]orientation() === "vertical"
[style.justify-content]flexAlign()