Getting started with React Range Navigator component
24 Jul 202610 minutes to read
This section describes the steps to create a simple Range Navigator and demonstrates the basic usage of the Range Navigator component.
Prerequisites
Before getting started, ensure that your development environment meets the system requirements for Syncfusion® React UI components. That page documents the supported React, Node.js, and npm versions, and includes the React-version compatibility table for Syncfusion React components.
- Node.js 18 or later.
- A modern code editor such as Visual Studio Code.
Dependencies
When you install @syncfusion/ej2-react-charts, the following peer dependencies are installed automatically:
|-- @syncfusion/ej2-react-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-svg-base
Installation and configuration
To easily set up a React application, use the Vite CLI (npm create vite), which provides a faster development environment, smaller bundle sizes, and optimized builds compared to traditional tools like create-react-app. For detailed steps, refer to the Vite installation instructions. Vite sets up your environment using JavaScript and optimizes your application for production.
Note: To create a React application using
create-react-appinstead, refer to this documentation for more details.
To create a new React application, run the following command. The command will prompt you for a few settings, such as selecting a framework and a variant.
npm create vite@latest my-appFor reference, the interactive prompt looks like this:

You can also skip the interactive prompts by passing the template flag directly. Pick the template that matches your preferred language and run the matching block:
npm create vite@latest my-app -- --template react-ts
cd my-app
npm installnpm create vite@latest my-app -- --template react
cd my-app
npm installInstall Syncfusion® Range Navigator package
All the available Essential® JS 2 packages are published in the npmjs.com public registry. To install the Range Navigator package, run the following command from the project folder:
npm install @syncfusion/ej2-react-charts
@syncfusion/ej2-react-chartsincludes the Range Navigator component along with the rest of the chart components, and automatically pulls in the peer dependencies listed in the Dependencies section above.
Add Range Navigator to the project
The Range Navigator’s root component is RangeNavigatorComponent. Open src/App.tsx (or src/App.jsx for the JavaScript template) and replace its contents with the following code.
import { RangeNavigatorComponent } from "@syncfusion/ej2-react-charts";
import * as React from "react";
function App() {
return (<RangeNavigatorComponent></RangeNavigatorComponent>);
}
export default App;import { RangeNavigatorComponent } from "@syncfusion/ej2-react-charts";
import * as React from "react";
function App() {
return (<RangeNavigatorComponent></RangeNavigatorComponent>);
}
export default App;Then, update src/main.tsx (or src/main.jsx) to mount the App component using React 18’s createRoot API.
import React from "react";
import { createRoot } from "react-dom/client";
import App from "./App";
import "./index.css";
createRoot(document.getElementById("root")!).render(
<React.StrictMode>
<App />
</React.StrictMode>
);Now run the npm run dev command in the console to start the development server. This command compiles your code and serves the application locally, opening it in the browser.
npm run devThe below example shows a basic Range Navigator.
import { RangeNavigatorComponent } from '@syncfusion/ej2-react-charts';
import * as React from "react";
import * as ReactDOM from "react-dom";
function App() {
return <RangeNavigatorComponent id="charts"/>;
}
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts'));
root.render(<App />);import { RangeNavigatorComponent } from '@syncfusion/ej2-react-charts';
import * as React from "react";
import * as ReactDOM from "react-dom";
function App() {
return <RangeNavigatorComponent id="charts" />
}
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts'));
root.render(<App />);Module injection
The Range Navigator is segregated into individual feature-wise modules. To use a particular feature, you need to inject its feature service in the services of the Inject component. The following services are commonly used to extend the Range Navigator’s basic functionality.
-
AreaSeries- Inject this module in toservicesto use the area series. -
DateTime- Inject this module in toservicesto use the DateTime axis. -
RangeTooltip- Inject this module in toservicesto use the tooltip feature.
Import the modules from the chart package and inject them into the services section of the Range Navigator component as follows.
import { RangeNavigatorComponent, AreaSeries, DateTime, RangeTooltip, Inject } from "@syncfusion/ej2-react-charts";
import * as React from "react";
function App() {
return (
<RangeNavigatorComponent id="charts">
<Inject services={[AreaSeries, DateTime, RangeTooltip]} />
</RangeNavigatorComponent>
);
}
export default App;Populate Range Navigator with data
Add a series object to the Range Navigator by using the series property. Map the JSON fields x and y to the series xName and yName properties, and set the JSON array as the dataSource property.
Since the JSON contains category data, set the valueType for the horizontal axis (primaryXAxis) to Category. By default, the axis valueType is Numeric.
import { AreaSeries, DateTime, Inject, RangeNavigatorComponent, RangenavigatorSeriesCollectionDirective, RangenavigatorSeriesDirective, RangeTooltip } from '@syncfusion/ej2-react-charts';
import * as React from "react";
import * as ReactDOM from "react-dom";
import { bitCoinData } from '../default-data';
function App() {
const data = bitCoinData;
return <RangeNavigatorComponent id='charts' valueType='DateTime' labelFormat='MMM-yy' value={[new Date('2017-09-01'), new Date('2018-02-01')]}>
<Inject services={[AreaSeries, DateTime, RangeTooltip]} />
<RangenavigatorSeriesCollectionDirective>
<RangenavigatorSeriesDirective dataSource={data} xName='x' yName='y' type='Area' width={2} />
</RangenavigatorSeriesCollectionDirective>
</RangeNavigatorComponent>;
}
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts'));
root.render(<App />);import {
AreaSeries, DateTime, Inject, RangeNavigatorComponent, RangenavigatorSeriesCollectionDirective,
RangenavigatorSeriesDirective, RangeTooltip
} from '@syncfusion/ej2-react-charts';
import * as React from "react";
import * as ReactDOM from "react-dom";
import { bitCoinData } from '../default-data';
function App() {
const data: object[] = bitCoinData;
return <RangeNavigatorComponent id='charts'
valueType='DateTime' labelFormat='MMM-yy' value={[new Date('2017-09-01'), new Date('2018-02-01')]}>
<Inject services={[AreaSeries, DateTime, RangeTooltip]} />
<RangenavigatorSeriesCollectionDirective>
<RangenavigatorSeriesDirective dataSource={data} xName='x' yName='y' type='Area' width={2} />
</RangenavigatorSeriesCollectionDirective>
</RangeNavigatorComponent>
}
export default App;
const root = ReactDOM.createRoot(document.getElementById('charts'));
root.render(<App />);Troubleshooting
Use the following guidance to resolve common issues when getting started with the Range Navigator component.
-
Range Navigator does not render (blank page)
- Verify that
index.htmlcontains a container withid="root", and thatmain.tsx/main.jsxcallsReactDOM.createRoot(document.getElementById("root"))followed byroot.render(<App />). - Run
npm installagain to ensure all peer dependencies listed in the Dependencies section are installed.
- Verify that
-
Tooltip is not visible after setting
tooltip.enable = true- Confirm that the
RangeTooltipmodule is included in theservicesarray of theInjectcomponent as shown in the Module injection and Enable tooltip sections.
- Confirm that the
-
Series data is not plotted or appears empty
- Confirm that the
dataSourcearray contains objects with property names matchingxNameandyName(case sensitive). - If the
xfield holdsDatevalues, set thevalueTypeofprimaryXAxistoDateTime; for string categories useCategory.
- Confirm that the
-
TypeScript errors on import
- Ensure
@types/reactand@types/react-domare installed. The Syncfusion package ships with its own types, so no additional type packages are required.
- Ensure
-
Module not found: Can't resolve '@syncfusion/ej2-react-charts'- The package was not installed in the current project. Run
npm install @syncfusion/ej2-react-chartsfrom the project root.
- The package was not installed in the current project. Run
-
ERESOLVEpeer-dependency errors during installation- A React or Node.js version mismatch is the most common cause. Install a supported React version (18 or 19) and Node.js 18 or later, then delete
node_modulesandpackage-lock.jsonand runnpm installagain.
- A React or Node.js version mismatch is the most common cause. Install a supported React version (18 or 19) and Node.js 18 or later, then delete
-
Build or dev server fails to start
- Confirm that you are using a supported Node.js version (Node 18 or later for the latest Vite templates).
- Delete
node_modulesandpackage-lock.json, then runnpm installagain.
See also
Explore the following related topics: