How to create bar chart in react using material UI and Devexpress ? - GeeksforGeeks

19 Jul, 2021
DevExpress: DevExpress is a package for controlling and building the user interface of the Window, 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.
Steps for creating React Application And Installing Module:
Step 1: Create a React application using the following command.npx create-react-app foldername 
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 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
npm install @material-ui/core
npm i --save @devexpress/dx-react-chart-material-ui
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
npm install @material-ui/core
npm i --save @devexpress/dx-react-chart-material-ui
Project Structure: It will look like the following :
Project Structure
Example: Now write down the following code in the App.js file. Here, the App is our default component where we have written our code.
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 dataconst 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
Material-UI
Picked
React-Questions
JavaScript
ReactJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Difference between var, let and const keywords in JavaScript
Difference Between PUT and PATCH Request
JavaScript | Promises
How to get character array from string in JavaScript?
How to fetch data from an API in ReactJS ?
How to redirect to another page in ReactJS ?
How to pass data from child component to its parent in ReactJS ?
How to pass data from one component to other component in ReactJS ?
ReactJS Functional Components