Гант: линии от контурных вех - тёмно-серые, почти фоновый слой под подписями, стрелка на конце; при нескольких вехах на строке подпись - только id
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -273,6 +273,8 @@ export function renderGantt(model: ProcessModel, schedule: Schedule, opts: Gantt
|
||||
};
|
||||
if (opts.deps !== false) {
|
||||
const arrows: string[] = [];
|
||||
const ghostLines: string[] = [];
|
||||
const ghostMarks: string[] = [];
|
||||
const redundant = redundantDependencies(model.rows);
|
||||
for (const g of groups) {
|
||||
for (const { row } of g.rows) {
|
||||
@@ -290,10 +292,12 @@ export function renderGantt(model: ProcessModel, schedule: Schedule, opts: Gantt
|
||||
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 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>`);
|
||||
const several = row.dependsOn.filter((d) => model.rows.find((r) => r.id === d)?.isMilestone && !redundant.has(`${d}>${row.id}`)).length > 1;
|
||||
const gl = `<text x="${x1 - 11}" y="${gy + 3}" text-anchor="end" font-size="9" fill="${gc}">${esc(several ? dep : truncate(`${dep} ${depRow.actionName ?? ""}`, 40))}</text>`; // несколько вех на одной строке: только id, чтобы подписи не налезали
|
||||
const x2e = row.isMilestone ? x2 - 10 : x2; // у вехи-цели стрелка заканчивается перед ромбом, иначе остриё закрыто ромбом
|
||||
const lp = x2e > x1 + 7 ? `M${x1 + 7} ${gy} H${x2e}` : x2e < x1 - 7 ? `M${x1 - 7} ${gy} H${x2e}` : ""; // назад - если шаг начинается раньше вехи (противоречие)
|
||||
if (lp) ghostLines.push(`<g>${tooltip([label])}<path d="${lp}" fill="none" stroke="#666" stroke-width="1.1" marker-end="url(#arrg)"/><path d="${lp}" fill="none" stroke="transparent" stroke-width="8" pointer-events="stroke"/></g>`);
|
||||
ghostMarks.push(`<g>${tooltip([label])}${ghost}${gl}</g>`);
|
||||
continue;
|
||||
}
|
||||
const d = x2 >= x1 ? `M${x1} ${from.y} V${to.y} H${x2}` : `M${x1} ${from.y} H${x1 + 6} V${to.y} H${x2}`;
|
||||
@@ -301,7 +305,9 @@ export function renderGantt(model: ProcessModel, schedule: Schedule, opts: Gantt
|
||||
}
|
||||
}
|
||||
}
|
||||
out.push(`<g opacity="0.75">${arrows.join("")}</g>`);
|
||||
// слои снизу вверх: линии от контурных вех (почти фон), обычные зависимости, контурные ромбы с подписями (поверх линий)
|
||||
out.push(`<g opacity="0.75">${ghostLines.join("")}${arrows.join("")}</g>`);
|
||||
out.push(`<g>${ghostMarks.join("")}</g>`);
|
||||
}
|
||||
|
||||
// Строки раскрытых групп
|
||||
@@ -439,6 +445,6 @@ export function renderGantt(model: ProcessModel, schedule: Schedule, opts: Gantt
|
||||
`<line x1="1085" y1="${ly - 3}" x2="1085" y2="${ly + 11}" stroke="#d32f2f" stroke-width="3"/><text x="1094" y="${ly + 7}">крайний срок</text></g>`,
|
||||
);
|
||||
|
||||
const defs = `<marker id="arr" viewBox="0 0 6 6" refX="5" refY="3" markerWidth="6" markerHeight="6" orient="auto"><path d="M0 0 L6 3 L0 6 z" fill="#444"/></marker>`;
|
||||
const defs = `<marker id="arr" viewBox="0 0 6 6" refX="5" refY="3" markerWidth="6" markerHeight="6" orient="auto"><path d="M0 0 L6 3 L0 6 z" fill="#444"/></marker><marker id="arrg" viewBox="0 0 6 6" refX="5" refY="3" markerWidth="6" markerHeight="6" orient="auto"><path d="M0 0 L6 3 L0 6 z" fill="#666"/></marker>`;
|
||||
return svgDoc(width, height, defs, out.join("\n"), `data-left="${GANTT_LEFT}" data-px="${px}"`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user