Zoom changed

Hi,

in the attached file yuo will find  a video regarding a strange behavior of zoom, see the initial value otherwisw is the same the layout i no teh same.

Best regard
Gian Piero Truccolo

Attachment: ZoomValueChangedFromBegin_970216fa.zip

14 Replies 1 reply marked as answer

SS Sridevi Sivakumar Syncfusion Team April 14, 2021 10:57 AM UTC

Hi Gian Piero Truccolo, 

Greetings from Syncfusion. 

We have checked your reported query and we would like to inform you that if the Gantt schedule width is less than the view port width, the Gantt Schedule will initially be extended to suit the view port size.

The Gantt schedule will be made to its actual size and zoomed based on the ZoomFactor once we begin zooming. 

Let us know if you need any further assistance.

Regards,
Sridevi S. 


Marked as answer

GI Gian April 14, 2021 01:09 PM UTC

Hi,

ok i undestand so is there a way to reset this behavior in order to return to the intial state after using zoom?

And is there also a way to reset Gantt control?
This second query is for other situation that we would like to manage.

Best regards
Gian Piero Truccolo


SS Sridevi Sivakumar Syncfusion Team April 15, 2021 03:27 PM UTC

Hi Gian Piero Truccolo,

Query: Reset this behavior in order to return to the initial state after using zoom

We have checked the reported query, we suspect you are expecting Gantt Schedule have to stretch, when you zoom the Gantt. But we would like to inform you that, we don’t have support to achieve this requirement in GanttControl.

Query:  Is there also a way to reset Gantt control 
We have analyzed your requirement and you can achieve your requirement by exporting the Gantt state and import the gantt when you expect to reset. Please find the below section to how to export and import the gantt.

For more infoemation about gantt import and export
https://help.syncfusion.com/wpf/gantt/import-and-export-support

Regards, 
Sridevi S.  
 



GI Gian April 16, 2021 06:53 AM UTC

Hi,

regarding the comment of the first i answer "not at all".

In the video attached you can see that when i change the zoom from 160 to 170 the chart width decreases,, instead i expect it increases.

Best Regards
Gian Piero Truccolo

Attachment: ZoomValueChangedFromBegin2_97a64068.zip


SS Sridevi Sivakumar Syncfusion Team April 19, 2021 12:29 PM UTC

Hi Natalia Alegria,

Thanks for your response.

We have analyzed the provided video and we would like to inform that, this is the default behavior of GanttControl. Ie., In zoom level 160, the Schedule is loaded with days (in bottom schedule) and its default range padding is 14 (days). So, the schedule started with
April 2,2021 and ended with May 4,2021. After increased zoom level to 170, one more schedule row has been added at the bottom with Hours time unit for readability and its default range padding is 5 (hours). So, now the schedule gets changed and started from April 14,2021 and ended with April 18,2021 (which is less than previously rendered date range), then only the schedule with get decreased.

Regards,
Sridevi S.  
 



GI Gian April 19, 2021 01:37 PM UTC

Hi,

 now i undestand how it works and its behavior.

In our case we want to set the schedule in another window, and only with that the schedule can change, an then use the zoom only to increase the width of the  existing the current schedule and keeping the existing behavior.

How can we achieev this?

Best regards
Gian Piero Truccolo


SS Sridevi Sivakumar Syncfusion Team April 20, 2021 01:50 PM UTC

Hi Gian Piero Truccolo,

Currently, we are validating the reported query and we will update the details on April 22, 2021.

Let us know if you need any further assistance.

Regards,
Sridevi S.
 



SS Sridevi Sivakumar Syncfusion Team April 22, 2021 01:43 PM UTC

Hi Gian Piero Truccolo,

Thanks for your patience.

We can achieve your requirement by creating new CustomScheduleSource by adjusting the bottom GanttScheduleRow’s PixelPerUnit (which is used to render the Gantt schedule cells) property based on ZoomFactor and initial PixelPerUnit value in ZoomChanged event. Please find the snippet below.
 
  
XAML: 
 
<syncfusion:GanttControl x:Name="Gantt" 
                        ItemsSource="{Binding ListaAttivita}" 
                         ScheduleType="CustomDateTime" 
                         CustomScheduleSource="{Binding CustomSchedule}" 
                         … 
                         ZoomChanged="Gantt_ZoomChanged" 
</syncfusion:GanttControl> 
 
  
C#: 
In MainWindows.xaml.cs 
  
private void Gantt_ZoomChanged(object sender, ZoomChangedEventArgs args) 
{ 
    List<GanttScheduleRowInfo> currentSource = this.Gantt.CustomScheduleSource as List<GanttScheduleRowInfo>; 
    List<GanttScheduleRowInfo> newSource = new List<GanttScheduleRowInfo>(); 
    foreach (GanttScheduleRowInfo info in currentSource) 
    { 
        newSource.Add(info); 
    } 
  
    double initialPixelPerUnit = 30; 
    double adjustment = ((args.ZoomFactor - 100) / 10) * 5; 
    newSource[currentSource.Count - 1].PixelsPerUnit = initialPixelPerUnit + adjustment; 
    this.Gantt.CustomScheduleSource = newSource; 
    args.Handled = true; 
} 
  
  
In ViewModel.cs 
  
private List<GanttScheduleRowInfo> customSchedule; 
  
public List<GanttScheduleRowInfo> CustomSchedule 
{ 
    get 
    { 
        return this.customSchedule; 
    } 
  
    set 
    { 
        this.customSchedule = value; 
    } 
} 
  
