home / skills / dennisadriaans / vue-chrts / vue-charts-overview

vue-charts-overview skill

/.claude/skills/vue-charts-overview

This skill provides overview of vue-chrts and nuxt-charts, including installation, components, and usage guidance for Vue 3 charts.

npx playbooks add skill dennisadriaans/vue-chrts --skill vue-charts-overview

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
3.7 KB
---
name: vue-chrts-overview
description: Overview of vue-chrts and nuxt-charts libraries. Use when the user asks about available charts, installation, or general library capabilities.
---

# Vue-Chrts / Nuxt-Charts Overview

vue-chrts is a Vue 3 charting library inspired by Tremor, built on Unovis. nuxt-charts is its Nuxt module wrapper.

## Quick Mental Model

Think of vue-chrts like a **restaurant menu**: you pick a chart type (the dish), provide your data (ingredients), and configure categories (the presentation). The library handles the cooking (rendering).

## Installation

```bash
# Vue.js
pnpm add vue-chrts

# Nuxt
pnpm add nuxt-charts
# Add to nuxt.config.ts: modules: ["nuxt-charts"]
```

## Available Chart Components

```
┌─────────────────────────────────────────────────────────────┐
│                    CHART COMPONENTS                         │
├─────────────────────────────────────────────────────────────┤
│  TIME SERIES         │  COMPARISON        │  RELATIONSHIPS  │
│  ─────────────       │  ──────────        │  ─────────────  │
│  • LineChart         │  • BarChart        │  • SankeyChart  │
│  • AreaChart         │  • DonutChart      │  • DagreGraph   │
│  • DualChart         │  • BubbleChart     │                 │
│                      │                    │                 │
├──────────────────────┼────────────────────┼─────────────────┤
│  SPECIALIZED         │  MAPS              │                 │
│  ───────────         │  ────              │                 │
│  • GanttChart        │  • TopoJSONMap     │                 │
│                      │  • DottedMap       │                 │
└──────────────────────┴────────────────────┴─────────────────┘
```

## Core Pattern for ALL Charts

Every chart follows this structure:

```vue
<template>
  <ChartComponent
    :data="dataArray"
    :categories="categoriesObject"
    :height="number"
    :xFormatter="formatterFunction"
    <!-- ...other props -->
  />
</template>

<script setup>
// 1. Your raw data array
const data = [{ label: 'A', value1: 10, value2: 20 }, ...]

// 2. Categories define which data keys to plot and how they look
const categories = {
  value1: { name: 'Display Name', color: '#hexcolor' },
  value2: { name: 'Another Series', color: '#hexcolor2' }
}

// 3. Formatter to display x-axis labels
const xFormatter = (tick) => data[tick].label
</script>
```

## Key Imports

```typescript
// Components
import { 
  LineChart, AreaChart, BarChart, DonutChart,
  BubbleChart, GanttChart, DagreGraph, DualChart,
  SankeyChart, TopoJSONMap, DottedMap
} from 'vue-chrts';

// Enums & Types
import { 
  LegendPosition,  // TopLeft, TopCenter, TopRight, BottomLeft, BottomCenter, BottomRight
  CurveType,       // Linear, MonotoneX, Step, Natural, Basis, Cardinal, etc.
  Orientation,     // Horizontal, Vertical
  DonutType        // Half, Full
} from 'vue-chrts';
```

## Common Gotcha

**xFormatter receives an INDEX, not the data object!**

```typescript
// ❌ WRONG
const xFormatter = (d) => d.month

// ✅ CORRECT  
const xFormatter = (tick) => data[tick].month
```

Overview

This skill provides a concise overview of the vue-chrts chart library and its Nuxt wrapper, nuxt-charts. It highlights available chart components, installation steps, the common component pattern, and important gotchas for Vue 3 projects. Use it to quickly determine if vue-chrts fits your visualization needs and how to get started.

How this skill works

vue-chrts exposes a set of Vue 3 chart components built on Unovis, each expecting a data array, a categories definition that maps data keys to display names and colors, and optional props like height and formatters. nuxt-charts is a Nuxt module that registers the components and simplifies integration in Nuxt apps. All charts share the same usage pattern: pass data, categories, and formatting functions to the chosen ChartComponent.

When to use it

  • You need a lightweight Vue 3 charting solution inspired by Tremor and built on Unovis.
  • You want ready-made components for time series, comparisons, relationship diagrams, maps, and specialized charts like Gantt.
  • You prefer a consistent API across many chart types so you can swap components without reworking data shape.
  • You’re building a Nuxt app and want easy registration via a module (nuxt-charts).

Best practices

  • Prepare a flat data array and use a categories object to map keys to labels and colors for predictable styling.
  • Remember xFormatter receives an index (tick). Use it to look up the data item (e.g., data[tick].label).
  • Define reusable formatter functions and category maps to keep chart components declarative and consistent.
  • Set explicit heights and legend positions for stable layouts across screen sizes.
  • Import only the components and enums you use to keep bundle size small.

Example use cases

  • Render time series dashboards with LineChart, AreaChart, or DualChart for comparing metrics.
  • Build comparison views using BarChart or DonutChart to show category breakdowns.
  • Visualize relationships with SankeyChart for flows or DagreGraph for network diagrams.
  • Add geographic views with TopoJSONMap or DottedMap for region- or point-based data.
  • Create schedule visualizations with GanttChart for project timelines.

FAQ

How do I install for a plain Vue 3 project?

Install vue-chrts (pnpm add vue-chrts) and import the components you need into your app.

How do I add it to a Nuxt project?

Install nuxt-charts (pnpm add nuxt-charts) and add 'nuxt-charts' to the modules array in nuxt.config.ts.

What is the common chart prop pattern?

All charts accept :data (array), :categories (object mapping keys to display names/colors), :height (number), and formatter props like :xFormatter.

What common mistake should I avoid?

Do not treat xFormatter as a data object. It receives an index; use it to index into your data array (data[tick]).