日历日视图逻辑

发布于 2024-10-21 00:38:54 字数 206 浏览 0 评论 0原文

我不知道我的逻辑是否正确,但我正在尝试从头开始实现日历日视图。而要实现同一时间共享同一空间,对我来说有点棘手。

我有一个时间列表:

A. 1am - 2am

B. 1am - 2.30am

C. 1.30am - 3am

所以基本上AC的共同时间是凌晨2点,所以他们需要在同一个空间共享。那么这个逻辑如何实现呢?

I don't know if my logic is right, but I'm trying to implement the calendar day view from scratch. And for implementing the sharing of same space with the same time, its kinda tricky for me.

I have a list of time:

A. 1am - 2am

B. 1am - 2.30am

C. 1.30am - 3am

So basically A-C have a common time of 2am, so they need to share in the same space. So how can do the logic of that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

Bonjour°[大白 2024-10-28 00:38:54

这并不难。您应该计算重叠的任务,分配给列并绘制它。在您的示例中,我们有 3 个重叠的任务。这意味着您必须为代表每个任务的框创建 3 列。

A. 凌晨 1 点 - 凌晨 2 点
B. 凌晨 1 点 - 凌晨 2.30
C. 4.30am - 3am

此示例创建 2 列,因为我们只有 2 个重叠任务。

现在,当您循环任务进行计数重叠时,您可以将每个任务分配给指定的列。当需要新列时 - 创建它。

下一个循环仅在指定的列中绘制此框。正如您所看到的,我们必须循环:一个用于计算重叠和分配列,第二个用于绘图。

It's not hard to this. You should count overlapped tasks, assign to columns ad draw it. In your example we have 3 overlapped task. It means you have to create 3 columns for boxes representing each task.

A. 1am - 2am
B. 1am - 2.30am
C. 4.30am - 3am

This example creates 2 columns because we have only 2 overlapped tasks.

Now, when you loop tasks for count overlappings you can assign each task to specified column. When new column is required - create it.

Next loop is only drawing this boxes in assigned columns. As you can see, we have to loops: one for count overlapping and assigning columns and second for drawing.

苏大泽ㄣ 2024-10-28 00:38:54

这是我在网上搜索的内容

要检查重叠:

Let CondA Mean DateRange A Completely After DateRange B (True if StartA > EndB)
让 CondB 表示 DateRange A 完全早于 DateRange B(如果 EndA < StartB,则为 True)

则如果 A 和 B 都不为 true,则存在重叠(如果一个范围既不完全在另一个范围之后,也不完全在另一个范围之前,则它们必须重叠)

现在我认为德摩根定律是这样的:

Not (A Or B) <=> Not A And Not B

这意味着 (StartA <= EndB) 且 (EndA >= StartB)

注意:这包括边缘完全重叠的情况。如果您希望排除它,请将 >= 运算符更改为 >,将 <= 更改为 <


因此,根据重叠值,我可以确定应该添加多少列。

Heres what I've got searching tru the net

To check the overlap:

Let CondA Mean DateRange A Completely After DateRange B (True if StartA > EndB)
Let CondB Mean DateRange A Completely Before DateRange B (True if EndA < StartB)

Then Overlap exists if Neither A Nor B is true ( If one range is neither completely after the other, nor completely before the other, then they must overlap)

Now deMorgan's law, I think it is, says that

Not (A Or B) <=> Not A And Not B

Which means (StartA <= EndB) And (EndA >= StartB)

NOTE: This includes conditions where the edges overlap exactly. If you wish to exclude that, change the >= operators to >, and <= to <


So, base on the overlap value, I can determine how many column should I add.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文