fix(react-chartjs version ): Fixed react-chartjs version outdated

This commit is contained in:
Laurian-Dufrechou
2023-05-20 19:27:52 +02:00
parent 97be61a48d
commit ace8284c6a
8 changed files with 19055 additions and 4135 deletions
+10 -8
View File
@@ -1,18 +1,20 @@
import React, { useEffect, useState } from 'react';
import { Pie } from 'react-chartjs-2';
import React, { useEffect, useState } from "react";
import { Pie } from "react-chartjs-2";
import { Chart as ChartJS, ArcElement, Tooltip, Legend } from "chart.js";
const PieChart = () => {
const [userData, setUserData] = useState([]);
ChartJS.register(ArcElement, Tooltip, Legend);
useEffect(() => {
// Fonction pour récupérer les données des utilisateurs depuis le backend
const fetchUserData = async () => {
try {
const response = await fetch('/api/users');
const response = await fetch("/api/users");
const data = await response.json();
setUserData(data);
} catch (error) {
console.error('Failed to fetch user data:', error);
console.error("Failed to fetch user data:", error);
}
};
@@ -39,12 +41,12 @@ const PieChart = () => {
// Préparer les données pour le chart
const data = {
labels: ['MALE', 'FEMALE', 'OTHER', 'UNKNOWN'],
labels: ["MALE", "FEMALE", "OTHER", "UNKNOWN"],
datasets: [
{
data: countGenders(),
backgroundColor: ['#FF6384', '#36A2EB', '#FFCE56', '#C0C0C0'],
hoverBackgroundColor: ['#FF6384', '#36A2EB', '#FFCE56', '#C0C0C0'],
backgroundColor: ["#FF6384", "#36A2EB", "#FFCE56", "#C0C0C0"],
hoverBackgroundColor: ["#FF6384", "#36A2EB", "#FFCE56", "#C0C0C0"],
},
],
};
@@ -52,4 +54,4 @@ const PieChart = () => {
return <Pie data={data} />;
};
export default PieChart;
export default PieChart;