Articles in this section
Category / Section

How to Set Current Zoom Value to Specific Value in JavaScript Diagram?

2 mins read

You can set current zoom value to specific value by calculating the required zoom factor.
The zoom factor determines how much the diagram should be zoomed in or out. It can be calculated by dividing the specific value by the current zoom value of the diagram.
You can use the zoomTo() method to apply the zoom. This method adjusts the zoom level of the diagram based on the calculated zoom factor, effectively zooming the diagram to the desired value.

The below code snippet demonstrating how to set the current zoom value to a specific value:

document.getElementById('zoom').onclick = () => {
 let zoomOption = {};
 //You can set any specific value as the target
 let target = 0.3143011474609375
 zoomOption.zoomFactor = target / diagram.scrollSettings.currentZoom - 1;
 diagram.zoomTo(zoomOption );
 console.log(diagram.scrollSettings.currentZoom)
 diagram.dataBind();
};

Sample

Conclusion
I hope you enjoyed learning how to set the current zoom value to a specific value in JavaScript Diagram.

You can refer to our JavaScript Diagram 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 JavaScript Diagram 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