Zooming Functionality in JavaScript Gantt Chart Control

18 Nov 20181 minute to read

The JavaScript Gantt Chart control provides zooming support to adjust the timeline view dynamically. This includes increasing or decreasing the width of timeline cells and changing the timeline units to view tasks across various timespan from minutes to decades.

To enable zooming features, add ZoomIn, ZoomOut, and ZoomToFit to the toolbar items collection. These actions can also be triggered externally using the built-in methods like zoomIn, zoomOut, and fitToProject.

Zoom in

This support is used to increase the timeline width and timeline unit from years to minutes timespan. When the ZoomIn icon was clicked, the timeline cell width is increased when the cell size exceeds the specified range and the timeline unit is changed based on the current zoom levels.

Zoom out

This support is used to increase the timeline width and timeline unit from minutes to years timespan. When the ZoomOut icon was clicked, the timeline cell width is decreased when the cell size falls behind the specified range and the timeline view mode is changed based on the current zooming levels.

Zoom to fit

This support is used to view all the tasks available in a project within available area on the chart part of Gantt. When users click the ZoomToFit icon, then all the tasks are rendered within the available chart container width.

Customizing zooming levels

Zoom actions are governed by predefined zooming levels specified in the zoomingLevels property. These levels can be customized by assigning a collection of zoom configurations to the zoomingLevels property.

Zoom actions via methods

Zooming actions can be triggered dynamically or through external controls using the following methods:

  • Zoom In - Use zoomIn when ZoomIn external button was clicked, the timeline cell width is increased when the cell size exceeds the specified range and the timeline unit is changed based on the current zoom levels.
  • Zoom Out - Use zoomOut when the ZoomOut external button was clicked, the timeline cell width is decreased when the cell size falls behind the specified range and the timeline view mode is changed based on the current zooming levels.
  • Zoom To Fit - Use fitToProject When ZoomToFit external button was clicked then all the tasks are rendered within the available chart container width.