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

VisibleRange - shouldn't it change when zooming?

I'm trying to display a chart's primary axis VisibleRange start and end dates in alternate locations.  The problem is that the properties don't seem to ever fire a change notification and Snoop indicates the values don't change when zooming.

I know the values are read only, but shouldn't they be accessible?
Is there another way to access a chart's VisibleRange start and end?

3 Replies

DA Devi Aruna Maharasi Murugan Syncfusion Team April 7, 2017 02:56 PM UTC

Hi Alan, 
  
Thanks for contacting Syncfusion Support. 
You can access the VisibleRange of axis in ActualRangeChanged event, whenever axis range gets changed. 
We have prepared a demo sample based on this to read the VisibleRange of the axes while zooming. 
  
Please refer the code snippet, 
  
XAML 
<chart:SfChart Name="chart" ZoomChanged="chart_ZoomChanged"> 
   
        <chart:SfChart.PrimaryAxis> 
             <chart:CategoryAxis  
                    ActualRangeChanged="CategoryAxis_ActualRangeChanged" /> 
        </chart:SfChart.PrimaryAxis> 
 
        <chart:SfChart.SecondaryAxis> 
                <chart:NumericalAxis                    
                     ActualRangeChanged="NumericalAxis_ActualRangeChanged"/> 
        </chart:SfChart.SecondaryAxis> 
 
    <chart:SfChart.Behaviors> 
        <chart:ChartZoomPanBehavior EnableSelectionZooming="True" 
                                    EnablePanning="True" 
                                    EnableZoomingToolBar="True" 
                                    ToolBarItems="All"/> 
                 
        </chart:SfChart.Behaviors> 
           
 </chart:SfChart> 
 
  
C# 
private void CategoryAxis_ActualRangeChanged(object sender, 
                                     ActualRangeChangedEventArgs e) 
        { 
             
            yStart.Text = chart.SecondaryAxis.VisibleRange.Start.ToString(); 
            yEnd.Text = chart.SecondaryAxis.VisibleRange.End.ToString(); 
        } 
 
        private void NumericalAxis_ActualRangeChanged(object sender,  
                                               ActualRangeChangedEventArgs e) 
        { 
            xStart.Text = chart.PrimaryAxis.VisibleRange.Start.ToString(); 
            xEnd.Text = chart.PrimaryAxis.VisibleRange.End.ToString(); 
        } 
  
  
Please find the output screenshot 
  
1)Before Zooming: 
 
2) After Zooming 
 
 
  
Please find the demo sample from below location 
  
Regards, 
Devi 
 






AL Alan L April 7, 2017 06:01 PM UTC

That gets me something like the behavior I was seeking, but doesn't seem accurate.

As an example, using your example, if I zoom from 19 to 20...

The visual display makes sense...


But the Visible range is given as ~18 to ~19.





DA Devi Aruna Maharasi Murugan Syncfusion Team April 10, 2017 11:59 AM UTC

Hi Alan, 
  
Thanks for your update. 
  
Since we have used CategoryAxis as chart primary axis in the demo provided in our last update, the visible range will be corresponding axis label index instead of the actual value. 
  
For example, if you have selected axis between 19 to 20, then the visible range of the CategoryAxis will be 18 to 19(index position of 19th and 20th point). 
  
To display the actual value as axis visible range, we can use NumericalAxis instead of CategoryAxis 
  
Please find the code snippet, 
<chart:SfChart Name="chart" > 
 
      <chart:SfChart.PrimaryAxis> 
          <chart:NumericalAxis x:Name="xAxis" 
                               EdgeLabelsVisibilityMode="AlwaysVisible" 
                               Interval="1" 
                                ActualRangeChanged="xAxis_ActualRangeChanged"/> 
     </chart:SfChart.PrimaryAxis> 
 
    <chart:SfChart.SecondaryAxis> 
        <chart:NumericalAxis x:Name="yAxis"   
               ActualRangeChanged="yAxis_ActualRangeChanged"/> 
    </chart:SfChart.SecondaryAxis> 
</chart:SfChart> 
 
  
C# 
 
private void xAxis_ActualRangeChanged(object sender,  
             Syncfusion.UI.Xaml.Charts.ActualRangeChangedEventArgs e) 
   { 
       yStart.Text = chart.SecondaryAxis.VisibleRange.Start.ToString(); 
       yEnd.Text = chart.SecondaryAxis.VisibleRange.End.ToString(); 
   } 
 
private void yAxis_ActualRangeChanged(object sender,  
                 Syncfusion.UI.Xaml.Charts.ActualRangeChangedEventArgs e) 
{ 
      xStart.Text = chart.PrimaryAxis.VisibleRange.Start.ToString(); 
      xEnd.Text = chart.PrimaryAxis.VisibleRange.End.ToString(); 
        
 } 
  
  
Please find the output image, 
  
1)While Zooming 
 
  
2)After Zooming 
 
  
We have prepared a demo sample by using NumericalAxis as chart primary axis for your reference and it can be downloaded from below link, 
  
  
Regards, 
Devi 




Loader.
Live Chat Icon For mobile
Up arrow icon