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.
Unfortunately, activation email could not send to your email. Please try again.

VisibleRange - shouldn't it change when zooming?

Thread ID:

Created:

Updated:

Platform:

Replies:

129874 Apr 6,2017 03:04 PM Apr 10,2017 07:59 AM WPF 3
loading
Tags: SfChart
Alan L
Asked On April 6, 2017 03:04 PM

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?

Devi Aruna Maharasi Murugan [Syncfusion]
Replied On April 7, 2017 10:56 AM

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 
 





Alan L
Replied On April 7, 2017 02:01 PM

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.




Devi Aruna Maharasi Murugan [Syncfusion]
Replied On April 10, 2017 07:59 AM

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 




CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;