Quantcast
Channel: GoJS - Northwoods Software
Viewing all articles
Browse latest Browse all 7069

Center align picture inside a node

$
0
0

@panirudh wrote:

In my application I have a GoJS diagram editor and I am trying to create a node and inside a node I am adding a picture. I need to center align the picture. Is there anyway I can do this?
Node Tepmplate code,

diagram.nodeTemplateMap.add("memoPicture",
	GO(go.Node, "Spot",
		new go.Binding("location", "loc", go.Point.parse).makeTwoWay(go.Point.stringify),
			GO(go.Panel, "Horizontal",
				GO(go.Picture,
				{
					name: "Picture",
					maxSize: new go.Size(250, 250),
					margin: new go.Margin(5, 5, 5, 5),
				},
				new go.Binding("source", "source"))
		)
	)
);

Code to add image is as below,

var location = "5 5";
var textNode =  $scope.diagramOptions.findNodeForKey("1");
	if (textNode !== null && textNode !== undefined) {
		var actBounds = textNode.actualBounds;
		location = "5" + (10 + actBounds.height);
	}
$scope.model.startTransaction("addPicture");
$scope.model.addNodeData({ key : "2", category:"memoPicture",  source:imageSource, loc: location, type: "editorImage" });
$scope.model.commitTransaction("addPicture");

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 7069

Trending Articles