nuxt-charts
Nuxt module for vue-chrts
Features
- ๐ Use beautiful chart components in your Nuxt applications
- ๐ Auto-imports for all chart components
- ๐ Multiple types: Line, Bar, Area, Donut
- ๐จ Easily customizable
- ๐ก Simple, intuitive API
- ๐ Built with Vue 3 and TypeScript
Installation
# npm
npm install nuxt-charts
# yarn
yarn add nuxt-charts
# pnpm
pnpm add nuxt-charts
Usage
Add the module to your Nuxt config:
// nuxt.config.ts
export default defineNuxtConfig({
modules: ["nuxt-charts"]
});
Then use the components in your Nuxt application:
<template>
<div class="chart-wrapper">
<LineChart
:data="data"
:categories="categories"
:height="300"
:xFormatter="xFormatter"
xLabel="Month"
yLabel="Amount"
/>
</div>
</template>
<script setup>
import { LineChart } from 'vue-chrts';
const data = [
{ month: 'Jan', sales: 100, profit: 50 },
{ month: 'Feb', sales: 120, profit: 55 },
{ month: 'Mar', sales: 180, profit: 80 },
{ month: 'Apr', sales: 110, profit: 40 },
{ month: 'May', sales: 90, profit: 30 },
];
const categories = {
sales: {
name: 'Sales',
color: '#3b82f6'
},
profit: {
name: 'Profit',
color: '#10b981'
}
};
const xFormatter = (i) => data[i].month;
</script>
Available Components
AreaChart
- Area chartAreaStackedChart
- Stacked area chartLineChart
- Line chartBarChart
- Bar chartDonutChart
- Donut chart
Auto-imported Types
The following types are auto-imported:
LegendPosition
CurveType
Orientation
BulletLegendItemInterface
License
MIT