Adjust vertical spacing in trend figure based on the number of tags to comply with Plotly constraints
Browse files
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=
|
| 366 |
-
vertical_spacing=
|
| 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 |
|