Гант: красные черты крайнего срока и в сводной строке группы
All checks were successful
ci / test (push) Successful in 26s
ci / deploy (push) Successful in 1m33s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-17 17:08:39 +03:00
parent 82cb6ba0a6
commit abfc459e2a
2 changed files with 9 additions and 3 deletions

View File

@@ -82,7 +82,7 @@ export interface GroupSummary {
start: number;
end: number;
/** вехи группы: строки с признаком is_milestone, по дате завершения */
milestones: Array<{ row: ProcessRow; day: number }>;
milestones: Array<{ row: ProcessRow; day: number; deadline: number | null }>;
/** отрезки, где в группе идут активности (объединение интервалов работ); между ними полоса прерывается */
segments: Array<[number, number]>;
}
@@ -98,7 +98,7 @@ export function summarizeGroup(stage: string, rows: Array<{ row: ProcessRow; t:
const end = Math.max(...base.map(({ t }) => t.end));
const milestones = rows
.filter(({ row, t }) => row.isMilestone && t.kind !== "recurring")
.map(({ row, t }) => ({ row, day: t.end }))
.map(({ row, t }) => ({ row, day: t.end, deadline: t.deadline }))
.sort((a, b) => a.day - b.day || a.row.id.localeCompare(b.row.id, "ru", { numeric: true }));
// Сводная полоса показывает занятость: отрезки работ объединяются, там где активностей нет - разрыв, дальше полоса продолжается.
// Если в группе нет ни одной работы с длительностью (только вехи), рисуется один сплошной отрезок от начала до конца.
@@ -398,6 +398,11 @@ export function renderGantt(model: ProcessModel, schedule: Schedule, opts: Gantt
if (!markDays.has(s.start)) out.push(diamond(x(s.start), 6));
if (!markDays.has(s.end)) out.push(diamond(x(s.end), 6));
for (const m of s.milestones) out.push(diamond(x(m.day), 8));
for (const m of s.milestones) {
if (m.deadline === null) continue;
const rx = x(m.deadline);
out.push(`<line x1="${rx}" y1="${cy - 12}" x2="${rx}" y2="${cy + 12}" stroke="#d32f2f" stroke-width="3"><title>${esc(`Крайний срок: ${m.row.id}, день ${m.deadline}`)}</title></line>`);
}
for (const l of g.labels) {
const ly = barY - 4 - l.level * LABEL_STEP;
out.push(`<text x="${l.x}" y="${ly}" text-anchor="middle" font-size="11" font-weight="600" fill="${c.stroke}">${esc(l.text)}</text>`);

View File

@@ -192,8 +192,9 @@ describe("computeSchedule", () => {
expect(sc.timings.get("CP-3")).toMatchObject({ end: 45, deadline: null }); // «около» крайним сроком не считается
expect(sc.warnings).toEqual([]);
const svg = renderGantt({ ...model, rows }, sc, {});
expect(svg.split('stroke="#d32f2f" stroke-width="3"').length - 1).toBe(2); // черта у CP-5 и один знак в легенде
expect(svg.split('stroke="#d32f2f" stroke-width="3"').length - 1).toBe(3); // черта у CP-5, в сводной полосе группы и знак в легенде
expect(svg).toContain("Крайний срок: день 75");
expect(svg).toContain("Крайний срок: CP-5, день 75"); // и в сводной полосе группы
});
it("повторяющиеся шаги тянутся до конца проекта и не считаются предшественниками", () => {