fix(gantt): improve task bar text (#1696)

* fix:  progress value is too large, resulting in incorrect calculation of bar width

* style: style improve

* style: style improve
This commit is contained in:
katherinehhh 2023-04-13 15:00:41 +08:00 committed by GitHub
parent 74e2811255
commit d0171b179f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 4 deletions

View File

@ -13,6 +13,7 @@ const formatData = (
hideChildren: boolean = false,
) => {
data.forEach((item: any) => {
const percent=item[fieldNames.progress] * 100;
if (item.children && item.children.length) {
tasks.push({
start: new Date(item[fieldNames.start]),
@ -20,7 +21,7 @@ const formatData = (
name: item[fieldNames.title],
id: item.id + '',
type: 'project',
progress: item[fieldNames.progress] * 100 || 0,
progress: percent>100?100:percent || 0,
hideChildren: hideChildren,
project: projectId,
color: item.color,
@ -33,7 +34,7 @@ const formatData = (
name: item[fieldNames.title],
id: item.id + '',
type: fieldNames.end ? 'task' : 'milestone',
progress: item[fieldNames.progress] * 100 || 0,
progress: percent>100?100:percent || 0,
project: projectId,
color: item.color,
});

View File

@ -98,7 +98,7 @@ export const TaskItem: React.FC<TaskItemProps> = (props) => {
{taskItem}
<text
x={isProjectBar ? task.x1 : getX()}
y={isProjectBar ? task.y - 8 : task.y + taskHeight * 0.5}
y={isProjectBar ? task.y - 8 : isTextInside ? task.y + taskHeight * 0.5 : task.y + taskHeight * 0.65}
className={isProjectBar ? cx(projectLabel) : isTextInside ? cx(barLabel) : cx(barLabel) && cx(barLabelOutside)}
ref={textRef}
>