-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex2.html
More file actions
128 lines (116 loc) · 4.17 KB
/
ex2.html
File metadata and controls
128 lines (116 loc) · 4.17 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>보안 대시보드</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
margin: 30px;
background-color: #f9fafb;
}
.dashboard {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 20px;
}
.chart-container {
padding: 20px;
background: #fff;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
border-radius: 10px;
max-width: 500px;
width: 100%;
text-align: center;
}
.chart-title {
font-size: 1.5em;
margin-bottom: 10px;
font-weight: bold;
}
.total-count {
font-size: 1.8em;
font-weight: bold;
color: #333;
margin-bottom: 10px;
}
#sensitiveInfoChart {
max-width: 400px;
margin: auto;
}
</style>
</head>
<body>
<div class="dashboard">
<div class="chart-container">
<h3 class="chart-title">한 달간 감지된 민감 텍스트</h3>
<h1 id="totalCount" class="total-count">0건</h1>
<p>이번 달 총 감지 건수</p>
<canvas id="dailyRiskChart"></canvas>
</div>
<div class="chart-container">
<h3 class="chart-title">유형별 민감 정보</h3>
<canvas id="sensitiveInfoChart"></canvas>
</div>
</div>
<script>
const dailyRiskData = [
{ date: "03/01", detection_count: 12 },
{ date: "03/02", detection_count: 7 },
{ date: "03/03", detection_count: 14 },
{ date: "03/04", detection_count: 8 },
{ date: "03/05", detection_count: 27 }
];
const sensitiveInfoData = {
labels: ["주민등록번호", "신용카드", "계좌번호", "기타"],
values: [40, 30, 20, 10]
};
document.getElementById('totalCount').innerText = dailyRiskData.reduce((acc, val) => acc + val.detection_count, 0) + '건';
function drawBarChart(id, labels, values) {
const ctx = document.getElementById(id).getContext("2d");
new Chart(ctx, {
type: "bar",
data: {
labels: labels,
datasets: [{
data: values,
backgroundColor: "rgba(104, 132, 245, 0.7)",
borderColor: "rgba(104, 132, 245, 1)",
borderWidth: 1
}]
},
options: {
responsive: true,
scales: {
x: { grid: { display: false } },
y: { grid: { display: false }, beginAtZero: true }
},
plugins: { legend: { display: false } }
}
});
}
function drawPieChart(id, labels, values) {
const ctx = document.getElementById(id).getContext("2d");
new Chart(ctx, {
type: "pie",
data: {
labels: labels,
datasets: [{
data: values,
backgroundColor: ["#818cf8", "#f87171", "#fbbf24", "#34d399"]
}]
},
options: { responsive: true, plugins: { legend: { position: "bottom" } } }
});
}
document.addEventListener("DOMContentLoaded", () => {
drawBarChart("dailyRiskChart", dailyRiskData.map(item => item.date), dailyRiskData.map(item => item.detection_count));
drawPieChart("sensitiveInfoChart", sensitiveInfoData.labels, sensitiveInfoData.values);
});
</script>
</body>
</html>