Skip to content

Commit d1f106b

Browse files
authored
Update index.html
1 parent f82dde5 commit d1f106b

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

index.html

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@
147147
text-align: center;
148148
width: 100%;
149149
min-width: 320px;
150-
min-height: 400px;
151150
margin-top: 20px;
152151
}
153152
canvas {
@@ -162,7 +161,6 @@
162161
}
163162
#graphCanvas {
164163
width: 100%;
165-
height: 400px;
166164
display: block;
167165
}
168166
.info {
@@ -308,7 +306,22 @@
308306
const dpr = window.devicePixelRatio || 1;
309307
const rect = container.getBoundingClientRect();
310308
const width = Math.floor(rect.width);
311-
const height = 400; // 固定高さ
309+
310+
// 画面の高さから必要な要素の高さを引いて、グラフが収まる高さを計算
311+
const viewportHeight = window.innerHeight;
312+
const controlsHeight = document.querySelector('.controls').offsetHeight;
313+
const h1Height = document.querySelector('h1') ? document.querySelector('h1').offsetHeight : 0;
314+
const marginTop = 20; // コンテナのmargin-top
315+
const gradientBarsHeight = 40 * 2 + 20; // グラデーションバー2つ分 + 余白
316+
const extraMargin = 40; // 追加の余白
317+
318+
// 利用可能な高さを計算
319+
const availableHeight = viewportHeight - controlsHeight - h1Height - marginTop - gradientBarsHeight - extraMargin;
320+
321+
// 最小高さ200px、最大高さ600px、アスペクト比も考慮
322+
const aspectRatio = 0.6; // 高さ/幅の比率
323+
const heightByAspect = width * aspectRatio;
324+
const height = Math.min(600, Math.max(200, Math.min(availableHeight, heightByAspect)));
312325

313326
canvas.width = width * dpr;
314327
canvas.height = height * dpr;

0 commit comments

Comments
 (0)