Diagram positioning

I m working on a project with a lot of diagrams in it, i need to fix these diagram to center of div and automatically fit the div on initialization for that purpose i was using
->this.diagram.initialContentAlignment = go.Spot.Center
then i use
->this.diagram.autoScale=go.Diagram.Uniform;

but the diagram render at the top right corner of div instead of center

and the diagram is not scaling to div size the red border marks the boundary of diagram
initial

Are you creating and initializing the Diagram too early? I’m wondering if at that time the DIV does not yet have the width and height that you are expecting it will have eventually. In your code you can check this at the time you are giving the Diagram its Diagram.div.

So I suggest that you only associate the Diagram with the DIV element once it has its expected size.

Unfortunately there is no HTML DOM event that notifies when a particular element has changed size, otherwise we would have implemented that so that we could always update everything to fit with the modified DIV. Read more at Resizing Diagrams -- Northwoods Software

well i m working in angular 6 and the diagram is initialized in the constructor and the height is applied to the diagram div in oninit()function dynamically after that the diagram is created

In which constructor? The app constructor is too early. Why can’t you associate the Diagram with its DIV at the time in OnInit that you are setting the DIV’s height?

i think i didnt convay what i ment
this dive is referenced in on init() but the other things that set the properties of diagram are in the constructor

and the above service above the highlight is setting the class of the diagram div

Did you read what I suggested, at Resizing Diagrams -- Northwoods Software ?