diff --git a/packages/khbuild_process_viz/src/gantt.ts b/packages/khbuild_process_viz/src/gantt.ts index 7a80624..73b220f 100644 --- a/packages/khbuild_process_viz/src/gantt.ts +++ b/packages/khbuild_process_viz/src/gantt.ts @@ -343,7 +343,9 @@ export function renderGantt(model: ProcessModel, schedule: Schedule, opts: Gantt } if (ms || t.kind === "milestone") { const px0 = x(t.end); - out.push(``); + const late = t.deadline !== null && t.end > t.deadline; + if (t.deadline !== null && t.end !== t.deadline) out.push(``); + out.push(``); if (!hasBar && name) { out.push(`${esc(name)}`); } @@ -393,11 +395,14 @@ export function renderGantt(model: ProcessModel, schedule: Schedule, opts: Gantt for (const [a, b] of s.segments) { out.push(``); } - const diamond = (dx: number, size: number) => ``; + const diamond = (dx: number, size: number, late = false) => ``; const markDays = new Set(s.milestones.map((m) => m.day)); 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 && m.day !== m.deadline) out.push(``); + out.push(diamond(x(m.day), 8, m.deadline !== null && m.day > m.deadline)); + } for (const m of s.milestones) { if (m.deadline === null) continue; const rx = x(m.deadline); diff --git a/packages/khbuild_process_viz/src/viz.test.ts b/packages/khbuild_process_viz/src/viz.test.ts index e37939e..b2ecd77 100644 --- a/packages/khbuild_process_viz/src/viz.test.ts +++ b/packages/khbuild_process_viz/src/viz.test.ts @@ -195,6 +195,20 @@ describe("computeSchedule", () => { expect(svg.split('stroke="#d32f2f" stroke-width="3"').length - 1).toBe(3); // черта у CP-5, в сводной полосе группы и знак в легенде expect(svg).toContain("Крайний срок: день 75"); expect(svg).toContain("Крайний срок: CP-5, день 75"); // и в сводной полосе группы + expect(svg).toContain('stroke="#d32f2f" stroke-width="1" stroke-dasharray="3 3"'); // пунктир от ромба до красной черты + expect(svg).not.toContain('stroke="#d32f2f" stroke-width="2.5"'); // опоздавшей вехи нет + }); + + it("веха правее крайнего срока: ромб остаётся справа от черты и обведён красным", () => { + const rows = [ + row({ id: "CP-0", stage: "S", date_constraint: "день 0" }), + row({ id: "S-1", stage: "S", depends_on: "CP-0", duration: "20d" }), + row({ id: "CP-5", stage: "S", depends_on: "S-1", date_constraint: "не позже дня 7" }), + ]; + const sc = computeSchedule(rows); + expect(sc.timings.get("CP-5")).toMatchObject({ end: 20, deadline: 7 }); + const svg = renderGantt({ ...model, rows }, sc, {}); + expect(svg).toContain('stroke="#d32f2f" stroke-width="2.5"'); // красный контур ромба }); it("повторяющиеся шаги тянутся до конца проекта и не считаются предшественниками", () => {