-
-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathJobAnalyticsGraph.jsx
More file actions
104 lines (97 loc) · 2.51 KB
/
JobAnalyticsGraph.jsx
File metadata and controls
104 lines (97 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import React from "react";
import PropTypes from "prop-types";
import { Bar } from "react-chartjs-2";
import {
Chart as ChartJS,
CategoryScale,
LinearScale,
BarElement,
Title,
Tooltip,
Legend,
} from "chart.js";
import ChartDataLabels from "chartjs-plugin-datalabels";
import styles from "./JobAnalyticsPage.module.css";
ChartJS.register(CategoryScale, LinearScale, BarElement, Title, Tooltip, Legend);
export default function JobAnalyticsGraph({ data, darkMode }) {
if (!Array.isArray(data) || data.length === 0) {
return <p>No data available</p>;
}
const chartData = {
labels: data.map((d) => d.role),
datasets: [
{
label: "Applications",
data: data.map((d) => d.applications ?? d.count ?? 0),
backgroundColor: darkMode ? "#3A506B" : "rgba(54, 162, 235, 0.7)",
},
],
};
const chartOptions = {
indexAxis: "y",
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: { display: false },
title: {
display: true,
text: "Most Competitive Roles",
color: darkMode ? "#E0E0E0" : "#111111",
font: { size: 18, weight: "bold" },
},
datalabels: {
color: darkMode ? "#E0E0E0" : "#111111",
anchor: "end",
align: "left",
offset: -5,
formatter: (value) => value.toLocaleString(),
font: { weight: "bold" },
},
},
scales: {
x: {
title: {
display: true,
text: "Number of Applications",
color: darkMode ? "#E0E0E0" : "#111111",
font: { weight: "bold", size: 14 },
},
ticks: {
color: darkMode ? "#E0E0E0" : "#111111",
},
grid: { color: darkMode ? "#333" : "#ddd" },
},
y: {
title: {
display: true,
text: "Role",
color: darkMode ? "#E0E0E0" : "#111111",
font: { weight: "bold", size: 14 },
},
ticks: {
color: darkMode ? "#E0E0E0" : "#111111",
},
grid: { color: darkMode ? "#333" : "#ddd" },
},
},
};
return (
<div className={styles.graphContainer}>
<Bar data={chartData} options={chartOptions} plugins={[ChartDataLabels]} />
</div>
);
}
JobAnalyticsGraph.propTypes = {
data: PropTypes.arrayOf(
PropTypes.shape({
role: PropTypes.string.isRequired,
applications: PropTypes.number,
count: PropTypes.number,
})
),
darkMode: PropTypes.bool,
};
JobAnalyticsGraph.defaultProps = {
data: [],
darkMode: false,
};