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:
parent
74e2811255
commit
d0171b179f
@ -13,6 +13,7 @@ const formatData = (
|
|||||||
hideChildren: boolean = false,
|
hideChildren: boolean = false,
|
||||||
) => {
|
) => {
|
||||||
data.forEach((item: any) => {
|
data.forEach((item: any) => {
|
||||||
|
const percent=item[fieldNames.progress] * 100;
|
||||||
if (item.children && item.children.length) {
|
if (item.children && item.children.length) {
|
||||||
tasks.push({
|
tasks.push({
|
||||||
start: new Date(item[fieldNames.start]),
|
start: new Date(item[fieldNames.start]),
|
||||||
@ -20,7 +21,7 @@ const formatData = (
|
|||||||
name: item[fieldNames.title],
|
name: item[fieldNames.title],
|
||||||
id: item.id + '',
|
id: item.id + '',
|
||||||
type: 'project',
|
type: 'project',
|
||||||
progress: item[fieldNames.progress] * 100 || 0,
|
progress: percent>100?100:percent || 0,
|
||||||
hideChildren: hideChildren,
|
hideChildren: hideChildren,
|
||||||
project: projectId,
|
project: projectId,
|
||||||
color: item.color,
|
color: item.color,
|
||||||
@ -33,7 +34,7 @@ const formatData = (
|
|||||||
name: item[fieldNames.title],
|
name: item[fieldNames.title],
|
||||||
id: item.id + '',
|
id: item.id + '',
|
||||||
type: fieldNames.end ? 'task' : 'milestone',
|
type: fieldNames.end ? 'task' : 'milestone',
|
||||||
progress: item[fieldNames.progress] * 100 || 0,
|
progress: percent>100?100:percent || 0,
|
||||||
project: projectId,
|
project: projectId,
|
||||||
color: item.color,
|
color: item.color,
|
||||||
});
|
});
|
||||||
|
@ -98,7 +98,7 @@ export const TaskItem: React.FC<TaskItemProps> = (props) => {
|
|||||||
{taskItem}
|
{taskItem}
|
||||||
<text
|
<text
|
||||||
x={isProjectBar ? task.x1 : getX()}
|
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)}
|
className={isProjectBar ? cx(projectLabel) : isTextInside ? cx(barLabel) : cx(barLabel) && cx(barLabelOutside)}
|
||||||
ref={textRef}
|
ref={textRef}
|
||||||
>
|
>
|
||||||
|
Loading…
Reference in New Issue
Block a user