nuxt-charts
nuxt-charts

vue-chrts 的 Nuxt 模組

nuxt-charts

npm versionnpm downloads

vue-chrts 的 Nuxt 模組

功能

  • 📊 在您的 Nuxt 應用程式中使用精美的圖表元件
  • 🔄 所有圖表元件均自動匯入
  • 📊 多種型別:折線圖、柱狀圖、面積圖、甜甜圈圖
  • 🎨 易於定製
  • 💡 簡單、直觀的 API
  • 🚀 使用 Vue 3 和 TypeScript 構建

安裝

# npm
npm install nuxt-charts

# yarn
yarn add nuxt-charts

# pnpm
pnpm add nuxt-charts

使用

將模組新增到您的 Nuxt 配置中

// nuxt.config.ts
export default defineNuxtConfig({
  modules: ["nuxt-charts"]
});

然後在您的 Nuxt 應用程式中使用這些元件

<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>

可用元件

  • AreaChart - 面積圖
  • AreaStackedChart - 堆疊面積圖
  • LineChart - 折線圖
  • BarChart - 柱狀圖
  • DonutChart - 甜甜圈圖

自動匯入的型別

以下型別是自動匯入的

  • LegendPosition
  • CurveType
  • Orientation
  • BulletLegendItemInterface

許可證

MIT