Гант: контурный ромб зависимости от вехи и для свёрнутых групп
All checks were successful
ci / test (push) Successful in 24s
ci / deploy (push) Successful in 1m34s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-17 17:37:44 +03:00
parent 3428cac809
commit 01bbe9ee66
2 changed files with 9 additions and 7 deletions

View File

@@ -285,13 +285,14 @@ export function renderGantt(model: ProcessModel, schedule: Schedule, opts: Gantt
const x2 = to.xs;
const depRow = model.rows.find((r) => r.id === dep);
const label = `${dep} -> ${row.id} ${depRow?.actionName ?? ""} -> ${row.actionName ?? ""}`;
if (depRow?.isMilestone && !g.collapsed && !groupOf.get(dep)?.collapsed) {
if (depRow?.isMilestone) {
// зависимость от вехи: вместо вертикали через весь план - контурный ромб вехи на строке зависимого шага, стрелка идёт от него
const gc = color(groupOf.get(dep)!.stage).stroke;
const gy = to.y;
const ghost = `<path d="M${x1} ${gy - 7} L${x1 + 7} ${gy} L${x1} ${gy + 7} L${x1 - 7} ${gy} Z" fill="#fff" stroke="${gc}" stroke-width="1.6"/>`;
const gl = `<text x="${x1 - 11}" y="${gy + 3}" text-anchor="end" font-size="9" fill="${gc}">${esc(truncate(`${dep} ${depRow.actionName ?? ""}`, 40))}</text>`;
const line = x2 > x1 + 7 ? `<path d="M${x1 + 7} ${gy} H${x2}" fill="none" stroke="#444" stroke-width="1.1" marker-end="url(#arr)"/><path d="M${x1 + 7} ${gy} H${x2}" fill="none" stroke="transparent" stroke-width="8" pointer-events="stroke"/>` : "";
const lp = x2 > x1 + 7 ? `M${x1 + 7} ${gy} H${x2}` : x2 < x1 - 7 ? `M${x1 - 7} ${gy} H${x2}` : ""; // назад - если шаг начинается раньше вехи (противоречие)
const line = lp ? `<path d="${lp}" fill="none" stroke="#444" stroke-width="1.1" marker-end="url(#arr)"/><path d="${lp}" fill="none" stroke="transparent" stroke-width="8" pointer-events="stroke"/>` : "";
arrows.push(`<g>${tooltip([label])}${ghost}${gl}${line}</g>`);
continue;
}

View File

@@ -355,12 +355,13 @@ describe("Гант: группы, вехи, свёртывание, масшта
expect(shut.match(/<svg[^>]*height="(\d+)"/)![1]!).not.toBe(open.match(/<svg[^>]*height="(\d+)"/)![1]!);
});
it("свёрнутая группа: зависимости между вехами сохраняются (стрелка от ромба вехи до зависимой строки)", () => {
const arrows = (svg: string) => svg.split('marker-end="url(#arr)"').length - 1;
it("зависимость от вехи рисуется контурным ромбом с подписью на строке зависимого шага (и при свёрнутой группе вехи)", () => {
const ghost = (svg: string) => svg.split('fill="#fff" stroke="').length - 1;
const shut = renderGantt(ms, sch, { collapsed: ["A"] });
expect(arrows(shut)).toBeGreaterThanOrEqual(1); // X-9 (группа A свёрнута) -> S-3
expect(arrows(renderGantt(ms, sch, { collapsed: ["A", "B"] }))).toBe(0); // S-3 - не веха, к нему стрелки нет
expect(arrows(renderGantt(ms, sch, {}))).toBeGreaterThan(arrows(shut));
expect(shut).toContain("X-9 Своя веха"); // подпись контурной вехи на строке S-3
expect(ghost(shut)).toBeGreaterThanOrEqual(1);
expect(renderGantt(ms, sch, { collapsed: ["A", "B"] })).not.toContain("X-9 Своя веха"); // S-3 не веха, строки для ромба нет
expect(renderGantt(ms, sch, {})).toContain("X-9 Своя веха");
});
it("стрелка зависимости имеет подсказку «от -> к» с названиями шагов", () => {