Programming
notebook-tag
def kind_tag(fig, kind, legend_items=None):
"""
СТОК / ПОТОК marker printed on the chart itself, so it survives into PPT.
The tag sits under the title, and the legend is pushed below the tag rather
than sharing its band. Legends wrap, so the gap is sized from the number of
entries — 7 products plus a line wrap to two rows and used to collide.
"""
txt = {"СТОК": "СТОК · снимок на отчётную дату, по месяцам не суммируется",
"ПОТОК": "ПОТОК · движение внутри месяца, суммируется",
"КОГОРТЫ": "КОГОРТЫ · разрез по месяцу выдачи",
"СРЕЗ": "СРЕЗ · одна отчётная дата"}.get(kind, kind)
n = legend_items if legend_items is not None else len(
[t for t in fig.data if t.showlegend is not False and t.name])
rows = max(1, math.ceil(n / 4)) # roughly four entries fit per row
tag_y = 1.045
leg_y = tag_y + 0.035
top_pad = 104 + 26 * rows # room for title + tag + legend rows
fig.add_annotation(text=txt, xref="paper", yref="paper", x=0, y=tag_y,
xanchor="left", yanchor="bottom", showarrow=False,
font=dict(size=10.5, color=BRAND["gold_deep"]))
fig.update_layout(legend=dict(y=leg_y, yanchor="bottom", x=0),
margin=dict(t=top_pad))
return fig
PO
powerty
Author
· Staff
Aug. 28, 2026
Aug. 28, 2026
2
Views
0
Likes
1m
Read