Hi there – this is a pretty basic question about figuring out the location of a node/Shape on the screen within the canvas. I’m confused about how to interpret the location data I am getting when I query a node’s position. I’m getting location values like “-228.9749994277954 -54.75”, but I’m confused as to what those coordinates to relative to?
What I’d like to do is get the node’s actual location on the screen by first determining (via jquery) the position of the GoJS canvas element, which will give me positive X,Y coordinates. Then, within GoJS, I’d like to be able to interpret the aforementioned negative location value coordinates so I can then make them relative the canvas’ position. Once I can do that, I can then infer a node’s ACTUAL position within the browser’s viewport. I’m sure there’s something simple in the docs I’m missing here…
The reason i need to do this is b/c I’m spawning a small modal html toolbar (that , in my requirements, needs to be done outside goJS for styling reasons and I also don’t want that to zoom) that will position itself adjacent to the node.
My diagram’s orientation :
“initialAutoScale”: go.Diagram.Uniform,
“initialContentAlignment”: go.Spot.Center
Here is what a typical node looks like :
$g(go.Node, “Spot”, GoJS_Styles.nodeStyle(),
new go.Binding(“location”, “loc”, go.Point.parse).makeTwoWay(go.Point.stringify),
// the main object is a Panel that surrounds a TextBlock with a rectangular Shape
$g(go.Panel, “Auto”,
$g(go.Shape, “Rectangle”,
{ fill: GoJS_Styles.decisionBgColor,
stroke: “rgb(100,100,100)” },
new go.Binding(“figure”, “figure”)),
$g(go.TextBlock,
{ font: “bold 9pt Helvetica, Arial, sans-serif”,
stroke: GoJS_Styles.darkText,
margin: 8,
maxSize: new go.Size(160, NaN),
wrap: go.TextBlock.WrapFit,
editable: true },
new go.Binding(“text”, “text”).makeTwoWay())
),
),