This project showcases various types of charts (Bar, Line, Area, Scatter, Pie, Column, Bubble, and Pictograph) using React and Chart.js. The charts use random generated or example data to illustrate how each type can be implemented.
- Bar chart for visualizing categories like monthly sales.
- Line graph for tracking trends such as website traffic.
- Area chart to show the filled area between two axes.
- Scatter plot for visualizing point data relationships.
- Pie chart for displaying portions of a whole dataset.
- Column chart for vertical bar representations.
- Bubble chart to plot data with varying bubble sizes.
- Pictograph representation using icons (such as apples).
This project is built with:
- React.js - A JavaScript library for building user interfaces.
- Chart.js - A JavaScript library for creating charts.
- React-Chartjs-2 - A React wrapper for Chart.js to make it easier to integrate in React apps.
- Clone the repository:
git clone https://github.com/praveenjadhav1510/Graphs---charts
- Navigate to the project directory:
cd Graphs---charts
- Install the dependencies:
npm install
- Run the development server:
npm start
The app should now be running at http://localhost:3000
.
This app includes the following chart types:
- Bar Chart
- Line Graph
- Area Chart
- Scatter Plot
- Pie Chart
- Column Chart
- Bubble Chart
Each chart is displayed with a unique dataset. Check out the /src/components/
folder to see the implementations.
In the App.js
file, all the charts are imported and displayed on the main page. You can customize the datasets in each component or add new charts using Chart.js by following the documentation links below.
import LineGraphComponent from './LineGraphComponent';
const App = () => {
return (
<div className="App">
<h1>React Chart.js Example</h1>
<LineGraphComponent />
</div>
);
};
export default App;
Each chart receives its data through a data
object. For example, the Line Graph uses:
const data = {
labels: ['Week 1', 'Week 2', 'Week 3', 'Week 4'],
datasets: [
{
label: 'Website Traffic',
data: [500, 600, 700, 800],
borderColor: 'blue',
fill: false,
},
],
};
You can update this data for your own use cases.
Contributions are welcome! If you have any ideas or suggestions for improving this project, feel free to open a pull request or create an issue.
To contribute:
- Fork the project.
- Create your feature branch (
git checkout -b feature/new-feature
). - Commit your changes (
git commit -m 'Add new feature'
). - Push to the branch (
git push origin feature/new-feature
). - Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for more details.