Introduction
In this article, I will show you steps to create a Column Bar Chart component in React JS functional component using Apexcharts and Bootstrap libraries. Know the vertical column bar chart component in React js functional component. For column charts in React, we need Apexcharts and Bootstrap packages. Apexcharts is a free, open-source JavaScript chart library. It offers each and every type of chart and graph that allows UI developers to create attractive charts with Real-Time data.
Note. Before going through this session, please visit my previous article related to React applications, as mentioned below.
Step 1. Create New Component
Create a component named ReactApexColumnBarChart.js under /components/ReactApexColumnBarChart.
Code in ReactApexColumnBarChart.js
import React from "react";
import Chart from "react-apexcharts";
const data = {
series: [
{
name: "Male",
data: [44, 55, 57, 56, 61, 58, 63, 60, 66, 70, 14, 84],
},
{
name: "Female",
data: [76, 85, 101, 98, 87, 105, 91, 114, 94, 60, 16, 76],
},
{
name: "Unknown",
data: [35, 41, 36, 26, 45, 48, 52, 53, 41, 80, 20, 100],
},
],
options: {
chart: {
type: "bar",
height: 350,
},
plotOptions: {
bar: {
horizontal: false,
columnWidth: "55%",
endingShape: "rounded",
},
},
dataLabels: {
enabled: false,
},
stroke: {
show: true,
width: 2,
colors: ["transparent"],
},
xaxis: {
categories: [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
],
},
yaxis: {
title: {
text: "$ (thousands)",
},
},
fill: {
opacity: 1,
},
tooltip: {
y: {
formatter: function (val) {
return "$ " + val + " thousands";
},
},
},
},
};
function ReactApexColumnBarChart() {
return (
<>
<Chart
options={data.options}
series={data.series}
type="bar"
height={350}
/>
</>
);
}
export default ReactApexColumnBarChart;
Code Description
React component called ReactApexColumnBarChart() where we can get options and series properties from data as a const variable.
function ReactApexColumnBarChart() {
return (
<>
<Chart
options={data.options}
series={data.series}
type="bar"
height={350}
/>
</>
);
}
The series section is shown below.
series: [
{
name: "Male",
data: [44, 55, 57, 56, 61, 58, 63, 60, 66, 70, 14, 84],
},
{
name: "Female",
data: [76, 85, 101, 98, 87, 105, 91, 114, 94, 60, 16, 76],
},
{
name: "Unknown",
data: [35, 41, 36, 26, 45, 48, 52, 53, 41, 80, 20, 100],
},
],


Join the conversation! Your thoughts help the community grow.