Гант: контурный ромб зависимости от вехи и для свёрнутых групп
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -285,13 +285,14 @@ export function renderGantt(model: ProcessModel, schedule: Schedule, opts: Gantt
|
|||||||
const x2 = to.xs;
|
const x2 = to.xs;
|
||||||
const depRow = model.rows.find((r) => r.id === dep);
|
const depRow = model.rows.find((r) => r.id === dep);
|
||||||
const label = `${dep} -> ${row.id} ${depRow?.actionName ?? ""} -> ${row.actionName ?? ""}`;
|
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 gc = color(groupOf.get(dep)!.stage).stroke;
|
||||||
const gy = to.y;
|
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 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 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>`);
|
arrows.push(`<g>${tooltip([label])}${ghost}${gl}${line}</g>`);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -355,12 +355,13 @@ describe("Гант: группы, вехи, свёртывание, масшта
|
|||||||
expect(shut.match(/<svg[^>]*height="(\d+)"/)![1]!).not.toBe(open.match(/<svg[^>]*height="(\d+)"/)![1]!);
|
expect(shut.match(/<svg[^>]*height="(\d+)"/)![1]!).not.toBe(open.match(/<svg[^>]*height="(\d+)"/)![1]!);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("свёрнутая группа: зависимости между вехами сохраняются (стрелка от ромба вехи до зависимой строки)", () => {
|
it("зависимость от вехи рисуется контурным ромбом с подписью на строке зависимого шага (и при свёрнутой группе вехи)", () => {
|
||||||
const arrows = (svg: string) => svg.split('marker-end="url(#arr)"').length - 1;
|
const ghost = (svg: string) => svg.split('fill="#fff" stroke="').length - 1;
|
||||||
const shut = renderGantt(ms, sch, { collapsed: ["A"] });
|
const shut = renderGantt(ms, sch, { collapsed: ["A"] });
|
||||||
expect(arrows(shut)).toBeGreaterThanOrEqual(1); // X-9 (группа A свёрнута) -> S-3
|
expect(shut).toContain("X-9 Своя веха"); // подпись контурной вехи на строке S-3
|
||||||
expect(arrows(renderGantt(ms, sch, { collapsed: ["A", "B"] }))).toBe(0); // S-3 - не веха, к нему стрелки нет
|
expect(ghost(shut)).toBeGreaterThanOrEqual(1);
|
||||||
expect(arrows(renderGantt(ms, sch, {}))).toBeGreaterThan(arrows(shut));
|
expect(renderGantt(ms, sch, { collapsed: ["A", "B"] })).not.toContain("X-9 Своя веха"); // S-3 не веха, строки для ромба нет
|
||||||
|
expect(renderGantt(ms, sch, {})).toContain("X-9 Своя веха");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("стрелка зависимости имеет подсказку «от -> к» с названиями шагов", () => {
|
it("стрелка зависимости имеет подсказку «от -> к» с названиями шагов", () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user