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