I have created palette data as defined below. It is my understanding that links should be defined using Point. But it is unpractical because i have to take into account the other items in the palette such as nodes. In the end, links will never have the right positioning as we add more nodes in the palette (see screenshot).
So is there a way to stack automatically nodes and links in the palette ? It is working fine with nodes, but not for links obviously.
public paletteNodeData: Array<go.ObjectData> = [
{ key: 'PaletteDecisionNode', color: 'firebrick', figure: 'Diamond', label: 'Decision' },
{ key: 'PaletteTaskNode', color: 'blueviolet', figure: 'RoundedRectangle', label: 'Task' },
{ key: 'PaletteProcessNode', color: 'yellow', figure: 'Procedure', label: 'Process' }
];
public paletteLinkData: Array<go.ObjectData> = [
{ points: new go.List(/*go.Point*/).addAll([new go.Point(0, 100), new go.Point(30, 100), new go.Point(30, 140), new go.Point(60, 140)]) }
];
yes, this is the behavior I want, and I actually took the code from this sample. It seems the link is positioned in the palette with absolute coordinates, but it is not “stacking” automatically.
(not sure what you mean with the non-negative points)
// the Palette also has a disconnected Link, which the user can drag-and-drop
{ points: new go.List(/*go.Point*/).addAll([new go.Point(0, 0), new go.Point(30, 0), new go.Point(30, 40), new go.Point(60, 40)]) },
{ points: new go.List(/*go.Point*/).addAll([new go.Point(20, 20), new go.Point(60, 20), new go.Point(60, 40), new go.Point(60, 50)]) },
{ points: new go.List(/*go.Point*/).addAll([new go.Point(900, 900), new go.Point(930, 900), new go.Point(930, 940), new go.Point(960, 940)]) }
but that was the point I was making :) For nodes to stack up in the Palette, there’s no need for hard-coded Point coordinates.
However for Links it seems we have to hard-code coordinates. In the end it is unmanageable. Each time I will add new items to the Palette, I will have to update the coordinates of the Links.
Is there no way to make them stack automatically (similarly to the nodes) ?
I’m saying that they do stack up automatically. However, you have to provide some route for the link, otherwise there won’t be anything to show. (Since there are no connected Nodes, there’s no way for it to compute a route.) You can probably use the same route for all of your links in your palette.
I see. However I don’t experience this behavior Here I took your coordinates :
public paletteLinkData: Array<go.ObjectData> = [
{ points: new go.List(/*go.Point*/).addAll([new go.Point(0, 0), new go.Point(30, 0), new go.Point(30, 40), new go.Point(60, 40)]) },
{ points: new go.List(/*go.Point*/).addAll([new go.Point(20, 20), new go.Point(60, 20), new go.Point(60, 40), new go.Point(60, 50)]) },
{ points: new go.List(/*go.Point*/).addAll([new go.Point(900, 900), new go.Point(930, 900), new go.Point(930, 940), new go.Point(960, 940)]) }
];
That’s odd. I cannot explain that. If you make a copy of the Draggable Link sample, and only make the change to the link data of the palette’s model that I did, do you not get the same result that I did?
If you do, then how did you initialize your Palette?
one other problem with this approach, is that I want to have different kind of links in the palette. How would I add a link with strokes ? I tried the following with no luck:
public paletteLinkData: Array<go.ObjectData> = [
{
points: new go.List(/*go.Point*/).addAll([new go.Point(0, 0), new go.Point(30, 0), new go.Point(30, 40), new go.Point(60, 40)]),
dash: [6, 3], thickness: 4
},
{ points: new go.List(/*go.Point*/).addAll([new go.Point(20, 20), new go.Point(60, 20), new go.Point(60, 40), new go.Point(60, 50)]) },
{ points: new go.List(/*go.Point*/).addAll([new go.Point(900, 900), new go.Point(930, 900), new go.Point(930, 940), new go.Point(960, 940)]) }
];
The GridLayout has Layout.isViewportSized set to true, so the layout will automatically be invalidated when the window “resize” event happens. But I cannot explain why you are getting the behavior that you are. Precisely which versions of GoJS and gojs-angular are you using?
The link template is like any other template – add whatever Bindings you need.
I have no idea if the version of Angular could be causing the problem. I would tend to doubt it.
Maybe the problem involves the timing in which the Palette is initialized and its HTMLDivElement are sized by the page. Can you find out if your code to set up the Palette and its model is being called at a time when the HTMLDivElement does not have the size it should be getting at a steady state (i.e. without any window resizing). If so, wait until the Div has the right size. Or force the layout to happen again when it does get the right size.
Been debugging step by step and I noticed that initially the shapes are positioned correctly in the palette. But at one point, the arrows move to the top. I noticed this happen here: