Docs
⚙️ ⏐ Utils
Legends

Legends

The Legends component in REAVIZ provides a visual representation of the data series in a chart. Legends help users understand what each color or symbol in the chart represents.

Types supported by reaviz:

  • Discrete Legend: Displays individual entries for each data series. REAVIZ does not include legends by default to keep the library modular, but you can add discrete legends as needed.
  • Sequential Legend: Useful for categorical charts such as heatmaps, supporting both vertical and horizontal layouts.

Where to use:

  • Clarify Data Series: Ideal for providing clear labels and color codes for different data series in a chart.
  • Enhance Readability: Useful for improving the readability and interpretation of complex charts.
  • Categorical Data Representation: Great for representing categorical data in charts like heatmaps.

Examples

Descrete

Sequential

API

DiscreteLegend (opens in a new tab)

PropDescriptionDefault
classNameCSS Class name.
string
styleCSS Styles.
CSSProperties
orientationOrientation of the legend.
"horizontal" | "vertical"
vertical
entriesEntry components to show in the legend.
ReactElement<DiscreteLegendEntryProps, FC<Partial<DiscreteLegendEntryProps>>>[]

DiscreteLegendEntry (opens in a new tab)

PropDescriptionDefault
labelLabel for the entry.
string
colorColor for the entry.
string
symbolSymbol for the entry.
ReactElement<DiscreteLegendSymbolProps, FC<Partial<DiscreteLegendSymbolProps>>> | ReactNode
<DiscreteLegendSymbol />
styleCSS Styles.
CSSProperties
classNameCSS Class names.
string
titleHTML Title Attribute.
string
orientationOrientation of the entry set internally by `DiscreteLegend`.
"horizontal" | "vertical"
horizontal
onMouseEnterMouse enter event.
(event: MouseEvent<HTMLDivElement, MouseEvent>) => void
onMouseLeaveMouse leave event.
(event: MouseEvent<HTMLDivElement, MouseEvent>) => void
onClickOn click event.
(event: MouseEvent<HTMLDivElement, MouseEvent>) => void

DiscreteLegendSymbol (opens in a new tab)

PropDescriptionDefault
colorColor for the symbol set by the `DiscreteLegendEntry`.
string
classNameCSS Class names.
string

SequentialLegend (opens in a new tab)

PropDescriptionDefault
classNameCSS Class name.
any
gradientClassNameCSS Class name for the gradient element.
string
styleCSS Styles.
any
orientationOrientation of the legend.
"horizontal" | "vertical"
vertical
data *Data to use to render the scale.
ChartDataShape[]
colorSchemeColor scheme for the scale.
string[]
['rgba(28, 107, 86, 0.5)', '#2da283']