How can I help you?
Important – Legacy Content (Vue 2 only)
Vue 2 reached end-of-life on December 31, 2023. This guide is maintained for existing Vue 2 projects only.
For new projects or modern development, use Vue 3 with Vite.
→ See the official Vue 3 Getting Started with Chart component
(Supports both Composition API and Options API, uses Vite instead of Vue CLI.)
Getting Started with the Vue Chart Component in Vue 2
20 Feb 202624 minutes to read
This section provides a step-by-step guide to creating a Vue 2 application using Vue CLI and integrating the Syncfusion® Vue Chart component. It helps users quickly configure a project and render an interactive chart.
Ready to streamline your Syncfusion Vue development?
Discover the full potential of Syncfusion Vue components with the Syncfusion AI Coding Assistant. It simplifies integration, configuration, and feature discovery through intelligent, context-aware code suggestions and is available in popular AI-powered IDEs such as VS Code, Cursor, and Syncfusion CodeStudio.
Explore Syncfusion AI Coding Assistant
To get started quickly with Vue Charts, refer to the following introductory video:
Prerequisites
Ensure that the development environment meets the required criteria listed in System requirements for Syncfusion Vue UI components.
Dependencies
The following are the minimum required dependencies to use the Vue Chart component:
|-- @syncfusion/ej2-vue-charts
|-- @syncfusion/ej2-base
|-- @syncfusion/ej2-data
|-- @syncfusion/ej2-pdf-export
|-- @syncfusion/ej2-file-utils
|-- @syncfusion/ej2-compression
|-- @syncfusion/ej2-charts
|-- @syncfusion/ej2-vue-base
|-- @syncfusion/ej2-svg-base
Setting up the Vue 2 project
To generate a Vue 2 project using Vue-CLI, use the vue create command. Follow these steps to install Vue CLI and create a new project:
npm install -g @vue/cli
vue create quickstart
cd quickstart
npm run serveor
yarn global add @vue/cli
vue create quickstart
cd quickstart
yarn run serveWhen creating a new project, choose the option Default ([Vue 2] babel, eslint) from the menu.

