Skip to content

Commit 9a5c4e5

Browse files
resolve merge issues (#141)
1 parent acead0b commit 9a5c4e5

File tree

3 files changed

+108
-2
lines changed

3 files changed

+108
-2
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"url": "https://github.com/uclaacm/bias-by-us/issues"
1919
},
2020
"devDependencies": {
21-
"husky": "^7.0.0"
21+
"husky": "^7.0.0",
22+
"lint-staged": "^16.2.6"
2223
}
2324
}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import React, { useEffect, useRef } from "react";
2+
import {
3+
Chart as ChartJS,
4+
BarController,
5+
BarElement,
6+
CategoryScale,
7+
LinearScale,
8+
Tooltip,
9+
Legend,
10+
} from "chart.js";
11+
12+
ChartJS.register(
13+
BarController,
14+
BarElement,
15+
CategoryScale,
16+
LinearScale,
17+
Tooltip,
18+
Legend,
19+
);
20+
21+
export default function AccuracyChart() {
22+
const canvasRef = useRef(null);
23+
const chartInstanceRef = useRef(null);
24+
25+
useEffect(() => {
26+
const ctx = canvasRef.current.getContext("2d");
27+
28+
if (chartInstanceRef.current) {
29+
chartInstanceRef.current.destroy();
30+
}
31+
32+
const data = {
33+
labels: ["Microsoft", "Face++", "IBM", "Amazon", "Kairos"],
34+
datasets: [
35+
{
36+
label: "Darker female",
37+
backgroundColor: "#e58a84",
38+
data: [79.2, 65.5, 65.3, 68.63, 77.5],
39+
},
40+
{
41+
label: "Darker male",
42+
backgroundColor: "#b39ce4",
43+
data: [94, 99.3, 88, 98.74, 98.7],
44+
},
45+
{
46+
label: "Lighter female",
47+
backgroundColor: "#8cb492",
48+
data: [98.3, 90.2, 92.9, 92.88, 93.6],
49+
},
50+
{
51+
label: "Lighter male",
52+
backgroundColor: "#f7c795",
53+
data: [100, 99.2, 99.7, 100, 100],
54+
},
55+
],
56+
};
57+
58+
const chart = new ChartJS(ctx, {
59+
type: "bar",
60+
data,
61+
options: {
62+
responsive: true,
63+
plugins: {
64+
legend: {
65+
position: "bottom",
66+
},
67+
tooltip: {
68+
callbacks: {
69+
label: (context) =>
70+
`${context.dataset.label}: ${context.parsed.y}%`,
71+
},
72+
},
73+
title: {
74+
display: true,
75+
text: "Accuracy of Face Recognition Technologies",
76+
},
77+
},
78+
scales: {
79+
y: {
80+
beginAtZero: true,
81+
title: {
82+
display: true,
83+
text: "Accuracy (%)",
84+
},
85+
},
86+
},
87+
},
88+
});
89+
90+
chartInstanceRef.current = chart;
91+
92+
return () => {
93+
if (chartInstanceRef.current) {
94+
chartInstanceRef.current.destroy();
95+
}
96+
};
97+
}, []);
98+
99+
return (
100+
<div style={{ width: "100%", maxWidth: "800px", margin: "0 auto" }}>
101+
<canvas ref={canvasRef} />
102+
</div>
103+
);
104+
}

website/src/caseStudies/FacialRecognition.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import "../main.css";
33
import teachLogo from "../assets/teachla-logo.svg";
44
import PostsList from "../components/mainContent/PostsList";
55
import CategorizationGame from "../components/posts/FacialRecognition/CategorizationGame";
6+
import AccuracyChart from "../components/posts/FacialRecognition/AccuracyChart";
67
import { VisibilityProvider } from "../components/mainContent/commonLogic";
78

89
export default function FacialRecognition() {
@@ -105,7 +106,7 @@ const FacialRecognitionInfo = [
105106
],
106107
},
107108
},
108-
109+
109110
{
110111
post: {
111112
profilePic: teachLogo,

0 commit comments

Comments
 (0)