How can I help you?
Getting Started with the Vue Range Navigator Component in Vue 2
19 Feb 20267 minutes to read
This article provides a step-by-step guide for setting up a Vue 2 project using Vue-CLI and integrating the Syncfusion® Vue Range Navigator component.
Prerequisites
System requirements for Syncfusion® Vue UI components
Dependencies
Below is the list of minimum dependencies required to use the Range Navigator component.
|-- @syncfusion/ej2-vue-charts
|-- @syncfusion/ej2-base
|-- @syncfusion/ej2-data
|-- @syncfusion/ej2-pdf-export
|-- @syncfusion/ej2-file-utils
|-- @syncfusion/ej2-compression
|-- @syncfusion/ej2-navigations
|-- @syncfusion/ej2-calendars
|-- @syncfusion/ej2-vue-base
|-- @syncfusion/ej2-svg-base
Setup 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 Range Navigator component as an example. Install the @syncfusion/ej2-vue-charts package by running the following command:
npm install @syncfusion/ej2-vue-charts --saveor
yarn add @syncfusion/ej2-vue-chartsThe –save will instruct NPM to include the Range Navigator package inside of the
dependenciessection of thepackage.json.
Add Syncfusion® Vue component
Follow the steps below to add the Range Navigator component:
1. First, import and register the Range Navigator component in the script section of the src/App.vue file.
<script>
import { RangeNavigatorComponent } from '@syncfusion/ej2-vue-charts';
export default {
components: {
'ejs-rangenavigator': RangeNavigatorComponent
}
}
</script>2. In the template section, define Range Navigator component.
<template>
<div id="app">
<ejs-rangenavigator></ejs-rangenavigator>
</div>
</template>Here is the summarized code for the above steps in the src/App.vue file:
<template>
<div id="app">
<ejs-rangenavigator></ejs-rangenavigator>
</div>
</template>
<script>
import { RangeNavigatorComponent } from '@syncfusion/ej2-vue-charts';
export default {
name: "App",
components: {
'ejs-rangenavigator': RangeNavigatorComponent
},
data() {
return {
}
}
}
</script>Run the project
To run the project, use the following command:
npm run serveor
yarn run serveModule Injection
To add features to the Range Navigator, inject the required modules. The following modules extend the Range Navigator’s basic functionality.
-
AreaSeries— Inject to use the area series. -
DateTime— Inject to use the date/time axis. -
RangeTooltip— Inject to enable the tooltip.
Inject these modules in the provide section as shown below.
import { RangeNavigatorComponent, AreaSeries, DateTime, RangeTooltip } from '@syncfusion/ej2-vue-charts';
export default {
components: {
'ejs-rangenavigator': RangeNavigatorComponent
},
provide: {
rangeNavigator: [AreaSeries, DateTime, RangeTooltip]
}
};Populate Range Navigator with Data
Now provide data to the Range Navigator. Add a series object using the series property. Map the JSON fields for x and y to the xName and yName properties, and set the JSON array to the dataSource property. If the JSON contains date/time values, set the valueType of the Range Navigator to DateTime. By default, the axis valueType is Numeric.
<template>
<div id="app">
<ejs-rangenavigator :valueType="valueType" :value="value" :labelFormat="labelFormat">
<e-rangenavigator-series-collection>
<e-rangenavigator-series :dataSource="data" type="Area" xName="x" yName="y" :width="2">
</e-rangenavigator-series>
</e-rangenavigator-series-collection>
</ejs-rangenavigator>
</div>
</template>
<script>
import { RangeNavigatorComponent, RangenavigatorSeriesDirective, RangenavigatorSeriesCollectionDirective, AreaSeries, DateTime } from '@syncfusion/ej2-vue-charts';
import { bitCoinData } from './default_data.js';
export default {
name: "App",
components: {
'ejs-rangenavigator': RangeNavigatorComponent,
'e-rangenavigator-series': RangenavigatorSeriesDirective,
'e-rangenavigator-series-collection': RangenavigatorSeriesCollectionDirective
},
data() {
return {
valueType: 'DateTime',
value: [new Date('2017-09-01'), new Date('2018-02-01')],
labelFormat: 'MMM-yy',
data: bitCoinData
};
},
provide: {
rangeNavigator: [DateTime, AreaSeries]
}
};
</script>Enable Tooltip
The tooltip is useful to show the selected data. You can enable tooltip by setting the enable property as true in tooltip object and by injecting RangeTooltip module using provide method.
<template>
<div id="app">
<ejs-rangenavigator :valueType="valueType" :value="value" :labelFormat="labelFormat" :tooltip="tooltip">
<e-rangenavigator-series-collection>
<e-rangenavigator-series :dataSource="data" type="Area" xName="x" yName="y" :width="2">
</e-rangenavigator-series>
</e-rangenavigator-series-collection>
</ejs-rangenavigator>
</div>
</template>
<script>
import { RangeNavigatorComponent, RangenavigatorSeriesDirective, RangenavigatorSeriesCollectionDirective, AreaSeries, DateTime, RangeTooltip } from '@syncfusion/ej2-vue-charts';
import { bitCoinData } from './default_data.js';
export default {
name: "App",
components: {
'ejs-rangenavigator': RangeNavigatorComponent,
'e-rangenavigator-series': RangenavigatorSeriesDirective,
'e-rangenavigator-series-collection': RangenavigatorSeriesCollectionDirective
},
data() {
return {
valueType: 'DateTime',
value: [new Date('2017-09-01'), new Date('2018-02-01')],
tooltip: { enable: true, displayMode: 'Always', format: 'MM/dd/yyyy' },
labelFormat: 'MMM-yy',
data: bitCoinData
};
},
provide: {
rangeNavigator: [DateTime, AreaSeries, RangeTooltip]
}
};
</script>