Гант: пунктир от вехи до красной черты; опоздавшая веха справа от черты с красным контуром
All checks were successful
ci / test (push) Successful in 25s
ci / deploy (push) Successful in 1m32s

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

View File

@@ -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(`<path d="M${px0} ${cy - 8} L${px0 + 8} ${cy} L${px0} ${cy + 8} L${px0 - 8} ${cy} Z" fill="#1f1f1f" stroke="#fff" stroke-width="1.2"/>`);
const late = t.deadline !== null && t.end > t.deadline;
if (t.deadline !== null && t.end !== t.deadline) out.push(`<line x1="${px0}" y1="${cy}" x2="${x(t.deadline)}" y2="${cy}" stroke="#d32f2f" stroke-width="1" stroke-dasharray="3 3"/>`);
out.push(`<path d="M${px0} ${cy - 8} L${px0 + 8} ${cy} L${px0} ${cy + 8} L${px0 - 8} ${cy} Z" fill="#1f1f1f" stroke="${late ? "#d32f2f" : "#fff"}" stroke-width="${late ? 2.5 : 1.2}"/>`);
if (!hasBar && name) {
out.push(`<text x="${px0 + 12}" y="${cy + 4}" font-size="11" font-weight="600" fill="${c.stroke}">${esc(name)}</text>`);
}
@@ -393,11 +395,14 @@ export function renderGantt(model: ProcessModel, schedule: Schedule, opts: Gantt
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 diamond = (dx: number, size: number, late = false) => `<path d="M${dx} ${cy - size} L${dx + size} ${cy} L${dx} ${cy + size} L${dx - size} ${cy} Z" fill="${c.stroke}" stroke="${late ? "#d32f2f" : "#fff"}" stroke-width="${late ? 2.5 : 1}"/>`;
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(`<line x1="${x(m.day)}" y1="${cy}" x2="${x(m.deadline)}" y2="${cy}" stroke="#d32f2f" stroke-width="1" stroke-dasharray="3 3"/>`);
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);

View File

@@ -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("повторяющиеся шаги тянутся до конца проекта и не считаются предшественниками", () => {