Articles in this section
Category / Section

How to Enable Zooming in Angular Column Charts?

2 mins read

Description

This article explains how to dynamically enable zooming in an Angular Column Chart when the dataset exceeds a specific number of data points.

Solution

To automatically enable zooming and scrolling based on the data count, configure the zoomFactor in the chart’s load event.

Implementation Details

  • If the dataset contains fewer than 5 data points, set zoomFactor to 1 (default view, no zoom).
  • If the dataset contains 5 or more data points, set zoomFactor to 0.5 to enable zooming and horizontal scrolling.

This approach ensures optimal data visibility by automatically adjusting the zoom level based on the dataset size.

Code Snippet

app.component.ts

public load(args): void {
   if (args.chart.dataSource.length > 5) {
     args.chart.primaryXAxis.zoomFactor = 0.5;
   } else {
     args.chart.primaryXAxis.zoomFactor = 1;
   }
   args.chart.zoomModule.isZoomed = true;
 }

app.component.html

<ejs-chart (load)='load($event)'>
</ejs-chart>

Screenshot

image.png

Live Demo

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

Conclusion

We hope you enjoyed learning how to enable zooming in Angular Column Charts based on the number of data points.

You can refer to our Angular chart feature tour page to learn about its other groundbreaking feature representations and documentation, as well as how to quickly get started with 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, 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