Ken-INOUE commited on
Commit
8e07b17
·
1 Parent(s): c8d9db6

Adjust vertical spacing in trend figure based on the number of tags to comply with Plotly constraints

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -361,9 +361,17 @@ def make_trend_figure(
361
  if not tags:
362
  return None
363
 
 
 
 
 
 
 
 
 
364
  fig = make_subplots(
365
- rows=len(tags), cols=1, shared_xaxes=True,
366
- vertical_spacing=0.03,
367
  subplot_titles=[f"{process_name} | 計測項目: {t}" for t in tags]
368
  )
369
 
 
361
  if not tags:
362
  return None
363
 
364
+ rows = len(tags)
365
+ # rows が多いときは、Plotly の制約: vertical_spacing <= 1/(rows-1)
366
+ if rows <= 1:
367
+ vspace = 0.03
368
+ else:
369
+ max_vs = (1.0 / (rows - 1)) - 1e-4 # ほんの少しだけマージンを取る
370
+ vspace = max(0.0, min(0.03, max_vs))
371
+
372
  fig = make_subplots(
373
+ rows=rows, cols=1, shared_xaxes=True,
374
+ vertical_spacing=vspace,
375
  subplot_titles=[f"{process_name} | 計測項目: {t}" for t in tags]
376
  )
377