Once the quickstart project is set up with default settings, proceed to add Syncfusion components to the project.
Add Syncfusion Vue packages
Syncfusion packages are available at npmjs.com. To use Vue components, install the required npm package.
This article uses the Vue Chart component (the @syncfusion/ej2-vue-charts package) as an example. Install it by running:
npm install @syncfusion/ej2-vue-chartsor
yarn add @syncfusion/ej2-vue-chartsNote: npm v5+ saves packages to
dependenciesby default;--saveis not required.
Add Syncfusion Vue component
Follow the steps below to add the Vue Chart component:
- Import and register the Chart component in the
scriptsection of the src/App.vue file.
<script>
import { ChartComponent } from '@syncfusion/ej2-vue-charts';
export default {
components: {
'ejs-chart': ChartComponent
}
}
</script>- In the
templatesection, define the Chart component.
<template>
<div id="app">
<ejs-chart id="container"> </ejs-chart>
</div>
</template>Here is the summarized code for the above steps in the src/App.vue file:
<template>
<div id="app">
<ejs-chart id="container"> </ejs-chart>
</div>
</template>
<script>
import { ChartComponent } from '@syncfusion/ej2-vue-charts';
export default {
name: "App",
components: {
'ejs-chart': ChartComponent
},
data () {
return {
}
}
}
</script>
<style>
#container{
height: 350px;
}
</style>Run the project
To run the project, use the following command:
npm run serveor
yarn run serveIn Vue, register the chart’s feature modules using the component’s provide option.
Module Injection
The Chart component is split into feature-specific modules. To enable a specific feature in a Vue 2
application, register the corresponding module(s) in the component’s provide option. The following
example shows the modules used in this guide and their purpose.
-
LineSeries- Register to enable the line series type. -
Legend- Register to enable the legend feature. -
Tooltip- Register to enable tooltip support. -
DataLabel- Register to enable data labels on points. -
Category- Register to enable category axis support.
Register these modules in the component provide option as shown below (Vue 2):
<script>
import {
ChartComponent,
LineSeries,
Category,
Legend,
Tooltip,
DataLabel
} from "@syncfusion/ej2-vue-charts";
export default {
components: {
'ejs-chart': ChartComponent
},
provide: {
chart: [LineSeries, Category, Legend, Tooltip, DataLabel]
}
};
</script>Tip: Only inject modules you actually use to keep bundle size smaller.
Populate Chart with Data
This section explains how to plot the following JSON data to the chart.
export default {
data() {
return {
seriesData: [
{ month: 'Jan', sales: 35 }, { month: 'Feb', sales: 28 },
{ month: 'Mar', sales: 34 }, { month: 'Apr', sales: 32 },
{ month: 'May', sales: 40 }, { month: 'Jun', sales: 32 },
{ month: 'Jul', sales: 35 }, { month: 'Aug', sales: 55 },
{ month: 'Sep', sales: 38 }, { month: 'Oct', sales: 30 },
{ month: 'Nov', sales: 25 }, { month: 'Dec', sales: 32 }
]
};
}
};
- Add a series object to the chart using the
seriesproperty. Map the fieldsmonthandsalesin the JSON data to thexNameandyNameproperties of the series, and set the JSON data to thedataSourceproperty.
Since the JSON contains category data, set the valueType for the horizontal axis to Category. By default, the axis valueType is Numeric.
<template>
<div id="app">
<ejs-chart id="container" :title='title' :primaryYAxis='primaryyAxis'>
<e-series-collection>
<e-series :dataSource='seriesData' type='Line' xName='month' yName='sales' name='Sales'></e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script>
import { ChartComponent, LineSeries, Category, Legend, Tooltip, DataLabel } from "@syncfusion/ej2-vue-charts";
export default {
components: {
'ejs-chart': ChartComponent
},
provide: {
chart: [LineSeries, Category, Legend, Tooltip, DataLabel]
},
data() {
return {
seriesData: [ /* your data */ ],
title: "Monthly Sales Report",
primaryyAxis: {
labelFormat: '${value}K'
}
};
}
};
</script>- The sales data are in thousands, so format the vertical axis labels by adding $ as a prefix and K as a suffix. This can be achieved by setting the axis
labelFormatto ‘${value}K’ using thelabelFormatproperty. Here,{value}acts as a placeholder for each axis label.
Modern Alternative: Vue 3 + Vite
For new applications, Syncfusion recommends Vue 3:
- Use Vite instead of Vue CLI (faster, modern tooling).
- Choose Composition API (
<script setup>) or Options API. - Same package (
@syncfusion/ej2-vue-charts), but registration uses Vue 3 syntax (no globalprovidein the same way — child directives are registered directly).
Full guide: Vue 3 Chart Getting Started
Example quickstart (Vite + Composition API):
npm create vite@latest quickstart -- --template vue
cd quickstart
npm install
npm install @syncfusion/ej2-vue-charts
npm run devSee the linked doc for full code examples.
Add Chart Title
Add a title to the chart using the title property to provide quick information about the displayed data.
<template>
<div id="app">
<ejs-chart id="container" :title='title' :primaryXAxis='primaryXAxis' :primaryYAxis='primaryYAxis'>
<e-series-collection>
<e-series :dataSource='seriesData' type='Line' xName='month' yName='sales' name='Sales'> </e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script>
import { ChartComponent, SeriesDirective, SeriesCollectionDirective, LineSeries, Category, Tooltip } from "@syncfusion/ej2-vue-charts";
export default {
name: "App",
components: {
'ejs-chart': ChartComponent,
'e-series-collection': SeriesCollectionDirective,
'e-series': SeriesDirective
},
data() {
return {
seriesData: [
{ month: 'Jan', sales: 35 }, { month: 'Feb', sales: 28 },
{ month: 'Mar', sales: 34 }, { month: 'Apr', sales: 32 },
{ month: 'May', sales: 40 }, { month: 'Jun', sales: 32 },
{ month: 'Jul', sales: 35 }, { month: 'Aug', sales: 55 },
{ month: 'Sep', sales: 38 }, { month: 'Oct', sales: 30 },
{ month: 'Nov', sales: 25 }, { month: 'Dec', sales: 32 }
],
primaryXAxis: {
valueType: 'Category'
},
primaryYAxis:{
labelFormat: '${value}K'
},
title: "Sales Analysis"
};
},
provide: {
chart: [LineSeries, Category, Tooltip]
}
};
</script>
<style>
#container{
height: 350px;
}
</style>Enable Legend
Enable the chart legend by setting the visible property to true in the legendSettings object and by registering the Legend module in provide.
<template>
<div id="app">
<ejs-chart id="container" :title='title' :primaryXAxis='primaryXAxis' :primaryYAxis='primaryYAxis' :legendSettings='legendSettings'>
<e-series-collection>
<e-series :dataSource='seriesData' type='Line' xName='month' yName='sales' name='Sales'> </e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script>
import { ChartComponent, SeriesDirective, SeriesCollectionDirective, LineSeries, Category, Legend } from "@syncfusion/ej2-vue-charts";
export default {
name: "App",
components: {
'ejs-chart': ChartComponent,
'e-series-collection': SeriesCollectionDirective,
'e-series': SeriesDirective
},
data() {
return {
seriesData: [
{ month: 'Jan', sales: 35 }, { month: 'Feb', sales: 28 },
{ month: 'Mar', sales: 34 }, { month: 'Apr', sales: 32 },
{ month: 'May', sales: 40 }, { month: 'Jun', sales: 32 },
{ month: 'Jul', sales: 35 }, { month: 'Aug', sales: 55 },
{ month: 'Sep', sales: 38 }, { month: 'Oct', sales: 30 },
{ month: 'Nov', sales: 25 }, { month: 'Dec', sales: 32 }
],
primaryXAxis: {
valueType: 'Category'
},
primaryYAxis:{
labelFormat: '${value}K'
},
legendSettings: {
visible: true
},
title: "Sales Analysis"
};
},
provide: {
chart: [LineSeries, Category, Legend]
}
};
</script>
<style>
#container {
height: 350px;
}
</style>Add Data Label
Add data labels to improve chart readability by setting the visible property to true in the dataLabel object and registering DataLabel in provide.
<template>
<div id="app">
<ejs-chart id="container" :title='title' :primaryXAxis='primaryXAxis' :primaryYAxis='primaryYAxis' :legendSettings='legendSettings'>
<e-series-collection>
<e-series :dataSource='seriesData' type='Line' xName='month' yName='sales' name='Sales' :marker='marker'> </e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script>
import { ChartComponent, SeriesDirective, SeriesCollectionDirective, LineSeries, Category, DataLabel, Legend } from "@syncfusion/ej2-vue-charts";
export default {
name: "App",
components: {
'ejs-chart': ChartComponent,
'e-series-collection': SeriesCollectionDirective,
'e-series': SeriesDirective
},
data() {
return {
seriesData: [
{ month: 'Jan', sales: 35 }, { month: 'Feb', sales: 28 },
{ month: 'Mar', sales: 34 }, { month: 'Apr', sales: 32 },
{ month: 'May', sales: 40 }, { month: 'Jun', sales: 32 },
{ month: 'Jul', sales: 35 }, { month: 'Aug', sales: 55 },
{ month: 'Sep', sales: 38 }, { month: 'Oct', sales: 30 },
{ month: 'Nov', sales: 25 }, { month: 'Dec', sales: 32 }
],
primaryXAxis: {
valueType: 'Category'
},
primaryYAxis:{
labelFormat: '${value}K'
},
legendSettings: {
visible: true
},
marker: {
dataLabel:{
visible: true
}
},
title: "Sales Analysis"
};
},
provide: {
chart: [LineSeries, Category, DataLabel, Legend]
}
};
</script>
<style>
#container {
height: 350px;
}
</style>Enable Tooltip
The tooltip is useful when data labels cannot display all information due to space constraints. Enable tooltip by setting enable to true in the tooltip object and registering Tooltip in provide.
<template>
<div id="app">
<ejs-chart id="container" :title='title' :primaryXAxis='primaryXAxis' :primaryYAxis='primaryYAxis' :tooltip='tooltip'>
<e-series-collection>
<e-series :dataSource='seriesData' type='Line' xName='month' yName='sales' name='Sales' :marker='marker'> </e-series>
</e-series-collection>
</ejs-chart>
</div>
</template>
<script>
import { ChartComponent, SeriesDirective, SeriesCollectionDirective, LineSeries, Category, DataLabel, Tooltip } from "@syncfusion/ej2-vue-charts";
export default {
name: "App",
components: {
'ejs-chart': ChartComponent,
'e-series-collection': SeriesCollectionDirective,
'e-series': SeriesDirective
},
data() {
return {
seriesData: [
{ month: 'Jan', sales: 35 }, { month: 'Feb', sales: 28 },
{ month: 'Mar', sales: 34 }, { month: 'Apr', sales: 32 },
{ month: 'May', sales: 40 }, { month: 'Jun', sales: 32 },
{ month: 'Jul', sales: 35 }, { month: 'Aug', sales: 55 },
{ month: 'Sep', sales: 38 }, { month: 'Oct', sales: 30 },
{ month: 'Nov', sales: 25 }, { month: 'Dec', sales: 32 }
],
primaryXAxis: {
valueType: 'Category'
},
primaryYAxis:{
labelFormat: '${value}K'
},
marker: {
dataLabel:{
visible: true
}
},
tooltip:{ enable: true },
title: "Sales Analysis"
};
},
provide: {
chart: [LineSeries, Category, DataLabel, Tooltip]
}
};
</script>
<style>
#container {
height: 350px;
}
</style>You can refer to our
Vue Chartsfeature tour page for its groundbreaking feature representations. You can also explore ourVue Charts examplethat shows various chart types and how to represent time-dependent data, showing trends in data at equal intervals.