Articles in this section
Category / Section

How can I retrieve the chart's axis range in WPF?

1 min read

The ChartAxis has two range types, the ActualRange and the VisibleRange. The value of the ActualRange retains the whole axis range all the time. The VisibleRange carries the current axis range value of the zooming or panning or scrolling state.

How to get axis visible range

You can get the current VisibleRange value of ChartAxis using the VisibleRange property as the code example below.

 

<chart:SfChart x:Name="chart" LayoutUpdated="chart_LayoutUpdated">
       <chart:SfChart.PrimaryAxis>
             <chart:CategoryAxis Interval="2" x:Name="primary" />
       </chart:SfChart.PrimaryAxis>
       ….
 
</chart:SfChart>

 

private void chart_LayoutUpdated(object sender, EventArgs e)
{
     var visibleRange = primary.VisibleRange;
} 

How to get axis actual range

You can get the ActualRange value of ChartAxis with help of ActualRangeChanged event argument values e.ActualMinimum and e.ActualMaximum, which represents start and end range of axis value respectively. The following code example shows how to get axis actual range value.

 

 <chart:SfChart x:Name="chart" >
      <chart:SfChart.PrimaryAxis>
          <chart:CategoryAxis Interval="2" x:Name="primary" ActualRangeChanged="primary_ActualRangeChanged"/>
       </chart:SfChart.PrimaryAxis>
        …. 
 
</chart:SfChart>

 

private void primary_ActualRangeChanged(object sender, ActualRangeChangedEventArgs e)
{
     var primaryActualMin = e.ActualMinimum;
     var primaryActualMax = e.ActualMaximum;
}

 

See Also:


How to specify axis range with padding in UWP

 

How to view specific axis range in real time or dynamic update for UWP

 

How to view axis range with padding in WPF

 

How to view certain axis range while dynamic update in WPF

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied