Query |
Response |
|
Please use fitToPage method which fits the diagram content within the viewport. We have created a sample in which we have called a fitToPage method at the button click. Could you please check in the below sample? Still if you face any issues, please share us more details such as modify the below sample.
|
|
Could you please elaborate your requirement in detail with the screenshot or video. So that we can validate and provide a solution. |
WebAPI
public List<HierarchicalTree> Get()
{
DiagramEntities3 entity = new DiagramEntities3();
List<HierarchicalTree> HierarchicalData = entity.HierarchicalTrees.ToList<HierarchicalTree>();
return HierarchicalData;
}
Angular
ngOnInit(): void {
const callback: Ajax = new Ajax(
'http://localhost:57270/api/entity/Get', 'GET', false, 'application/json; charset=utf-8'
);
callback.onSuccess = (JsonString: any): void => {
let diagramInstance= this;
setTimeout( function () {
//set an diagram layout
diagramInstance.diagram.layout = {
type: 'HierarchicalTree', verticalSpacing: 30, horizontalSpacing: 40,
enableAnimation: true
}
//get a layout tree from database
let parsedData = JSON.parse(JsonString);
//set datasource
diagramInstance.diagram.dataSourceSettings = {
id: 'Name', parentId: 'Category',
dataManager: new DataManager(parsedData),
doBinding: (nodeModel: NodeModel, data: object, diagram: Diagram) => {
nodeModel.shape = { type: 'Basic', shape:'Rectangle' };
nodeModel.annotations = [{content: (data as EmployeeInfo).Name}]
}
}
},100)
};
callback.send().then();
} |
|
public scrollSettings: ScrollSettingsModel = { minZoom: 0.01 }; |
Hi Shyam,
Your example in https://stackblitz.com/edit/angular-ksffa1-dwtpf4?file=app.component.ts does not work when calling .fitToPage() if the browser window is in a certain size. Steps to reproduce:
- Set browser window not to max.
- Press fitToPage button -> diagram is not resized to fit available space - FAIL
- Set browser window to max.
- Press fitToPage button -> diagram is resized to fit available space - SUCCESS
- Set browser window back to not max.
- Press fitToPage button -> diagram is not resized to fit available space - FAIL
I am also getting the same result using my code.
Robert
Hi Robert,
We will validate and update you with more details on September 01, 2022.
Regards,
Sivaranjith
Hi Alain,
The diagram fitToPage method works when we zoom in/out the diagram page not the browser zoom. Could you please share us more details such as video to explain your issue which will help us to investigate further on it.
Regards,
Shyam G
Hi Shyam G,
Please see attached video that shows fitToPage() doesn't work if available space of diagram is small.
Robert
Hi Robert,
The fitToPage method will zoom the diagram based on the viewport size. The minimum zoom allowed in diagram is 0.2 and maximum zoom is 30. In the video, the diagram size is lesser in the stackblitz and when you call the fitToPage method, the diagram zoom value is lesser than 0.2 and so the fitToPage method doesn't work in this case. Please open the stackblitz in new window and use fitToPage method.
Regards,
Sivaranjith
Hi Sivaranjith,
Thanks for the reply. I will take note of the size when c
Robert
Hi Robert,
Please let us know if you need further assistance on this.
Regards,
Sivaranjith