This is a migrated thread and some comments may be shown as answers.

Customise GanttView Timeline Interval

7 Answers 152 Views
GanttView
This is a migrated thread and some comments may be shown as answers.
Marko
Top achievements
Rank 1
Marko asked on 15 May 2013, 10:16 AM
Hello,

Can we customize GanttView Timeline Interval? I want to have a custome date interval instead of predefined Day/Week/Month. I couldn't find any example or documentation related to intervals. A sample project will be really helpful.

Thanks


7 Answers, 1 is accepted

Sort by
0
Miroslav Nedyalkov
Telerik team
answered on 15 May 2013, 05:36 PM
Hi Marko,

The timeline intervals of the GanttView are highly customizable. I would suggest you to take a look at this example and to read this article.

Hope this helps.

All the best,
Miroslav Nedyalkov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Marko
Top achievements
Rank 1
answered on 16 May 2013, 09:32 AM
Hi Miroslav,

Thanks for your reply. I have read the two links but I didn't find any information creating custom Interval except using the predefined ones.

We follow fiscal year and our year starts in April instead of January. So week 01 will start from April. Also we have cycles. How can I customise the TimeLine to set up these intervals?

Thanks
0
Miroslav Nedyalkov
Telerik team
answered on 17 May 2013, 05:41 AM
Hello Marko,

If you need to set a custom interval, which cannot be found among the default ones you may define a custom one. You can take a look at this example to see how you can do this.

Regards,
Miroslav Nedyalkov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Marko
Top achievements
Rank 1
answered on 20 May 2013, 02:44 PM
Hello Miroslav,

Thanks for your example. I have used QuarterlyInterval class and its working fine with my example.
I have created CycleInterval class similar to QuarterlyInterval but whenever I run my solution my visual studio is crashing or complaining about out of memory exception during BindingDebugging. Can you please help me in identifying the problem?

public class CycleInterval : TickIntervalBase
    {
        public override long GetAverageLength()
        {
            return TimeSpan.TicksPerDay * (365 / 15);
        }

        protected override DateTime GetFirst(DateTime dateTime, DayOfWeek firstDayOfWeek)
        {           
            return new DateTime(dateTime.Year, dateTime.Month, 1);
        }
       
        protected override DateTime GetNext(DateTime dateTime)
        {            
            return GetCycle(dateTime).End;
         }

        protected override string FormatValue(Range<long> timeRange)
        {
            var Cycle = GetCycle(new DateTime(timeRange.Start));
            return string.Format("Cycle {0} - {1}", Cycle.Number, Cycle.Year);
        }

        private Cycle GetCycle(DateTime dateTime)
        {
            return Cycles.Where(r => dateTime >= r.Start || dateTime <= r.End).FirstOrDefault();
        }


        private System.Collections.Generic.List<Cycle> Cycles = new System.Collections.Generic.List<Cycle>(){
            new Cycle{Year = 2014, Start = new DateTime(2013,04,01), End = new DateTime(2013,04,20), Number=1},
            new Cycle{Year = 2014, Start = new DateTime(2013,04,21), End = new DateTime(2013,05,15), Number=2},
            new Cycle{Year = 2014, Start = new DateTime(2013,05,16), End = new DateTime(2013,06,22), Number=3},
            new Cycle{Year = 2014, Start = new DateTime(2013,06,23), End = new DateTime(2013,07,10), Number=4},
            new Cycle{Year = 2014, Start = new DateTime(2013,07,11), End = new DateTime(2013,08,18), Number=5},
            new Cycle{Year = 2014, Start = new DateTime(2013,08,19), End = new DateTime(2013,09,14), Number=6},
            new Cycle{Year = 2014, Start = new DateTime(2013,09,15), End = new DateTime(2013,10,10), Number=7},
            new Cycle{Year = 2014, Start = new DateTime(2013,10,11), End = new DateTime(2013,11,01), Number=8},
            new Cycle{Year = 2014, Start = new DateTime(2013,11,02), End = new DateTime(2013,12,07), Number=9},
            new Cycle{Year = 2014, Start = new DateTime(2013,12,08), End = new DateTime(2014,01,04), Number=10},
            new Cycle{Year = 2014, Start = new DateTime(2014,01,05), End = new DateTime(2014,01,28), Number=11},
            new Cycle{Year = 2014, Start = new DateTime(2014,01,28), End = new DateTime(2014,02,14), Number=12},
            new Cycle{Year = 2014, Start = new DateTime(2014,02,15), End = new DateTime(2014,03,01), Number=13},
            new Cycle{Year = 2014, Start = new DateTime(2014,03,02), End = new DateTime(2014,03,14), Number=14},
            new Cycle{Year = 2014, Start = new DateTime(2014,03,15), End = new DateTime(2014,03,31), Number=15}
        };
    }

    public class Cycle
    {
        public int Year { get; set; }
        public int Number { get; set; }
        public DateTime Start { get; set; }
        public DateTime End { get; set; }
    }



Thanks

0
Miroslav Nedyalkov
Telerik team
answered on 22 May 2013, 09:01 AM
Hi Marko,

From the code you sent I can see some performance optimizations should be done. Please notice that the methods of the Interval class are called a lot of times so their logic should be very fast. In your code I can see that both GetNext and FormatValue methods have linear complexity so this may cause performance problems.

I also tried your code and noticed that your implementation for the GetNext method returns "4/20/2013 12:00:00 AM" if it gets "4/20/2013 12:00:00 AM" as its parameter which causes an endless cycle. Most probably this is the cause of the exception you are observing.

Hope this helps.

Regards,
Miroslav Nedyalkov
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Marko
Top achievements
Rank 1
answered on 22 May 2013, 12:39 PM
Hi Miraslov,

Sorry, I didn't understand your reply. Will it be possible for you to provide an example?

Thanks
0
Marko
Top achievements
Rank 1
answered on 28 May 2013, 07:51 AM
Hello Miroslav,

I am stuck with memory exception. Can you please help me?

Thanks
Tags
GanttView
Asked by
Marko
Top achievements
Rank 1
Answers by
Miroslav Nedyalkov
Telerik team
Marko
Top achievements
Rank 1
Share this question
or