mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
fix gantt chart view position fix
This commit is contained in:
parent
80a4a5dd62
commit
c06ef5c7c9
@ -64,9 +64,9 @@ export const ChartViewRoot: FC<ChartViewRootProps> = observer((props) => {
|
||||
useGanttChart();
|
||||
|
||||
// rendering the block structure
|
||||
const renderBlockStructure = (view: any, blocks: IGanttBlock[] | null) =>
|
||||
const renderBlockStructure = (view: ChartDataType, blocks: IGanttBlock[] | null) =>
|
||||
blocks
|
||||
? blocks.map((block: any) => ({
|
||||
? blocks.map((block: IGanttBlock) => ({
|
||||
...block,
|
||||
position: getMonthChartItemPositionWidthInMonth(view, block),
|
||||
}))
|
||||
|
@ -1,4 +1,5 @@
|
||||
// types
|
||||
import { findTotalDaysInRange } from "helpers/date-time.helper";
|
||||
import { weeks, months } from "../data";
|
||||
import { ChartDataType, IGanttBlock } from "../types";
|
||||
// data
|
||||
@ -167,15 +168,16 @@ export const getMonthChartItemPositionWidthInMonth = (chartData: ChartDataType,
|
||||
const { startDate } = chartData.data;
|
||||
const { start_date: itemStartDate, target_date: itemTargetDate } = itemData;
|
||||
|
||||
if (!itemStartDate || !itemTargetDate) return null;
|
||||
if (!itemStartDate || !itemTargetDate) return;
|
||||
|
||||
startDate.setHours(0, 0, 0, 0);
|
||||
itemStartDate.setHours(0, 0, 0, 0);
|
||||
itemTargetDate.setHours(0, 0, 0, 0);
|
||||
|
||||
// position code starts
|
||||
const positionTimeDifference: number = startDate.getTime() - itemStartDate.getTime();
|
||||
const positionDaysDifference: number = Math.abs(Math.floor(positionTimeDifference / (1000 * 60 * 60 * 24)));
|
||||
const positionDaysDifference = findTotalDaysInRange(startDate, itemStartDate, false);
|
||||
|
||||
if (!positionDaysDifference) return;
|
||||
|
||||
scrollPosition = positionDaysDifference * chartData.data.width;
|
||||
|
||||
let diffMonths = (itemStartDate.getFullYear() - startDate.getFullYear()) * 12;
|
||||
|
Loading…
Reference in New Issue
Block a user