Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TimeLine] Startline display #208

Merged
merged 2 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# [1.34.0](https://github.com/melfore/konva-timeline/compare/v1.33.2...v1.34.0) (2024-03-04)


### Features

* 🎸 [TimeLine]Reported start-end range ([df79cb0](https://github.com/melfore/konva-timeline/commit/df79cb0e5623b6abaf452a30def1180bf7a88da0)), closes [#202](https://github.com/melfore/konva-timeline/issues/202)
- 🎸 [TimeLine]Reported start-end range ([df79cb0](https://github.com/melfore/konva-timeline/commit/df79cb0e5623b6abaf452a30def1180bf7a88da0)), closes [#202](https://github.com/melfore/konva-timeline/issues/202)

## [1.33.2](https://github.com/melfore/konva-timeline/compare/v1.33.1...v1.33.2) (2024-02-29)

Expand Down
31 changes: 29 additions & 2 deletions src/KonvaTimeline/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,34 @@ export const NonPreciseRange: Story = {
resourceId: "1",
time: {
start: 1697632200000,
end: 1697639400000,
end: 1697739400000,
},
},
{
id: "4",
label: "Task4",
resourceId: "3",
time: {
start: 1697802666000,
end: 1697939066000,
},
},
{
id: "3",
label: "Task3",
resourceId: "1",
time: {
start: 1697925606000,
end: 1698091206000,
},
},
{
id: "2",
label: "Task2",
resourceId: "2",
time: {
start: 1697691606000,
end: 1697818006000,
},
},
],
Expand All @@ -157,7 +184,7 @@ export const CompletedPercentage: Story = {
resourceId: "2",
completedPercentage: 28,
time: {
start: 1698047900000,
start: 1698357600000,
end: 1698557900000,
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/tasks/utils/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const validateTasks = (
return false;
}

if (taskEnd < range.start || taskStart > range.end) {
if (taskStart < range.start || taskEnd > range.end) {
errors.push({ entity: "task", level: "warn", message: "Outside range", refId: taskId });
return false;
}
Expand Down
33 changes: 21 additions & 12 deletions src/timeline/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,13 @@ const Timeline: FC<TimelineProps> = () => {
[scrollbarSize, themeColor, timelineCommonStyle]
);

const startOffset = useMemo(() => {
if (externalRangeInMillis.start === +interval.start!) {
return false;
}
return true;
}, [externalRangeInMillis, interval]);

const xOfStart = useMemo(() => {
const timeStart = DateTime.fromMillis(externalRangeInMillis.start);
const startOffsetInUnit = timeStart.diff(interval.start!).as(resolution.unit);
Expand All @@ -184,7 +191,7 @@ const Timeline: FC<TimelineProps> = () => {
}, [fullTimelineWidth, xOfEnd]);

const marginOffset = useMemo(() => {
return columnWidth * 0.01;
return columnWidth * 0.015;
}, [columnWidth]);

const gridStageWrapperStyle = useMemo(
Expand Down Expand Up @@ -308,17 +315,19 @@ const Timeline: FC<TimelineProps> = () => {
onTaskEvent={setExistTask}
/>
)}
<Layer>
<KonvaLine
x={xOfStart}
y={rowHeight * 0.8}
points={[0, 0, 0, stageHeight]}
stroke="red"
strokeWidth={1}
dash={[8, 3]}
/>
<KonvaText fill="red" x={xOfStart - 13} y={rowHeight * 0.8 - 10} text="Start" width={columnWidth} />
</Layer>
{startOffset && (
<Layer>
<KonvaLine
x={xOfStart}
y={rowHeight * 0.8}
points={[0, 0, 0, stageHeight]}
stroke="red"
strokeWidth={1}
dash={[8, 3]}
/>
<KonvaText fill="red" x={xOfStart - 13} y={rowHeight * 0.8 - 20} text="Start" width={columnWidth} />
</Layer>
)}
{newTask && (
<Layer>
<Rect
Expand Down