Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions src/components/dashboard/stats/ChartLineBuildingAccess.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const ChartLineBuildingAccess = () => {
document.body.classList.contains('dark-mode')
);

const chartColors = ['#5AC66F', '#235D3A', '#2e7d7a', '#82c7e2', '#0d6728', '#626262'];

useEffect(() => {
const observer = new MutationObserver(() => {
setIsDarkMode(document.body.classList.contains('dark-mode'));
Expand All @@ -34,13 +36,10 @@ const ChartLineBuildingAccess = () => {
data.forEach(({ date, day, buildingName, total }) => {
const dayNum = new Date(date).getDate();
const label = `${dayNum}일 ${day}요일`;

labelSet.add(label);

if (!grouped[buildingName]) {
grouped[buildingName] = {};
}

grouped[buildingName][label] = total;
});

Expand Down Expand Up @@ -70,21 +69,26 @@ const ChartLineBuildingAccess = () => {
chart: { type: 'line' },
stroke: { curve: 'straight', width: 2 },
markers: { size: 0 },
colors: chartColors,
dataLabels: {
enabled: true,
background: {
enabled: true,
foreColor: '#fff',
borderRadius: 2,
padding: 4,
opacity: 0.9,
borderRadius: 4,
opacity: 1,
dropShadow: { enabled: false },
},
style: {
fontSize: '11px',
fontWeight: 'bold',
colors: ['#fff'],
},
formatter: function (val, opts) {
const seriesIndex = opts.seriesIndex;
const backgroundColor = chartColors[seriesIndex % chartColors.length];
opts.w.config.dataLabels.background.backgroundColor = backgroundColor;
return val;
},
},
xaxis: {
categories: categories,
Expand All @@ -96,7 +100,6 @@ const ChartLineBuildingAccess = () => {
},
},
},
colors: ['#5AC66F', '#235D3A', '#2e7d7a', '#82c7e2', '#0d6728', '#626262'],
title: {
text: '건물별 출입 현황',
align: 'left',
Expand Down
19 changes: 19 additions & 0 deletions src/components/dashboard/stats/css/ChartLineBuildingAccess.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,22 @@
body.dark-mode .chart-line-building-access-card {
background: #3a3a3a;
}

.apexcharts-series[data\:realIndex="0"] .apexcharts-datalabel {
background-color: #5AC66F !important;
}
.apexcharts-series[data\:realIndex="1"] .apexcharts-datalabel {
background-color: #235D3A !important;
}
.apexcharts-series[data\:realIndex="2"] .apexcharts-datalabel {
background-color: #2e7d7a !important;
}
.apexcharts-series[data\:realIndex="3"] .apexcharts-datalabel {
background-color: #82c7e2 !important;
}
.apexcharts-series[data\:realIndex="4"] .apexcharts-datalabel {
background-color: #0d6728 !important;
}
.apexcharts-series[data\:realIndex="5"] .apexcharts-datalabel {
background-color: #626262 !important;
}