How to create bar chart in react using material UI and Devexpress ?
Last Updated :
07 Nov, 2023
Data visualization is an essential aspect of many web applications. To Create a Bar Chart in React using material UI and Devexpress is a commonly used visualization technique to represent data in a visually appealing and understandable format. I
DevExpress: DevExpress is a package for controlling and building the user interface of Windows, Mobile, and other applications.
Bar Charts: A bar chart is a pictorial representation of data that presents categorical data with rectangular bars with heights or lengths proportional to the values that they represent. In other words, it is the pictorial representation of the dataset. These data sets contain the numerical values of variables that represent the length or height.
Prerequisites
Approach
To create a Bar Chart in React using material UI and DevExpress, we will install the dev express and MUI packages first. Then create dummy data in the form of an array of objects with numeric values and represent them on the Bar chart using the Chart component and respective attributes.
Steps for 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 StructureThe updated dependencies in package.json file will look like:
"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:Â Thhis example implements chart component form the dev express to visualise the data as a Bar chart.
JavaScript
// Filename - App.js
import React from "react";
import Paper from "@material-ui/core/Paper";
import {
ArgumentAxis,
ValueAxis,
Chart,
BarSeries,
} from "@devexpress/dx-react-chart-material-ui";
const App = () => {
// Sample data
const data = [
{ argument: "Monday", value: 30 },
{ argument: "Tuesday", value: 20 },
{ argument: "Wednesday", value: 10 },
{ argument: "Thursday", value: 50 },
{ argument: "Friday", value: 60 },
];
return (
<Paper>
<Chart data={data}>
<ArgumentAxis />
<ValueAxis />
<BarSeries
valueField="value"
argumentField="argument"
/>
</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
Similar Reads
How to create pie chart in react using material UI and DevExpress ? We'll explore how to create dynamic and visually appealing pie charts in a React application by leveraging two powerful libraries: Material-UI and DevExpress. DevExpress: DevExpress is a package for controlling and building the user interface of the Window, Mobile, and other applications. Pie Charts
2 min read
How to create line chart in react using material UI and DevExpress ? 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
2 min read
How to create scatter chart in react using material UI and DevExpress ? This article will help us learn how to create scatter charts using the material UI library and devexpress using React JS. DevExpress: DevExpress is a package for controlling and building the user interface of Windows, Mobile, and other applications. Scatter Charts: A scatter chart is a set of dotted
2 min read
How to create Doughnut chart in react using material UI and DevExpress ? A doughnut chart represents a circular piechart-like visualization of data in a round figure with different colors or part of the circle represents an element with the area covered respective to their values. DevExpress: DevExpress is a package for controlling and building the user interface of Wind
2 min read
Create a Radial Bar Chart using Recharts in ReactJS Rechart JS is a library that is used for creating charts for React JS. This library is used for building Line charts, Bar charts, Pie charts, etc, with the help of React and D3 (Data-Driven Documents). Â A Radial Bar chart is a categorical bar chart that is displayed in polar coordinates. It is also
3 min read
How to create line chart using react bootstrap ? Line charts are used to represent the relation between two data X and 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. Creating React Application And Installing
2 min read