search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Display Back to Back Events in Scheduler

Asked by Patrick Burrows
7 years ago.

I have single events that are comprised of three parts. I need to display each of the three parts on the schedule. The parts are:
1. a 10 - 20 minute warm up time,
2. a 3 - 5 hour working time,
3. and then a 10 - 20 minute cool down time.

The way I am displaying this is by using 3 events that all start back to back. So, for my test data I will create 3 events with the following times:
1. 7:59 - 8:14
2. 8:00 - 12:00
3. 12:01 - 12:16

This isn't ideal, because it is causing the Scheduler to display funky depending on how I have the various display options configured.

If you look at the attached file "daypilot-image1" you can see that I am able to make it all display evenly across a row. However, this is only working because I have hardcoded my warmup and cooldown times to be 15 minutes and set the setting:
CellDuration = 15,

If I vary from this duration, I get something that looks like Image 3 (which I will explain below)

If you look at "daypilot-image2" you can see where I have got rid of the CellDuration setting and have instead set:
UseEventBoxes = UseEventBoxesType.Never,

As you can see in that image, though, the events have gaps between the warm up, work, and cool down sections. These gaps occur even when I set the distance between the End of one and the Start of the next to be one second. If I set the End of one and the Start of the next to be the same time, you get what is in Image 3.

Image 3 is what happens if I have no CellDuration set and UseEventBoxes set to anything but Never, or if I have the schedules End and Start at the same time.

What is the best way to display what I am trying to accomplish?

Ideally, I'd like to have these three sections actually be one event. But if that is not possible, I'd like to be able to display back-to-back events with no gap between them, and no overlap issues where some of the events move to the next row.

Thanks for the help.

Answer posted by Dan Letecky [DayPilot]
7 years ago.

1. The combination of UseEventBoxes=Never and setting the end time to the start time of the next event should work. If you take Image 3 and set UseEventBoxes=Never, does it work as expected?

2. You should be able to add custom elements to the events using active areas. This would allow you to make it a single event. The only problem is that you need to define the active area width in pixels. You would have to manually calculate the pixels from the date.

Example for warm up:

    protected void DayPilotScheduler1_BeforeEventRender(object sender, BeforeEventRenderEventArgs e)
    {
        TimeSpan warmup = TimeSpan.FromMinutes(30);
        int warmupWidth = (int) (warmup.TotalMinutes/DayPilotScheduler1.CellDuration*DayPilotScheduler1.CellWidth);
        e.Areas.Add(new Area().Left(0).Top(0).Bottom(0).Width(warmupWidth).CssClass("warmup").Html("W").Visibility(AreaVisibility.Visible));
    }

Define .warmup as needed, e.g.

.warmup {
  background-color: red;
  opacity: 0.5;
}

Comment posted by Dan Letecky [DayPilot]
7 years ago.

For the MVC version it is almost the same:

protected override void OnBeforeEventRender(BeforeEventRenderArgs e)
{
        TimeSpan warmup = TimeSpan.FromMinutes(30);
        int warmupWidth = (int) (warmup.TotalMinutes/DayPilotScheduler1.CellDuration*DayPilotScheduler1.CellWidth);
        e.Areas.Add(new Area().Left(0).Top(0).Bottom(0).Width(warmupWidth).CssClass("warmup").Html("W").Visibility(AreaVisibility.Visible));
}
Comment posted by Patrick Burrows
7 years ago.

I tried technique 2 (cause, that is what I wanted to start) and that is working well. Positioning the right-hand area is a bit more of a calculation, but that is working too.

Thanks for the help.

Comment posted by Dan Letecky [DayPilot]
7 years ago.

The right-hand area shouldn't be any more difficult than the first one. Just use Right() instead of Left():

e.Areas.Add(new Area().Right(0).Top(0).Bottom(0).Width(cooldownWidth).CssClass("cooldown").Html("W").Visibility(AreaVisibility.Visible));
Comment posted by Patrick Burrows
7 years ago.

Ha, yeah. I noticed there was a "right" property after I sent that. My bad.

This question is more than 3 months old and has been closed. Please create a new question if you have anything to add.