|
| 1 | +import React from 'react'; |
| 2 | +import { Doughnut } from 'react-chartjs-2'; |
| 3 | +import { Chart as ChartJS, ArcElement, Tooltip, Legend } from 'chart.js'; |
| 4 | + |
| 5 | +ChartJS.register(ArcElement, Tooltip, Legend); |
| 6 | + |
| 7 | +// eslint-disable-next-line react/function-component-definition |
| 8 | +const PieChart: React.FC = () => { |
| 9 | + const data = { |
| 10 | + labels: ['new pie chart'], |
| 11 | + datasets: [ |
| 12 | + { |
| 13 | + label: 'rates', |
| 14 | + data: [30, 100], |
| 15 | + backgroundColor: ['#4F46E5', '#A5B4FC'], |
| 16 | + hoverOffset: 4, |
| 17 | + }, |
| 18 | + ], |
| 19 | + }; |
| 20 | + const data2 = { |
| 21 | + labels: ['new pie chart'], |
| 22 | + datasets: [ |
| 23 | + { |
| 24 | + label: 'rates', |
| 25 | + data: [30, 70], |
| 26 | + backgroundColor: ['#4F46E5', '#A5B4FC'], |
| 27 | + hoverOffset: 4, |
| 28 | + }, |
| 29 | + ], |
| 30 | + }; |
| 31 | + const data3 = { |
| 32 | + labels: ['new pie chart'], |
| 33 | + datasets: [ |
| 34 | + { |
| 35 | + label: 'rates', |
| 36 | + data: [60, 60], |
| 37 | + backgroundColor: ['#4F46E5', '#A5B4FC'], |
| 38 | + hoverOffset: 4, |
| 39 | + }, |
| 40 | + ], |
| 41 | + }; |
| 42 | + |
| 43 | + const options = { |
| 44 | + responsive: true, |
| 45 | + cutout: '70%', |
| 46 | + plugins: { |
| 47 | + tooltip: { |
| 48 | + callbacks: { |
| 49 | + // eslint-disable-next-line func-names, object-shorthand |
| 50 | + label: function (tooltipItem: any) { |
| 51 | + return `${tooltipItem.label}: ${tooltipItem.raw}%`; |
| 52 | + }, |
| 53 | + }, |
| 54 | + }, |
| 55 | + legend: { |
| 56 | + display: false, |
| 57 | + }, |
| 58 | + }, |
| 59 | + }; |
| 60 | + |
| 61 | + return ( |
| 62 | + <div className="flex flex-col items-center -ml-8 mb-8"> |
| 63 | + <div className="flex space-x-8"> |
| 64 | + <div className="relative w-[200px] h-[200px] bg-red-200 p-2 rounded"> |
| 65 | + <Doughnut data={data} options={options} /> |
| 66 | + <div className="absolute inset-0 flex items-center justify-center"> |
| 67 | + <div className="text-center"> |
| 68 | + <p className="text-2xl font-semibold text-gray-500">10</p> |
| 69 | + </div> |
| 70 | + </div> |
| 71 | + <p className="text-center mt-2">New Invitations & Registration</p> |
| 72 | + </div> |
| 73 | + <div className="relative w-[200px] h-[200px] bg-green-200 p-2 rounded"> |
| 74 | + <Doughnut data={data2} options={options} /> |
| 75 | + <div className="absolute inset-0 flex items-center justify-center"> |
| 76 | + <div className="text-center"> |
| 77 | + <p className="text-2xl font-semibold text-gray-500">20</p> |
| 78 | + </div> |
| 79 | + </div> |
| 80 | + <p className="text-center mt-2">Upcoming Events</p> |
| 81 | + </div> |
| 82 | + <div className="relative w-[200px] h-[200px] bg-yellow-200 p-2 rounded"> |
| 83 | + <Doughnut data={data3} options={options} /> |
| 84 | + <div className="absolute inset-0 flex items-center justify-center"> |
| 85 | + <div className="text-center"> |
| 86 | + <p className="text-2xl font-semibold text-gray-500">50</p> |
| 87 | + </div> |
| 88 | + </div> |
| 89 | + <p className="text-center mt-2">Active& Progressive Tickets</p> |
| 90 | + </div> |
| 91 | + </div> |
| 92 | + </div> |
| 93 | + ); |
| 94 | +}; |
| 95 | + |
| 96 | +export default PieChart; |
0 commit comments