Change minimum and maximum of Y Axis after zooming


How to set minimum and maximum of the Y axis after user zooms using mouse wheel


I tried use this article in zoomend event but didn't work

How to Update the Minimum and Maximum Axis Range in Blazor Charts?


Please guide




1 Reply

DG Durga Gopalakrishnan Syncfusion Team November 13, 2024 12:36 PM UTC

Hi Praveen,


We recommend using the OnAxisActualRangeCalculated event to adjust the axis range after zooming the chart. Compare the zoomed axis range minimum and maximum values with the initial axis range, then modify the argument’s minimum and maximum values to achieve your desired result. Please refer to the sample and screenshot below.


<SfChart>

    <ChartEvents OnAxisActualRangeCalculated="RangeCalculatedEvt"></ChartEvents>   

    <ChartPrimaryYAxis Minimum="@initialMinY" Maximum="@initialMaxY"></ChartPrimaryYAxis>

    <ChartZoomSettings EnableMouseWheelZooming ="true"></ChartZoomSettings>

</SfChart>

@code {

    public double initialMinY = 0;

    public double initialMaxY = 50;

    public double newMinY = 10;

    public double newMaxY = 40;

    public void RangeCalculatedEvt(AxisRangeCalculatedEventArgs args)

    {

        if (args.AxisName == "PrimaryYAxis" && initialMinY != args.Minimum && initialMaxY != args.Maximum)

        {

            args.Minimum = newMinY;

            args.Maximum = newMaxY;

        }

    }

}


Sample : https://blazorplayground.syncfusion.com/VtrJMiCgpVIopQvB


Please let us know if you have any concerns.


Regards,

Durga Gopalakrishnan.


Loader.
Up arrow icon