We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Showing the first few bars in sfchart and enable scrolling to see the rest

Hi,

I referred the below link.

https://www.syncfusion.com/kb/7721/how-to-display-fixed-number-of-data-points-in-sfchart

But with this it always shows the last set of bars . However, I want to show the first few bars based on the number specified and enable scrolling to see the bars on the right.

Is it possible?

3 Replies

SP Saravana Pandian Murugan Syncfusion Team June 15, 2017 11:28 AM UTC

Hi Naveen, 
  
Thanks for using Syncfusion products. 
  
You can achieve this requirement by using ZoomFactor/ZoomPosition of ChartAxis. Please find the code snippet below. 
  
Code Example: 
  
  
chart.PrimaryAxis = new CategoryAxis() 
            { 
  
                ZoomFactor = 0.5, 
  
                ZoomPosition = 0       
      
            }; 
  
  
  
ZoomFactor defines the percentage of visible range from the total range of axis. For instance, when the Range is from 0 to 100 and ZoomFactor is 0.5, the visible range will be 0 to 50 or 50 to 100 (the start of the range will be determined by ZoomPosition).  
  
ZoomPosition: 
  
ZoomPosition defines the start of the range of values that need to be displayed as a result of ZoomFactor. For the above scenario, when the ZoomPosition is 0.25 then the visible range will be from 25 to 75. 
  
Note: The sum of ZoomFactor and ZoomPosition must also fall within the value of 0 to 1. 
  
We have attached a sample for your reference which can be downloaded from the below location. 
  
  
Please check the sample and let us know if you need further assistance on this. 
  
Regards, 
Saravana Pandian M. 



NC Naveen C Ramachandrappa June 16, 2017 08:46 PM UTC

Hi,

Thanks for the info. I have an additional question.

Let say I have 8 bars and I show only 4 bars when the chart comes up using the zoom factor and zoom position.

If I try zooming out completely, I will end up seeing all the 8 bars but I want to restrict user to see only 4 bars at the max when he tries to zoom out and to see the rest he has to scroll. At no point in time, I want him to see more than 4 bars. So, I want to lock user on zoom out . Is there a way to achieve this?


PS Parthiban Sundaram Syncfusion Team June 19, 2017 05:46 AM UTC

  
  
Thanks for the update. 
  
Please find the below code snippet to lock the Zooming.  
  
Code Snippet: 
  
            
 chart.ChartBehaviors.Add(newChartZoomPanBehavior() 
            { 
                EnableDoubleTap = false, 
                EnableZooming = false 
            }); 
  
 
  
Also, we have modified the sample based on your requirement. Please download from following location. 
  
   
Please let us know, if you need further assistance on this.  
  
Regards,
Parthiban S
  
 


Loader.
Live Chat Icon For mobile
Up arrow icon