Skip to content

This sample demonstrate how to maintain a particular interval on axes while zooming WPF chart.

Notifications You must be signed in to change notification settings

SyncfusionExamples/How-to-maintain-a-particular-interval-on-axes-while-zooming-WPF-chart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

How-to-maintain-a-particular-interval-on-axes-while-zooming-WPF-chart

This sample demonstrate how to maintain a particular interval on axes while zooming 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 (in this case, 5) 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>

Output:

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

After zooming, the x-axis maintains the same interval, but the y-axis interval has changed. Maintain a particular interval on axes while zooming WPF Chart

Troubleshooting

Path too long exception

If you are facing path too long exception when building this example project, close Visual Studio and rename the repository to short and build the project.

About

This sample demonstrate how to maintain a particular interval on axes while zooming WPF chart.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages