Гант: групповая полоса прерывается там, где нет активностей; справочник этапов (stages) в модели
All checks were successful
ci / test (push) Successful in 20s
ci / deploy (push) Successful in 1m19s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-14 20:15:28 +03:00
parent cf1ba11bf7
commit 317d6249e8
4 changed files with 88 additions and 4 deletions

View File

@@ -93,6 +93,8 @@ export interface GroupSummary {
end: number;
/** вехи группы: строки с признаком is_milestone, по дате завершения */
milestones: Array<{ row: ProcessRow; day: number }>;
/** отрезки, где в группе идут активности (объединение интервалов работ); между ними полоса прерывается */
segments: Array<[number, number]>;
}
/**
@@ -108,7 +110,21 @@ export function summarizeGroup(stage: string, rows: Array<{ row: ProcessRow; t:
.filter(({ row, t }) => row.isMilestone && t.kind !== "recurring")
.map(({ row, t }) => ({ row, day: t.end }))
.sort((a, b) => a.day - b.day || a.row.id.localeCompare(b.row.id, "ru", { numeric: true }));
return { stage, start: Number.isFinite(start) ? start : 0, end: Number.isFinite(end) ? end : 0, milestones };
// Сводная полоса показывает занятость: отрезки работ объединяются, там где активностей нет - разрыв, дальше полоса продолжается.
// Если в группе нет ни одной работы с длительностью (только вехи), рисуется один сплошной отрезок от начала до конца.
const tasks = rows
.filter(({ t }) => t.kind === "task")
.map(({ t }) => [t.start, t.end] as [number, number])
.sort((a, b) => a[0] - b[0] || a[1] - b[1]);
const segments: Array<[number, number]> = [];
for (const [a, b] of tasks) {
const last = segments.at(-1);
if (last && a <= last[1]) last[1] = Math.max(last[1], b);
else segments.push([a, b]);
}
const s0 = Number.isFinite(start) ? start : 0;
const e0 = Number.isFinite(end) ? end : 0;
return { stage, start: s0, end: e0, milestones, segments: segments.length ? segments : [[s0, e0]] };
}
interface PlacedLabel { x: number; level: number; text: string; row: ProcessRow }
@@ -348,7 +364,9 @@ export function renderGantt(model: ProcessModel, schedule: Schedule, opts: Gantt
if (people.length) out.push(`<text x="32" y="${g.top + 34}" font-size="11" fill="#667085">${esc(truncate(people.join(" · "), 44))}</text>`);
out.push("</g>");
out.push(`<g>${tip}`);
out.push(`<rect x="${x(s.start)}" y="${barY}" width="${Math.max(2, (s.end - s.start) * px)}" height="${GROUP_BAR_H}" rx="2" fill="${c.stroke}" stroke="${c.stroke}" stroke-width="1.2"/>`);
for (const [a, b] of s.segments) {
out.push(`<rect x="${x(a)}" y="${barY}" width="${Math.max(2, (b - a) * px)}" height="${GROUP_BAR_H}" rx="2" fill="${c.stroke}" stroke="${c.stroke}" stroke-width="1.2"/>`);
}
const diamond = (dx: number, size: number) => `<path d="M${dx} ${cy - size} L${dx + size} ${cy} L${dx} ${cy + size} L${dx - size} ${cy} Z" fill="${c.stroke}" stroke="#fff" stroke-width="1"/>`;
const markDays = new Set(s.milestones.map((m) => m.day));
if (!markDays.has(s.start)) out.push(diamond(x(s.start), 6));