Vue 3 ApexCharts Component

1.11.1 · active · verified Sun Apr 19

vue3-apexcharts is the official Vue 3 wrapper component for ApexCharts.js, a modern open-source charting library used for building interactive data visualizations. Currently at version 1.11.1, it provides seamless integration of ApexCharts within Vue 3 applications, offering features like reactive chart updates where changes to data or options automatically re-render the chart. The library supports tree-shaking, allowing developers to import only necessary chart types to optimize bundle size, and includes robust Server-Side Rendering (SSR) capabilities with dedicated `<apexchart-server>` and `<apexchart-hydrate>` components. It also offers full TypeScript support, enhancing developer experience with type safety. This package is specifically designed for Vue 3; users requiring Vue 2 compatibility should instead use the `vue-apexcharts` package. The release cadence typically follows updates to the core ApexCharts.js library, ensuring compatibility and access to new features. Its key differentiator is being the official, fully-featured, and actively maintained Vue 3 component for ApexCharts.js.

Common errors

Warnings

Install

Imports

Quickstart

This example demonstrates how to create a reactive bar chart using `vue3-apexcharts`, configure its data and options, and dynamically update the chart series when a button is clicked. It includes both local component registration and TypeScript type declaration for the global `$apexcharts` property, making it ready for a modern Vue 3 setup.

<template>
  <div class="app">
    <apexchart
      width="550"
      type="bar"
      :options="chartOptions"
      :series="series"
    ></apexchart>
    <div>
      <button @click="updateChart">Update Chart Data</button>
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent } from 'vue';
import VueApexCharts from "vue3-apexcharts";
import ApexCharts from "apexcharts"; // For global property typing

// Add this when into a TypeScript codebase to type $apexcharts
declare module "@vue/runtime-core" {
  interface ComponentCustomProperties {
    $apexcharts: typeof ApexCharts;
  }
}

export default defineComponent({
  components: {
    apexchart: VueApexCharts, // Local registration, or use app.use(VueApexCharts) globally in main.ts
  },
  data() {
    return {
      chartOptions: {
        chart: {
          id: "vuechart-example",
          toolbar: {
            show: false
          }
        },
        xaxis: {
          categories: [1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998]
        },
        title: {
          text: 'Yearly Data Series',
          align: 'left'
        }
      },
      series: [
        {
          name: "Series A",
          data: [30, 40, 35, 50, 49, 60, 70, 91]
        }
      ]
    };
  },
  methods: {
    updateChart() {
      // Simulate data update by generating new random data
      const newSeriesData = this.series[0].data.map(() => Math.floor(Math.random() * (100 - 20 + 1)) + 20);
      this.series = [{ name: "Series A", data: newSeriesData }];
    }
  }
});
</script>

<style>
.app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
button {
  padding: 10px 20px;
  margin-top: 20px;
  cursor: pointer;
  background-color: #42b983;
  color: white;
  border: none;
  border-radius: 5px;
}
</style>

view raw JSON →