Skip to content

Commit 9573171

Browse files
committed
[chore] : 차트 크기 변경
1 parent d0fa662 commit 9573171

4 files changed

Lines changed: 37 additions & 26 deletions

File tree

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
11
export const DIMENSIONS = {
22
width: 800,
3-
height: 400, // 기본 높이 (최소값)
4-
laneHeight: 60, // 각 폴더 레인당 고정 높이
5-
margin: { top: 40, right: 120, bottom: 60, left: 20 },
6-
};
7-
8-
/**
9-
* 폴더 개수에 따라 차트 높이를 동적으로 계산
10-
* @param folderCount 폴더 개수
11-
* @returns 계산된 차트 높이
12-
*/
13-
export const calculateChartHeight = (folderCount: number): number => {
14-
const contentHeight = folderCount * DIMENSIONS.laneHeight;
15-
return DIMENSIONS.margin.top + contentHeight + DIMENSIONS.margin.bottom;
3+
height: 500, // 고정 높이
4+
margin: { top: 20, right: 70, bottom: 20, left: 20 },
165
};

packages/view/src/components/FolderActivityFlow/FolderActivityFlow.scss

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,38 +55,52 @@
5555
}
5656

5757
&__breadcrumb {
58-
margin: 0 0 1rem 0;
5958
padding-left: 50px;
6059
font-size: $font-size-body;
60+
min-height: 24px; // 최소 높이 고정
61+
display: flex;
62+
align-items: center;
63+
64+
.MuiBreadcrumbs-ol {
65+
flex-wrap: nowrap; // 줄바꿈 방지
66+
}
6167

6268
.MuiBreadcrumbs-separator {
6369
color: $color-white;
70+
margin: 0 4px; // 고정 간격
6471
}
6572

6673
.MuiTypography-root {
6774
color: $color-white;
6875
font-size: $font-size-body;
6976
font-weight: $font-weight-regular;
77+
white-space: nowrap; // 텍스트 줄바꿈 방지
7078
}
7179

7280
.MuiLink-root {
7381
color: $color-white;
7482
font-size: $font-size-body;
7583
font-weight: $font-weight-regular;
84+
white-space: nowrap; // 텍스트 줄바꿈 방지
85+
text-decoration: none;
7686

7787
&:hover {
7888
color: $color-white;
89+
text-decoration: underline;
7990
}
8091
}
8192

8293
svg {
8394
color: $color-light-gray;
95+
display: block; // 인라인 간격 제거
8496
}
8597
}
8698

