Hi Team-
we are facing some issue with Connector's annotation style while switching between connector's type.
Here are the steps:
We are using automatic layout while creating diagram.
User might be able to change the coordinates of the nodes which we store in storage on node's position change event (positionChange event)
when we load the diagram , we override node's default position on created event of the diagram.
At any point when we trigger the position change event ,
if (args.state == 'Completed')
{
store the coordinates ();
rearrange the connectors();
}
in the rearrangeConnector we switch the connector type to StraightLine and then by Orthogonal(our default type is always Orthogonal)
the reason we are doing this is because on position change connector tend to add a lot of unnecessary segments , therefore by changing it to straightLine and then to Orthogonal it rearranges itself with least segment in Orthogonal type.
Only problem in this approach is the annotation of connector which is supposed to stick to the middle of the connector:
function getConnectorDefaults(obj) {
obj.type = 'Orthogonal';
obj.style.strokeColor = '#cdcdcd';
obj.style.strokeWidth = 1;
obj.constraints =
(ej.diagrams.ConnectorConstraints.Default
| ej.diagrams.ConnectorConstraints.DragSegmentThumb) &
~ej.diagrams.ConnectorConstraints.DragSourceEnd &
~ej.diagrams.ConnectorConstraints.DragTargetEnd
;
obj.targetDecorator = {
style: {
strokeColor: '#cdcdcd',
fill: '#cdcdcd',
},
};
obj.annotations = [{
content: '',
margin: { top: 10, bottom: 10 },
horizontalAlignment: 'Center',
verticalAlignment: 'Top',
style: { fontSize: '11' },
}];
return obj;
}
is still holding on to it's position as if the connector is straightLine(not orthogonal)
I have attached images to explain this behavior and code available in console in the attached screenshot.
I want the annotation to retain it's style in the same way when the connector type - Orthogonal.
Attachment:
ConnectorTransition_3f283a38.zip