public ViewModel() 
{ 
 
   this.CustomSchedule = new List<GanttScheduleRowInfo> 
   { 
       new GanttScheduleRowInfo { TimeUnit = TimeUnit.Weeks}, 
       new GanttScheduleRowInfo { TimeUnit = TimeUnit.Days, PixelsPerUnit = 30 } 
   }; 
} 
  
NOTE: Schedule stretch behavior will not get worked for CustomSchedule. I.e. White space will be displayed at the right side of Chart. 
  
Please find the sample from below link 
  
Please refer the below user guide document to know more information about custom zooming support in GanttControl, 
  
Please let us know if you have concerns.

Regards,
Sridevi S.
 
  
 



GI Gian April 23, 2021 10:14 AM UTC

Hi,

it's working.
Now if i zoom the schedule time width increase like we we expect.

Our goal is to increse days before and after so that the user can scrool on right and left in order to  move activies.
So we set ScheduleRangePadding="365".
First query, can we do this dynamically? For example add ScheduleRangePadding to the existing?

When we increase the zoom in this situation the gantt chart focus goes back.
Is there the possibility to scrool to the initial position? Or to keep a focus in a particular region..

Best regards
Gian Piero Truccolo






VR Vignesh Ramesh Syncfusion Team April 26, 2021 12:31 PM UTC

Hi Gian Piero Truccolo, 

Thanks for your confirmation. 

Query 1 : First query, can we do this dynamically? For example add ScheduleRangePadding to the existing? 
We can achieve this requirement by changing the ScheduleRangePadding dynamically in ZoomChanged event of GanttControl as like below snippet. 

private void Gantt_ZoomChanged(object sender, ZoomChangedEventArgs args) 
{ 
 
    // To increase the schedule range padding dynamically. 
    if (args.ZoomFactor != 100) 
    { 
        if (this.Gantt.ScheduleRangePadding != 365) 
        { 
            this.Gantt.ScheduleRangePadding = 365; 
        } 
    } 
    else if (this.Gantt.ScheduleRangePadding != 14) 
    { 
        this.Gantt.ScheduleRangePadding = 14; 
    } 
 
} 


Query 2 : Is there the possibility to scroll to the initial position? Or to keep a focus in a particular region 
We have ScrollGanttChartTo support in GanttControl, by using this method we can scroll the GanttChart to particular date. So, we can achieve your requirement by scroll the GanttChart to node’s start date in each and every zoom change as like below snippet. Since the scroll offset will be changed from source level for every zoom level changing. 

private void Gantt_ZoomChanged(object sender, ZoomChangedEventArgs args) 
{ 
     
 
    // To scroll the gantt chart to particular date. 
    this.Gantt.ScrollGanttChartTo(DateTime.Today); 
} 

Please find the updated demo from the below link. 


Please let us know if you have any queries. 

Vignesh Ramesh. 




GI Gian April 26, 2021 01:16 PM UTC

Hi,

we wantt to pass to method ScroolGanttChart teh date we see beofre we start zooming not a particual date. And keep it until the zoom will be reset.
Is it possible?

Best Regards
Gian Piero Truccolo


SS Sridevi Sivakumar Syncfusion Team April 28, 2021 07:09 AM UTC

Hi Gian Piero Truccolo,

This update is mainly to get the confirmation of your reported issue to proceed with this without any misleading.

Can you please provide detailed information on the reported query?

Do you want to pass the current schedule start date on the view to the ScrollGanttChartTo method while zooming to maintaining the same start date on the schedule view?


Regards,
Sridevi S. 



GI Gian April 28, 2021 07:24 AM UTC

Hi,

yes. this is our goal, so that the user zooming the area always starts from tha same start date and only with scrool bar the user will change the area the zoom.

Best regards
Gian Piero Truccolo


SS Sridevi Sivakumar Syncfusion Team April 29, 2021 02:03 PM UTC

Hi Gian Piero Truccolo,

Thanks for the clarification.

We have analyzed your requirement and achieve it in sample level. First, we have calculated the visible start date of the GanttSchedule by using GetVisibleStartDate method while Gantt loading or whenever the horizontal scroll bar get changed. After that, we have scrolled the GanttChart to the calculated visible start date on every zoom level changed by using ScrollGanttChartTo method of GanttControl. Please find the snippet below.
 
  
        private void Gantt_Loaded(object sender, RoutedEventArgs e)  
        {  
           …  
             
           sv2 = VisualTreeHelper.GetChild(VisualTreeHelper.GetChild(GanttChart, 0), 0) as ScrollViewer;  
            sv2.VerticalScrollBarVisibility = ScrollBarVisibility.Visible;  
            this.visibleStartTime = this.GetVisibleStartDate(sv1.HorizontalOffset);  
        }  
  
        private void Sv1_ScrollChanged(object sender, ScrollChangedEventArgs e)  
        {  
           ..  
  
            this.visibleStartTime = this.GetVisibleStartDate(e.HorizontalOffset);  
          …  
            }  
        }  
  
        private DateTime GetVisibleStartDate(double offset)  
        {  
            …  
                double days = offset / dayWidth;  
            …  
                return this.Gantt.ActualStartTime;  
        }  
  
        private void Gantt_ZoomChanged(object sender, ZoomChangedEventArgs args)  
        {  
…  
  
            // To scroll the gantt chart to particular date.  
            this.Gantt.ScrollGanttChartTo(this.visibleStartTime);  
        }  

Please have a sample from the below link  
 


Loader.
Up arrow icon