mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-14 06:43:25 +08:00
Merge pull request #4074 from l2fprod/feature/user_journey_expand_section
💄 section width now covers all tasks
This commit is contained in:
commit
f62c4831ad
@ -224,6 +224,17 @@ export const drawTasks = function (diagram, tasks, verticalPos) {
|
||||
num = sectionNumber % fills.length;
|
||||
colour = textColours[sectionNumber % textColours.length];
|
||||
|
||||
// count how many consecutive tasks have the same section
|
||||
let taskInSectionCount = 0;
|
||||
const currentSection = task.section;
|
||||
for (let taskIndex = i; taskIndex < tasks.length; taskIndex++) {
|
||||
if (tasks[taskIndex].section == currentSection) {
|
||||
taskInSectionCount = taskInSectionCount + 1;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const section = {
|
||||
x: i * conf.taskMargin + i * conf.width + LEFT_MARGIN,
|
||||
y: 50,
|
||||
@ -231,6 +242,7 @@ export const drawTasks = function (diagram, tasks, verticalPos) {
|
||||
fill,
|
||||
num,
|
||||
colour,
|
||||
taskCount: taskInSectionCount,
|
||||
};
|
||||
|
||||
svgDraw.drawSection(diagram, section, conf);
|
||||
|
@ -196,7 +196,10 @@ export const drawSection = function (elem, section, conf) {
|
||||
rect.x = section.x;
|
||||
rect.y = section.y;
|
||||
rect.fill = section.fill;
|
||||
rect.width = conf.width;
|
||||
// section width covers all nested tasks
|
||||
rect.width =
|
||||
conf.width * section.taskCount + // width of the tasks
|
||||
conf.diagramMarginX * (section.taskCount - 1); // width of space between tasks
|
||||
rect.height = conf.height;
|
||||
rect.class = 'journey-section section-type-' + section.num;
|
||||
rect.rx = 3;
|
||||
|
Loading…
x
Reference in New Issue
Block a user