Creating a line chart in React using material UI and DevExpress simply means creating a simple graph to show the relationship between two parameters.
DevExpress: DevExpress is a package for controlling and building the user interface of the Windows, Mobile, and other applications.
Line Charts: Line charts are used to represent the relation between two data relationships X and relationships Y on a different axis. One of the axes of the plot represents the specific categories being compared, while the other axis represents the measured values corresponding to those categories.
Prerequisites
Approach
To create a line chart in React using material UI and DevExpress, we will install the devexpress and MUI packages first. Then create dummy data in the form of an array of objects with numeric values and represent them on the line chart using the Chart component and respective attributes.
Steps to Create React Application And Installing Module:
Step 1: Create a React application using the following command.
npx create-react-app foldername
Step 2: After creating your project folder i.e. folder name, move to it using the following command.
cd foldername
Step 3: After creating the ReactJS application, install the required modules using the following command.
npm i --save @devexpress/dx-react-core @devexpress/dx-react-chart
@material-ui/core devexpress/dx-react-chart-material-ui
Project Structure:

Project Structure
The updated list of dependencies after installing packages
"dependencies": {
"@devexpress/dx-react-chart": "^4.0.5",
"@devexpress/dx-react-chart-material-ui": "^4.0.5",
"@devexpress/dx-react-core": "^4.0.5",
"@material-ui/core": "^4.12.4",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
}
Example:Used the chart component form teh dev express to visualise the data as a line chart.
Javascript
import React from "react" ;
import Paper from "@material-ui/core/Paper" ;
import {
ArgumentAxis,
ValueAxis,
Chart,
LineSeries,
} from "@devexpress/dx-react-chart-material-ui" ;
const App = () => {
const data = [
{ x: 1, y: 30 },
{ x: 2, y: 40 },
{ x: 3, y: 5 },
{ x: 4, y: 2 },
{ x: 5, y: 21 },
];
return (
<Paper>
<Chart data={data}>
<ArgumentAxis />
<ValueAxis />
<LineSeries
valueField= "y"
argumentField= "x"
/>
</Chart>
</Paper>
);
};
export default App;
|
Step to Run Application: Run the application using the following command from the root directory of the project:
npm start
Output: Now open your browser and go to http://localhost:3000/, you will see the following output:

Output
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!