Articles in this section
Category / Section

How to Reset Zoom on Angular Charts Using a Button Click?

2 mins read

Description

This article explains how to reset a zoomed-in Angular chart to its original view using a button click.

Solution

Zooming in charts allows you to focus on specific regions of the data for a more detailed view. By enabling the showToolbar property in zoomSettings, you can display the zooming toolbar on the initial rendering of the chart. This toolbar includes buttons for zoom, zoom-in, zoom-out, pan, and reset. If you need to reset the zoomed chart, simply set the zoomFactor property to 1 and the zoomPosition property to 0.

Code Snippet

app.component.html

<button ejs-button (click)="resetZoom()">Reset Zoom</button>
<ejs-chart [zoomSettings]='zoomSettings'>
</ejs-chart>

app.component.ts

   public zoomSettings: Object = {
       mode: 'X',
       enableMouseWheelZooming: true,
       enablePinchZooming: true,
       enableSelectionZooming: true,
       showToolbar: true
   };
   public resetZoom(): void {
      this.chart.primaryXAxis.zoomFactor = 1;
      this.chart.primaryXAxis.zoomPosition = 0;
   }
The following image illustrates the output of the above code:

Before clicking on the button

image.png

After clicking on the button

image.png

Refer to the working sample for additional details and implementation: View Sample in Stackblitz

Conclusion

We hope you enjoyed learning about how to reset a zoomed-in Angular chart to its original view using a button click.

You can refer to our Angular Chart feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our Angular Chart example 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, BoldDesk Support, 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