Charts

A generic, dark-mode-aware chart component built on Chart.js. Pass any Chart.js type (bar, line, pie, doughnut, radar, …) and it registers the required controllers automatically. Ships as a standalone package, @vultra/charts.

Usage

<script>
  import { Chart } from '@vultra/charts';
</script>

<Chart
  type="line"
  data={{
    labels: ['Jan', 'Feb', 'Mar'],
    datasets: [{ label: 'Revenue', data: [120, 260, 410] }]
  }}
/>

Chart types

<Chart type="bar" {data} />
<Chart type="pie" {data} />
<Chart type="doughnut" {data} />
<Chart type="radar" {data} />

Options

<Chart
  type="line"
  {data}
  options={{ responsive: true, plugins: { legend: { display: false } } }}
  height={360}
/>

Props

PropTypeDefaultDescription
typeChartType'bar'Chart.js chart type (bar, line, pie, doughnut, radar, …)
dataChartDataChart datasets and labels (required)
optionsChartOptionsChart.js options, merged over sensible defaults
heightnumber300Container height in pixels
widthnumberContainer width in pixels (defaults to 100%)
classstringAdditional classes
onRef(chart: ChartJS) => voidCalled with the underlying Chart.js instance

Convenience exports

@vultra/charts also exports chartPresets (per-type option presets), chartColors (a stable 8-color palette), and chartColorsAlpha(alpha).

Standalone package

Unlike the other components in @vultra/ui, charts live in their own package so you can tree-shake only what you need:

pnpm add @vultra/charts

Features

  • One component for every Chart.js type — no per-chart modules
  • Dark-mode aware, theme-aware defaults
  • Pre-registered controllers/scales (no manual Chart.js setup)
  • Exposed Chart.js instance via onRef for advanced control

Install

pnpm add @vultra/charts