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.

Dark previewReplay previewOpen in new tab

Usage

Import the parts you need from the component's folder.

ts
import { ChartContainer, ChartTooltipContent, ChartLegendContent } from "@/components/ui/chart";

Grid

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

Dark previewReplay previewOpen in new tab

Axis

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

Dark previewReplay previewOpen in new tab

Tooltip

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

Dark previewReplay previewOpen in new tab

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.

Dark previewReplay previewOpen in new tab

Legend

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

Dark previewReplay previewOpen in new tab

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
configChartConfig—Map of dataKey → { label, color, icon }. Drives theming and the legend.
cursorbooleanfalseShow the Unovis crosshair line.
classstring—Extra classes for the wrapping div.
SlotDescription
defaultScoped slot exposing { id, config } for the chart leaf components.

ChartTooltipContent

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

ChartLegendContent

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