File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed
Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change 147147 text-align : center;
148148 width : 100% ;
149149 min-width : 320px ;
150- min-height : 400px ;
151150 margin-top : 20px ;
152151 }
153152 canvas {
162161 }
163162 # graphCanvas {
164163 width : 100% ;
165- height : 400px ;
166164 display : block;
167165 }
168166 .info {
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 ;
You can’t perform that action at this time.
0 commit comments