Hi,
I’m creating an interface that allows users to drag search results into a go.js diagram and have them appear as new nodes. Everything is working except accurate positioning of the new node elements. My attempt always appears some distance to the southeast of the intended spot. I’m guessing that given the mouse event object though, I should be able to express a generic line of code that places the node at the mouseup point, but I’m not sure what I’m missing. This is what I’m currently trying, where ‘e’ is the mouse event, and ‘pt’ should hold the loc value:
notifyDropTarget: function (ddSource, e, data) {
var myDiagram = this.getGoMainCanvas().diagram,
pt = myDiagram.transformViewToDoc(new go.Point(e.getXY()[0], e.getXY()[1])),
locString = String(pt.x + ' ' + pt.y);
var nodeData = {
key: data.records[0].data.uri,
title: data.records[0].data.label,
type: "standard",
category: "standard",
percent: 22.60845450218767,
color: "#00FFFF",
description: data.records[0].data.preview,
loc: locString
};
myDiagram.model.addNodeData(nodeData);
}
Big thanks in advance for any insight.
Cheers,
- Ken