Conflicting features and tools


We have implemented a diagram that is fairly feature-rich, especially when it comes to links. Among other things, we let the user select whether to use regular, curvy or orthogonal links. We have also added the PolylineLinkingTool to allow the user to create new segmented links.

Already, we hit some issues trying to integrate these tools and features. As an example, curvy links (i.e. curve: go.Link.Bezier) appear to require the fromSpot/toSpot value to be None whereas orthogonal links sometimes exhibit weird behavior unless the fromSpot/toSpot is a Side.

Similarly, the PolylineLinkingTool gives the best result for a fromSpot/toSpot value of None. Side values have the effect that the created link’s endpoints’ location seem to be recalculated instead of respecting the exact spots set by the user.

Still, we found satisfactory workarounds for these issues.

Now, we want to add the LinkShiftingTool to our diagram, in order to allow the user to set the location of link endpoints. The problem here is that this tool will only activate (and work as expected) for links whose fromSpot/toSpot values are either Sides or specific spots.

Given this requirement, we struggle to find a way to define our link template (and diagram as a whole) in a way that would satisfy the requirements for curvy links, orthogonal links, the PolylineLinkingTool and the LinkShiftingTool. It seems that whatever fromSpot/toSpot value we set on the link template, some things are going to work and some things aren’t.

Are the various diagram features and extension tools meant to work with each other, or are they only supposed to work in isolation as in the various example diagrams you provide? If the former is true, could you provide some example that is close enough to what we’re trying to achieve?

That’s a pretty general question.

Bezier curve link routes by default only have four points in them, including the middle two control points. Combining that with other features might produce a conflict because there aren’t enough points to do what you want.

“…Side” Spots are meant to be used for rectangular ports where the link routing can be calculated for all of the links connecting with the port.

Since you want to have so much flexibility for each link, it seems that you should not be using any particular spot on your ports. Instead, you’ll want to set or bind the Link.fromSpot and Link.toSpot on each link based on what’s appropriate for the kind of routing or editing that you want to support.

That will mean that you’ll need to adapt the LinkShiftingTool to work in your environment with your expectations. I’m not sure what might be needed to be done. Hopefully at the time the PolylineLinkingTool is running you’ll know whether it should be curvy or orthogonal. Clearly you will already know that when the LinkShiftingTool is running.

Here’s a very specific example of something we’d expect to work out of the box:

This is a very lightly modified version of the LinkShiftingTool example diagram: the only meaningful change is that the link template’s curve is set to go.Link.Bezier. In order for links to actually display a curve, the fromSpot/toSpot property assignments have to be commented out on the node template, effectively setting the properties to None.

The issue is that these changes prevent the LinkShiftingTool from activating, since it requires spots that are either specific or Sides. Uncommenting the fromSpot/toSpot property assignments brings the tool back, but makes links straight instead of curvy.

Once again, we really expect a link shifting tool to work on links in general, not only on straight links. Conversely, we expect links to support a constant set of features regardless of whether they happen to be straight or curvy.

OK, so I just copied extensions/LinkShifting.html and made one change: I added this line to the link template’s property settings:

    , curve: go.Link.Bezier, fromEndSegmentLength: 30, toEndSegmentLength: 30

Then shifting the link coming out of Alpha results in:

This behavior looks correct to me.

Moving Beta towards the right shows how the link stays at the manually shifted spot at Alpha:

So everything looks like it behaves as I think you are asking for. Perhaps there is some other combination of properties that isn’t working for you?

I wouldn’t say this is the desired behavior, for the following reasons:

  1. The handles allowing the user to reshape the curvy link are gone
  2. The anchor shifting handles are not displayed near the node’s border, where the user naturally expects them to be

What we want is for curvy links to work the same, with the ability to move their endpoint along a node’s border.

Well, for #2 you could change the segmentFraction of the shifting handles to be 0.2 or something like that.

I don’t know about #1.