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();
|
useGanttChart();
|
||||||
|
|
||||||
// rendering the block structure
|
// rendering the block structure
|
||||||
const renderBlockStructure = (view: any, blocks: IGanttBlock[] | null) =>
|
const renderBlockStructure = (view: ChartDataType, blocks: IGanttBlock[] | null) =>
|
||||||
blocks
|
blocks
|
||||||
? blocks.map((block: any) => ({
|
? blocks.map((block: IGanttBlock) => ({
|
||||||
...block,
|
...block,
|
||||||
position: getMonthChartItemPositionWidthInMonth(view, block),
|
position: getMonthChartItemPositionWidthInMonth(view, block),
|
||||||
}))
|
}))
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
// types
|
// types
|
||||||
|
import { findTotalDaysInRange } from "helpers/date-time.helper";
|
||||||
import { weeks, months } from "../data";
|
import { weeks, months } from "../data";
|
||||||
import { ChartDataType, IGanttBlock } from "../types";
|
import { ChartDataType, IGanttBlock } from "../types";
|
||||||
// data
|
// data
|
||||||
@ -167,15 +168,16 @@ export const getMonthChartItemPositionWidthInMonth = (chartData: ChartDataType,
|
|||||||
const { startDate } = chartData.data;
|
const { startDate } = chartData.data;
|
||||||
const { start_date: itemStartDate, target_date: itemTargetDate } = itemData;
|
const { start_date: itemStartDate, target_date: itemTargetDate } = itemData;
|
||||||
|
|
||||||
if (!itemStartDate || !itemTargetDate) return null;
|
if (!itemStartDate || !itemTargetDate) return;
|
||||||
|
|
||||||
startDate.setHours(0, 0, 0, 0);
|
startDate.setHours(0, 0, 0, 0);
|
||||||
itemStartDate.setHours(0, 0, 0, 0);
|
itemStartDate.setHours(0, 0, 0, 0);
|
||||||
itemTargetDate.setHours(0, 0, 0, 0);
|
itemTargetDate.setHours(0, 0, 0, 0);
|
||||||
|
|
||||||
// position code starts
|
const positionDaysDifference = findTotalDaysInRange(startDate, itemStartDate, false);
|
||||||
const positionTimeDifference: number = startDate.getTime() - itemStartDate.getTime();
|
|
||||||
const positionDaysDifference: number = Math.abs(Math.floor(positionTimeDifference / (1000 * 60 * 60 * 24)));
|
if (!positionDaysDifference) return;
|
||||||
|
|
||||||
scrollPosition = positionDaysDifference * chartData.data.width;
|
scrollPosition = positionDaysDifference * chartData.data.width;
|
||||||
|
|
||||||
let diffMonths = (itemStartDate.getFullYear() - startDate.getFullYear()) * 12;
|
let diffMonths = (itemStartDate.getFullYear() - startDate.getFullYear()) * 12;
|
||||||
|
Loading…
Reference in New Issue
Block a user