mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
[WEB-1235] chore: module and cycle sidebar graph improvement (#4650)
* chore: module and cycle sidebar graph improvement * chore: code refactor
This commit is contained in:
parent
9143e5abc8
commit
fc4ba5a170
@ -56,21 +56,18 @@ const ProgressChart: React.FC<Props> = ({ distribution, startDate, endDate, tota
|
|||||||
dates = eachDayOfInterval({ start, end });
|
dates = eachDayOfInterval({ start, end });
|
||||||
}
|
}
|
||||||
|
|
||||||
const maxDates = 4;
|
if (dates.length === 0) return [];
|
||||||
const totalDates = dates.length;
|
|
||||||
|
|
||||||
if (totalDates <= maxDates) return dates.map((d) => renderFormattedDateWithoutYear(d));
|
const formattedDates = dates.map((d) => renderFormattedDateWithoutYear(d));
|
||||||
else {
|
const firstDate = formattedDates[0];
|
||||||
const interval = Math.ceil(totalDates / maxDates);
|
const lastDate = formattedDates[formattedDates.length - 1];
|
||||||
const limitedDates = [];
|
|
||||||
|
|
||||||
for (let i = 0; i < totalDates; i += interval) limitedDates.push(renderFormattedDateWithoutYear(dates[i]));
|
if (formattedDates.length <= 2) return [firstDate, lastDate];
|
||||||
|
|
||||||
if (!limitedDates.includes(renderFormattedDateWithoutYear(dates[totalDates - 1])))
|
const middleDateIndex = Math.floor(formattedDates.length / 2);
|
||||||
limitedDates.push(renderFormattedDateWithoutYear(dates[totalDates - 1]));
|
const middleDate = formattedDates[middleDateIndex];
|
||||||
|
|
||||||
return limitedDates;
|
return [firstDate, middleDate, lastDate];
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
Reference in New Issue
Block a user