Toggle Sidebar B
AppearanceLight & dark mode D

Chart

Charting foundation built on unovis-vue. ChartContainer provides the theming, config context, tooltip wiring, and legend that every chart shares. For ready-made charts see Line, Area, Bar, Pie, and Semi Circle.

Default

A basic bar chart. ChartBar wraps ChartContainer, so it inherits the shared theming, tooltip, and legend plumbing from a single config.

Replay preview

Grid

Draw horizontal grid lines behind the plot with the grid prop.

Replay preview

Axis

Customize the axis ticks. Pass xTickFormatter and yTickFormatter to reshape category and value labels (here, compact currency).

Replay preview

Tooltip

ChartContainer wires ChartTooltipContent into the crosshair. Hover to see the title and per-series rows; valueFormatter shapes each value.

Replay preview

Custom tooltip

Pass tooltipFormatter for full control of each row. It forwards to ChartTooltipContent's formatter(value, name, item, index, payload) and returns a string that replaces the default label/value split.

Replay preview

Legend

Render ChartLegendContent (exported as ChartLegend) below the chart with the legend prop; labels and colors come from the config.

Replay preview

Anatomy

Import all parts and piece them together.

vue
<script setup>
import {
  ChartContainer,
  ChartCrosshair,
  ChartLegendContent,
  ChartTooltip,
  VisArea,
  VisAxis,
  VisLine,
  VisXYContainer,
} from "@/components/ui/chart";
</script>

<template>
  <ChartContainer>
    <VisXYContainer>
      <VisArea />
      <VisLine />
      <VisAxis />
      <ChartTooltip />
      <ChartCrosshair />
    </VisXYContainer>
    <ChartLegendContent />
  </ChartContainer>
</template>

API Reference

ChartContainer

PropTypeDefaultDescription
configChartConfigMap of dataKey → { label, color, icon }. Drives theming and the legend.
cursorbooleanfalseShow the Unovis crosshair line.
classstringExtra classes for the wrapping div.
SlotDescription
defaultScoped slot exposing { id, config } for the chart leaf components.

ChartTooltipContent

PropTypeDefaultDescription
configChartConfigTheming map for tooltip swatches and labels.
indicator"dot" | "line" | "dashed""dot"Indicator style next to each value.
hideLabelbooleanfalseHide the tooltip title row.
labelFormatter(d) => stringFormat the title (e.g. dates).

ChartLegendContent

PropTypeDefaultDescription
verticalAlign"top" | "bottom""bottom"Position relative to the chart.
hideIconbooleanfalseHide per-series icons from the config.