Articles in this section
Category / Section

How to keep the axis interval constant while zooming in WPF Chart?

1 min read

This article explains how to maintain a specific interval on the axis while zooming in a WPF chart.

To maintain a specific interval on the axis while zooming a WPF chart you can use the EnableAutoIntervalOnZooming property of the chart axis and set it to false.

Additionally, you can add the ChartZoomPanBehavior to the charts’ behavior collection and set the desired interval on the axis. This will ensure that the axis interval remains consistent during zoom operations.

The following code sample demonstrates this implementation.

[Xaml]

<chart:SfChart>
 
    <chart:SfChart.Behaviors>
        <chart:ChartZoomPanBehavior />
    </chart:SfChart.Behaviors>
            
    <chart:SfChart.PrimaryAxis>
        <chart:NumericalAxis Interval="5" EnableAutoIntervalOnZooming="False"/>
    </chart:SfChart.PrimaryAxis>
 
    <chart:SfChart.SecondaryAxis>
        <chart:NumericalAxis />
    </chart:SfChart.SecondaryAxis>
 
    <chart:ColumnSeries ItemsSource="{Binding Data}"
                        XBindingPath="XValue"
                        YBindingPath="YValue"/>
</chart:SfChart>

 

By setting this code sample, the chart will maintain the interval of 5 even when zooming.


Output:

Before zooming, the x-axis interval is 5, and the y-axis interval is 20.


Chart before zooming.


After zooming, the x-axis maintains the same interval, but the y-axis interval has changed.


Maintain axis interval while zooming.


For more details, please refer to the project on GitHub.


See Also

How to reset zooming in WPF Chart (SfChart)?

How to zoom a chart programmatically?

How to set zoom and pan position for WPF Chart (SfChart)?


Conclusion

I hope you enjoyed learning how to keep the axis interval constant while zooming in WPF Chart (SfChart).

You can refer to our WPF Chart feature tour page know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WPF Chart Examples to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

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