Skip to content

Commit 04adfc8

Browse files
add logins modol
2 parents 8db60b5 + 3ebab71 commit 04adfc8

File tree

6 files changed

+615
-43
lines changed

6 files changed

+615
-43
lines changed

src/Chart/ProgressBar.tsx

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import React from 'react';
2+
3+
interface ProgressBarProps {
4+
passedPercentage: number; // Percentage of passed logins
5+
failedPercentage: number; // Percentage of failed logins
6+
}
7+
8+
function ProgressBar({ passedPercentage, failedPercentage }: ProgressBarProps) {
9+
return (
10+
<div className="w-1/2 space-y-4">
11+
<div className="relative h-6 rounded-full overflow-hidden bg-gray-200 dark:bg-gray-700">
12+
<div
13+
className="absolute h-full bg-green-500 text-white text-center"
14+
style={{ width: `${passedPercentage}%` }}
15+
>
16+
{passedPercentage}%
17+
</div>
18+
<div
19+
className="absolute h-full bg-red-500 text-white text-center"
20+
style={{
21+
width: `${failedPercentage}%`,
22+
left: `${passedPercentage}%`,
23+
}}
24+
>
25+
{failedPercentage}%
26+
</div>
27+
</div>
28+
<div className="flex justify-between text-sm text-gray-600 dark:text-gray-300">
29+
<p className="text-sm text-gray-600 dark:text-gray-300">
30+
<span className="text-green-500 font-semibold">Green</span>: Passed
31+
Logins
32+
</p>
33+
<p className="text-sm text-gray-600 dark:text-gray-300">
34+
<span className="text-red-500 font-semibold">Red</span>: Failed Logins
35+
</p>
36+
</div>
37+
</div>
38+
);
39+
}
40+
41+
export default ProgressBar;

src/Chart/TeamChart.tsx

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
import React from 'react';
2+
import { Line } from 'react-chartjs-2';
3+
import {
4+
Chart as ChartJS,
5+
CategoryScale,
6+
LinearScale,
7+
PointElement,
8+
LineElement,
9+
Title,
10+
Tooltip,
11+
Legend,
12+
} from 'chart.js';
13+
14+
ChartJS.register(
15+
CategoryScale,
16+
LinearScale,
17+
PointElement,
18+
LineElement,
19+
Title,
20+
Tooltip,
21+
Legend,
22+
);
23+
24+
interface TeamChartProps {
25+
timeframe?: 'daily' | 'weekly' | 'monthly';
26+
}
27+
28+
function TeamChart({ timeframe = 'daily' }: TeamChartProps) {
29+
const chartData = {
30+
daily: {
31+
labels: ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'],
32+
datasets: [
33+
{
34+
label: 'Andela',
35+
data: [1, 3, 0, 2, 1, 3, 2],
36+
fill: false,
37+
borderColor: '#4F46E5',
38+
tension: 0.4,
39+
},
40+
],
41+
},
42+
weekly: {
43+
labels: [
44+
'03',
45+
'06',
46+
'09',
47+
'12',
48+
'15',
49+
'18',
50+
'21',
51+
'24',
52+
'27',
53+
'30',
54+
'31',
55+
'34',
56+
'37',
57+
'40',
58+
'43',
59+
'46',
60+
'49',
61+
'54',
62+
],
63+
datasets: [
64+
{
65+
label: 'Andela',
66+
data: [1, 3, 0, 2, 1, 3, 2, 0, 2, 1, 3, 0, 2, 1, 4, 1, 2, 4],
67+
fill: false,
68+
borderColor: '#4F46E5',
69+
tension: 0.4,
70+
},
71+
],
72+
},
73+
monthly: {
74+
labels: Array.from({ length: 31 }, (_, i) =>
75+
String(i + 1).padStart(2, '0'),
76+
),
77+
datasets: [
78+
{
79+
label: 'Andela',
80+
data: Array.from({ length: 31 }, () => Math.floor(Math.random() * 8)),
81+
fill: false,
82+
borderColor: '#4F46E5',
83+
tension: 0.4,
84+
},
85+
],
86+
},
87+
};
88+
89+
const options = {
90+
responsive: true,
91+
maintainAspectRatio: false,
92+
plugins: {
93+
legend: {
94+
position: 'bottom' as const,
95+
},
96+
tooltip: {
97+
mode: 'index' as const,
98+
intersect: false,
99+
},
100+
},
101+
scales: {
102+
y: {
103+
beginAtZero: true,
104+
grid: {
105+
color: '#D1D5DB',
106+
},
107+
ticks: {
108+
color: '#6B7280',
109+
},
110+
},
111+
x: {
112+
grid: {
113+
display: false,
114+
},
115+
ticks: {
116+
color: '#6B7280',
117+
},
118+
},
119+
},
120+
};
121+
122+
return (
123+
<div className="w-full max-w-4xl h-[60vh] max-h-[500px] mx-auto p-4 md:p-6 lg:p-8 bg-white dark:bg-gray-800 rounded-md shadow-md">
124+
<Line data={chartData[timeframe]} options={options} />
125+
</div>
126+
);
127+
}
128+
129+
export default TeamChart;

src/Chart/UsersChart.tsx

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,58 @@ ChartJS.register(
2121
Legend,
2222
);
2323

24-
// eslint-disable-next-line react/function-component-definition
25-
// Rename the function component from usersChart to UsersChart
26-
const UsersChart: React.FC = () => {
24+
function UsersChart() {
2725
const data = {
2826
labels: [
29-
'01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13',
30-
'14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26',
31-
'27', '28', '29', '30', '31',
27+
'01',
28+
'02',
29+
'03',
30+
'04',
31+
'05',
32+
'06',
33+
'07',
34+
'08',
35+
'09',
36+
'10',
37+
'11',
38+
'12',
39+
'13',
40+
'14',
41+
'15',
42+
'16',
43+
'17',
44+
'18',
45+
'19',
46+
'20',
47+
'21',
48+
'22',
49+
'23',
50+
'24',
51+
'25',
52+
'26',
53+
'27',
54+
'28',
55+
'29',
56+
'30',
57+
'31',
3258
],
3359
datasets: [
3460
{
3561
label: 'Andela',
36-
data: [1, 3, 0, 2, 1, 3, 2, 0, 2, 1, 3, 0, 2, 1, 4, 1, 2, 4, 7, 2, 3, 4, 4, 3, 8, 0, 3, 5, 7],
62+
data: [
63+
1, 3, 0, 2, 1, 3, 2, 0, 2, 1, 3, 0, 2, 1, 4, 1, 2, 4, 7, 2, 3, 4, 4,
64+
3, 8, 0, 3, 5, 7,
65+
],
3766
fill: false,
3867
borderColor: '#4F46E5',
3968
tension: 0.4,
4069
},
4170
{
4271
label: 'NESA',
43-
data: [2, 3, 6, 4, 3, 4, 2, 1, 2, 6, 2, 2, 3, 2, 3, 5, 7, 2, 1, 2, 4, 6, 6, 1, 2, 3, 4, 5, 6.5],
72+
data: [
73+
2, 3, 6, 4, 3, 4, 2, 1, 2, 6, 2, 2, 3, 2, 3, 5, 7, 2, 1, 2, 4, 6, 6,
74+
1, 2, 3, 4, 5, 6.5,
75+
],
4476
fill: false,
4577
borderColor: '#8C8120',
4678
tension: 0.4,
@@ -50,6 +82,7 @@ const UsersChart: React.FC = () => {
5082

5183
const options = {
5284
responsive: true,
85+
maintainAspectRatio: false,
5386
plugins: {
5487
legend: {
5588
position: 'bottom' as const,
@@ -71,10 +104,10 @@ const UsersChart: React.FC = () => {
71104
};
72105

73106
return (
74-
<div className="w-full h-[300px]">
75-
<Line data={data} options={options} className="-ml-8" />
107+
<div className="w-full max-w-4xl h-[60vh] max-h-[500px] mx-auto p-4 md:p-6 lg:p-8 bg-white dark:bg-gray-800 rounded-md shadow-md">
108+
<Line data={data} options={options} />
76109
</div>
77110
);
78-
};
111+
}
79112

80113
export default UsersChart;

0 commit comments

Comments
 (0)