We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to apply zooming and paning feature on diagram?


We are creating some sample map using the Diagram feature in the angular. We want zoom and panning feature in the diagram. We have created diagram like below,

In the drawshape.component.html
<ejs-diagram #diagram id="diagram" width="100%" height="700px" [snapSettings]='snapSettings' [getConnectorDefaults]='connDefaults' [getNodeDefaults]='getNodeDefaults' dragEnter='dragEnter' (created)="diagramCreate($event)" [constraints]='diagramConstraints'> </ejs-diagram>

And in the drawshape.component.ts file,

ngOnInit(): void {
       this.diagramConstraints = DiagramConstraints.PageEditable | DiagramConstraints.Zoom & ~DiagramConstraints.Pan;

What changes need to be done in the code? Please suggest. Thank you.

3 Replies

RT Ramya Thirugnanam Syncfusion Team July 2, 2019 06:19 AM UTC

Hi Siddharth,  
Thanks for contacting Syncfusion support. 
Please set DiagramTools as ZoomPan to activate pan tool in diagram. Please refer to the below code example, sample and help documentation.  
Code example:  
  <ejs-diagram #diagram id="diagram" width="100%" height="499px"  [tool]='tool' 
public tool: DiagramTools = DiagramTools.ZoomPan;  
Ramya T 

SK Siddharth Kulat July 2, 2019 09:04 AM UTC

Hello Sir,

Thanks for the update. Actually we want the achieve the functionality using the button click. I am attaching the image of the required functionality. Do you have any sample code for that?


Thank You

RT Ramya Thirugnanam Syncfusion Team July 2, 2019 11:58 AM UTC

Hi Siddharth,  
We have modified a sample to activated pan tool in button click. Please refer to the code example and sample below.  
Code example:  
  <button id="changeTool" (click)="changeTool()"> changeTool </button>  
changeTool(): void {  
      //set ZoomPan tool  
       this.diagram.tool =  DiagramTools.ZoomPan;  
Ramya T 

Live Chat Icon For mobile
Up arrow icon