Zoom changed error

Hi,

On load data and zoom change (setting zoomfactor and  from ViewModel) of GanttControl in some cases I have a same problem as described in https://www.syncfusion.com/forums/164482/zoom-changed

How can I detect, when this situation happens and how can I find the correct minimum value of zoom where this will not present itself?

Thank you for you support.

Kind regards,

Nicola Dellea


3 Replies

VM Vidyalakshmi Mani Syncfusion Team April 5, 2024 09:19 AM UTC

Hi Nicola,


Based on the information provided, we have conducted a test by binding a slider to the GanttControl and zooming the Gantt using the slider. In our test, the control behaved as expected without any issues.


We have attached the tested sample and an output video for your reference. Please review the sample and video to verify if it aligns with your scenario.


To assist you further, could you please provide additional details?

1. Have you used the TaskDetails class for binding or a custom model class?

2. Have you used the "UseAutoUpdateHierarchy" property as true or false?


If the issue persists in your environment, please modify our sample to reproduce the problem or provide us with your sample where the issue occurs. This will help us investigate and address the issue more effectively.


Regards,

Vidyalakshmi M.



Attachment: SampleAndOutputVideo_a84796f.zip


ND Nicola Dellea April 5, 2024 01:25 PM UTC

Dear  Vidyalakshmi,


I use custom model class (TaskGantt) that implements IGanttTask interface, Children are of the same type (TaskGantt), stored in a ObservableCollection,   UseAutoUpdateHierarchy is set to true.
mapping in xaml is:

<Sync:TaskAttributeMapping TaskIdMapping="TaskId"

                                    TaskNameMapping="TaskName"

                                    DurationMapping="Duration"

                                    StartDateMapping="StartDate"

                                    FinishDateMapping="FinishDate"

                                    ChildMapping="Children"

                                    ProgressMapping="Progress"

                                          MileStoneMapping="IsMileStone">

In a solution provided by you the same effect could be achieved by zooming to a minimum value (slider completely to the left).

Kind regards,

Nicola

Image_1194_1712322905249



VM Vidyalakshmi Mani Syncfusion Team April 8, 2024 12:59 PM UTC

Hi Nicola,


Thank you for sharing this information. To address the issue you're experiencing, we suggest adjusting the properties "BaseCellMinLength" and "BaseCellMaxLength" as outlined in this UG document: Adding-built-in-zooming-to-an-application. If this does not resolve the issue, you can explore using the Custom zooming feature, which is explained in detail in our documentation: Custom-Zooming


In the CustomZooming approach, you can change the schedule row information and cell size dynamically by handling the Zoom changed event handler. Please note that you cannot use both built-in zooming and custom zooming together. Here’s a code snippet for your reference:


        /// Event Handler in code behind

        /// <summary>

        /// Handles the ZoomChanged event of the Gantt control.

        /// </summary>

        /// <param name="sender">The source of the event.</param>

        /// <param name="args">The <see cref="Syncfusion.Windows.Controls.Gantt.ZoomChangedEventArgs"/> instance containing the event data.</param>

        private void Gantt_ZoomChanged(object sender, ZoomChangedEventArgs args)

        {

            if (args.ZoomFactor == 100)

            {

                args.ScheduleHeaderInfo = new List<GanttScheduleRowInfo>

                {

                    new GanttScheduleRowInfo{ CellsPerUnit=1, TimeUnit= TimeUnit.Weeks },

                    new GanttScheduleRowInfo{CellsPerUnit=1,TimeUnit = TimeUnit.Days, PixelsPerUnit= 20}

                };

            }

            else if (args.ZoomFactor == 200)

            {

                args.ScheduleHeaderInfo = new List<GanttScheduleRowInfo>

                {

                    new GanttScheduleRowInfo{ CellsPerUnit=1, TimeUnit= TimeUnit.Days, CellTextFormat ="ddd d MMM" },

                    new GanttScheduleRowInfo{CellsPerUnit=12,TimeUnit = TimeUnit.Hours, PixelsPerUnit= 4, CellTextFormat="hh tt"}

                };

            }

            else if (args.ZoomFactor == 300)

            {

                args.ScheduleHeaderInfo = new List<GanttScheduleRowInfo>

                {

                    new GanttScheduleRowInfo{ CellsPerUnit=1, TimeUnit= TimeUnit.Days, CellTextFormat ="ddd d MMM"  },

                    new GanttScheduleRowInfo{CellsPerUnit=6,TimeUnit = TimeUnit.Hours, PixelsPerUnit= 8, CellTextFormat="hh tt"}

                };

            }

            else if (args.ZoomFactor == 400)

            {

                args.ScheduleHeaderInfo = new List<GanttScheduleRowInfo>

                {

                    new GanttScheduleRowInfo{ CellsPerUnit=1, TimeUnit= TimeUnit.Days, CellTextFormat ="ddd d MMM"  },

                    new GanttScheduleRowInfo{CellsPerUnit=1,TimeUnit = TimeUnit.Hours, PixelsPerUnit= 69, CellTextFormat="hh tt"}

                };

            }

            else if (args.ZoomFactor == 600)

            {

                args.ScheduleHeaderInfo = new List<GanttScheduleRowInfo>

                {

                    new GanttScheduleRowInfo{ CellsPerUnit=1, TimeUnit= TimeUnit.Hours, CellTextFormat="hh:mm tt" },

                    new GanttScheduleRowInfo{CellsPerUnit=15,TimeUnit = TimeUnit.Minutes, PixelsPerUnit= 2}

                };

            }

            else if (args.ZoomFactor == 800)

            {

                args.ScheduleHeaderInfo = new List<GanttScheduleRowInfo>

                {

                    new GanttScheduleRowInfo{ CellsPerUnit=1, TimeUnit= TimeUnit.Hours, CellTextFormat="hh:mm tt" },

                    new GanttScheduleRowInfo{CellsPerUnit=5,TimeUnit = TimeUnit.Minutes, PixelsPerUnit= 4}

                };

            }

            else if (args.ZoomFactor == 1000)

            {

                args.ScheduleHeaderInfo = new List<GanttScheduleRowInfo>

                {

                    new GanttScheduleRowInfo{ CellsPerUnit=1, TimeUnit= TimeUnit.Hours, CellTextFormat="hh:mm tt" },

                    new GanttScheduleRowInfo{CellsPerUnit=1,TimeUnit = TimeUnit.Minutes, PixelsPerUnit= 20}

                };

            }

 

            args.Handled = true;

        }

 



We have also prepared a simple sample demonstrating CustomZooming, which is attached for your reference. Please try implementing either of these solutions and let us know if the issue is resolved. We're here to assist you.


Regards,

Vidyalakshmi M.



Attachment: WPFGanttControl_2c97bdb8.zip

Loader.
Up arrow icon