Skip to content
Back to skills

Legend

ASecurity

Chart legends for identifying data series. `DiscreteLegend` for categorical series; `SequentialLegend` for continuous color scales.

  • 4 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added May 27, 2026
data-aigoreactnode

Works with

  • cli

Security analysis

A100/100

Scanned May 27, 2026

npx -y skills add reaviz/skills --skill legend --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Legend?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Legend
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/reaviz-legend/badge)](https://www.skillsdirectory.com/skills/reaviz-legend)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
# Legend

Chart legends for identifying data series. `DiscreteLegend` for categorical series; `SequentialLegend` for continuous color scales.

## Import

```tsx
import {
  DiscreteLegend,
  DiscreteLegendEntry,
  DiscreteLegendSymbol,
  SequentialLegend
} from 'reaviz';
```

## DiscreteLegend Props

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `entries` | `ReactElement<DiscreteLegendEntryProps>[]` | — | Legend entries (required) |
| `orientation` | `'horizontal' \| 'vertical'` | `'vertical'` | Layout direction |
| `className` | `string` | — | CSS class |
| `style` | `React.CSSProperties` | — | Inline styles |

## DiscreteLegendEntry Props

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `label` | `string` | — | Entry label (required) |
| `color` | `string` | — | Entry color (required) |
| `symbol` | `ReactElement \| ReactNode` | `<DiscreteLegendSymbol />` | Symbol element |
| `title` | `string` | — | HTML title attribute |
| `className` | `string` | — | CSS class |
| `style` | `React.CSSProperties` | — | Inline styles |
| `onClick` | `(event) => void` | — | Click handler |
| `onMouseEnter` | `(event) => void` | — | Mouse enter handler |
| `onMouseLeave` | `(event) => void` | — | Mouse leave handler |

## DiscreteLegendSymbol Props

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `color` | `string` | — | Symbol color (set by entry) |
| `className` | `string` | — | CSS class |

## SequentialLegend Props

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `data` | `ChartDataShape[]` | — | Data for scale extent (required) |
| `colorScheme` | `string[]` | `['rgba(28,107,86,0.5)', '#2da283']` | Color range |
| `orientation` | `'horizontal' \| 'vertical'` | `'vertical'` | Layout direction |
| `className` | `string` | — | CSS class |
| `gradientClassName` | `string` | — | CSS class for gradient element |
| `style` | `any` | — | Inline styles |

## Discrete Legend

```tsx
<DiscreteLegend
  orientation="horizontal"
  entries={[
    <DiscreteLegendEntry label="Series A" color="#2d60e8" />,
    <DiscreteLegendEntry label="Series B" color="#26efb5" />,
    <DiscreteLegendEntry label="Series C" color="#ff5722" />,
  ]}
/>
```

## Vertical Legend

```tsx
<DiscreteLegend
  orientation="vertical"
  entries={[
    <DiscreteLegendEntry label="Revenue" color="#2d60e8" />,
    <DiscreteLegendEntry label="Costs" color="#ff5722" />,
  ]}
/>
```

## Interactive Legend (Toggle Series)

```tsx
const [active, setActive] = useState(['A', 'B']);

<DiscreteLegend
  entries={series.map((s) => (
    <DiscreteLegendEntry
      key={s.key}
      label={s.key}
      color={s.color}
      style={{ opacity: active.includes(s.key) ? 1 : 0.3 }}
      onClick={() =>
        setActive((prev) =>
          prev.includes(s.key)
            ? prev.filter((k) => k !== s.key)
            : [...prev, s.key]
        )
      }
    />
  ))}
/>
```

## Sequential Legend (Heatmap)

```tsx
<SequentialLegend
  data={heatmapData}
  colorScheme={['#f0f9e8', '#08589e']}
  orientation="vertical"
/>
```

## Horizontal Sequential Legend

```tsx
<SequentialLegend
  data={data}
  orientation="horizontal"
  colorScheme={['rgba(28,107,86,0.5)', '#2da283']}
/>
```

## Notes

- Legends are **not** automatically rendered by charts — add them alongside your chart component
- `DiscreteLegend` renders HTML elements (not SVG), so place it outside the chart SVG
- `SequentialLegend` renders a gradient bar with min/max labels from the data extent

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.