Keeping visible y-values on zoomed graph when range changes

2 posts, 0 answers
  1. Philip
    Philip avatar
    15 posts
    Member since:
    Mar 2015

    Posted 07 Feb Link to this post

    Hi, I'm using a RadCartesianChart with a LinearAxis as y-axis. The range for the y-axis is automatic (I haven't set Minimum or Maximum on the axis).

    Vertical zoom is enabled, so the user can zoom to the range he likes. The problem is that the range of the viewed y-values changes when range of the line series changes. I understand this is probably by design, since you want to keep the relative values VerticalZoomRangeStart and VerticalZoomRangeEnd.

    To make the problem clear, I'll use an example:

    Let's say the range of the data is [0,10]. The user then zooms the y-axis to display the values [8,9]. Then the range of the data changes to [0,20] and the range of the y-aixs is recalculated. The range the user sees now automatically changes from [8,9] og [16,18], since the zoom is still [0.8,0.9]. Is there a way to avoid this without manually setting the range of the y-axis?

    From the documentation it says : "Maximum: Gets or sets the user-defined maximum of the axis. By default the axis calculates the maximum, depending on the maximum of the plotted data points."

    Is there a way to get the calculated maximum? I would then be able to calculate new values for vertical zoom to keep the range of the y-values the same. I noticed that the calculated maximum is not necessarily the same as maximum of the dataset, since you make sure the calculated maximum is a nice round number.


  2. Martin Ivanov
    Martin Ivanov avatar
    1352 posts

    Posted 09 Feb Link to this post

    Hi Philip,

    You are correct, the chart keeps the relative zoom range when the axis range changes. This is by design and cannot be changed. In order to achieve your requirement you will need to manually calculate the new zoom range and set the corresponding properties - VerticalZoomRangeStart and VerticalZoomRangeEnd.

    You can get the automatically calculated range via the LinearAxis' ActualRange and ActualVisibleRange properties. There are also events which are invoked when those properties change - .ActualRangeChanged and ActualVisibleRangeChanged.

    I hope this helps.

    Telerik by Progress
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Back to Top