Set default zoom level

I am trying to set the default zoom level that the diagram area has when it is loaded on the page. How and where do I need to make the changes in the code to set the default diagram zoom level without using the drop down list to change the zoom value after loading? (eg: set the default zoom level at 50%)

1 Reply

SG Shyam G Syncfusion Team May 2, 2018 10:00 AM UTC

Hi Deshan, 
 
Please use create event which triggers when diagram control is created in which you can set a default zoom value. Please refer to the code example below. 
 
Code example: 
 
Aspx.cs file 
//create event 
 DiagramContent.OnClientCreate = "create"; 
 
   function create(args) { 
        var diagram = $("#diagram").ejDiagram("instance"); 
        var zoom = ej.datavisualization.Diagram.Zoom(); 
        var currentZoom = diagram._getCurrentZoom(); 
       //set zoom value to 50 percentage 
        zoom.zoomFactor = (0.5 / currentZoom) - 1; 
        diagram.zoomTo(zoom); 
  } 
 
 
Regards, 
Shyam G 


Loader.
Up arrow icon