8799
&__chart {
88100
display: block;
89-
margin: 0 auto;
101+
width: 100%;
102+
padding: 0 50px;
103+
box-sizing: border-box;
90104
cursor: grab;
91105
background: $color-background;
92106
overflow: visible;

packages/view/src/components/FolderActivityFlow/FolderActivityFlow.tsx

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import NavigateNextIcon from "@mui/icons-material/NavigateNext";
88

99
import { useDataStore } from "store";
1010

11-
import { DIMENSIONS, calculateChartHeight } from "./FolderActivityFlow.const";
11+
import { DIMENSIONS } from "./FolderActivityFlow.const";
1212
import "./FolderActivityFlow.scss";
1313
import { extractReleaseBasedContributorActivities } from "./FolderActivityFlow.util";
1414
import { renderReleaseVisualization } from "./ReleaseVisualization";
@@ -19,6 +19,7 @@ const FolderActivityFlow = () => {
1919

2020
const svgRef = useRef<SVGSVGElement>(null);
2121
const tooltipRef = useRef<HTMLDivElement>(null);
22+
const containerRef = useRef<HTMLDivElement>(null);
2223

2324
const {
2425
currentPath,
@@ -45,25 +46,28 @@ const FolderActivityFlow = () => {
4546
return;
4647
}
4748

49+
// 컨테이너 너비 계산 (패딩 50px * 2 = 100px 제외)
50+
const containerWidth = containerRef.current?.clientWidth || DIMENSIONS.width;
51+
const chartWidth = containerWidth - 100; // 좌우 패딩 50px씩 제외
52+
53+
// 차트 높이 고정
54+
const chartHeight = DIMENSIONS.height;
55+
const svg = d3.select(svgRef.current).attr("width", chartWidth).attr("height", chartHeight);
56+
4857
// 실제로 activity가 있는 폴더만 카운트
4958
const currentDepth = currentPath === "" ? 1 : currentPath.split("/").length + 1;
5059
const releaseContributorActivities = extractReleaseBasedContributorActivities(
5160
totalData,
5261
releaseTopFolderPaths,
5362
currentDepth
5463
);
55-
const activeFolderCount = new Set(releaseContributorActivities.map((a) => a.folderPath)).size;
56-
57-
// 폴더 개수에 따라 동적으로 높이 계산
58-
const chartHeight = calculateChartHeight(activeFolderCount);
59-
const svg = d3.select(svgRef.current).attr("width", DIMENSIONS.width).attr("height", chartHeight);
6064

6165
svg.selectAll("*").remove();
6266

6367
if (releaseContributorActivities.length === 0) {
6468
svg
6569
.append("text")
66-
.attr("x", DIMENSIONS.width / 2)
70+
.attr("x", chartWidth / 2)
6771
.attr("y", chartHeight / 2)
6872
.attr("text-anchor", "middle")
6973
.attr("dominant-baseline", "middle")
@@ -80,11 +84,12 @@ const FolderActivityFlow = () => {
8084
tooltipRef,
8185
onFolderClick: navigateToFolder,
8286
chartHeight,
87+
chartWidth,
8388
});
8489
}, [totalData, releaseGroups, releaseTopFolderPaths, navigateToFolder, currentPath]);
8590

8691
return (
87-
<div className="folder-activity-flow">
92+
<div className="folder-activity-flow" ref={containerRef}>
8893
<div className="folder-activity-flow__header">
8994
<div>
9095
<p className="folder-activity-flow__title">Contributors Folder Activity Flow</p>
@@ -111,7 +116,7 @@ const FolderActivityFlow = () => {
111116
return (
112117
<Link
113118
key={crumb}
114-
underline="hover"
119+
underline="none"
115120
component="button"
116121
onClick={() => navigateToBreadcrumb(index, breadcrumbs.length)}
117122
sx={{ cursor: "pointer" }}

packages/view/src/components/FolderActivityFlow/ReleaseVisualization.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ interface ReleaseVisualizationProps {
2626
onFolderClick: (folderPath: string) => void;
2727
/** Chart height (calculated dynamically based on folder count) */
2828
chartHeight: number;
29+
/** Chart width (calculated dynamically based on container width) */
30+
chartWidth: number;
2931
}
3032

3133
/**
@@ -44,6 +46,7 @@ export const renderReleaseVisualization = ({
4446
tooltipRef,
4547
onFolderClick,
4648
chartHeight,
49+
chartWidth,
4750
}: ReleaseVisualizationProps) => {
4851
const tooltip = d3.select(tooltipRef.current);
4952

@@ -64,7 +67,7 @@ export const renderReleaseVisualization = ({
6467
const xScale = d3
6568
.scaleBand()
6669
.domain(uniqueReleases.map(String))
67-
.range([DIMENSIONS.margin.left, DIMENSIONS.width - DIMENSIONS.margin.right])
70+
.range([DIMENSIONS.margin.left, chartWidth - DIMENSIONS.margin.right])
6871
.paddingInner(0.1);
6972

7073
const yScale = d3
@@ -99,7 +102,7 @@ export const renderReleaseVisualization = ({
99102
const isFile = folderPath.includes(".");
100103
return isFile ? "folder-label" : "folder-label clickable";
101104
})
102-
.attr("x", DIMENSIONS.width - DIMENSIONS.margin.right + 10)
105+
.attr("x", chartWidth - DIMENSIONS.margin.right + 10)
103106
.attr("y", (folderPath: string) => (yScale(folderPath) || 0) + yScale.bandwidth() / 2)
104107
.attr("text-anchor", "start")
105108
.attr("dominant-baseline", "middle")

0 commit comments

Comments
 (0)