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

The nodes in the palette are centered in both horizontal and vertical directions

$
0
0

@forrest wrote:

Hi,How to center the nodes in the palette both horizontally and vertically when there is only one node in the palette,

myDiagram.groupTemplateMap.add("OfGroups",
                $(go.Group, "Auto",
                    {
                        name: "Groups",
                        background: "transparent",
                        computesBoundsAfterDrag: true,

                        layout: $(go.GridLayout,
                            {
                                alignment: go.GridLayout.Position,
                                wrappingColumn: 5,
                                cellSize: new go.Size(1, 1),
                                spacing: new go.Size(4, 4)
                            }),
                    },
                    $(go.Shape, "Rectangle",
                        {
                            fill: null,
                            stroke: "#ff913a",
                            strokeWidth: 2,
                            cursor: "pointer",
                            portId: "",
                            fromLinkable: true,
                            toLinkable: true,
                            fromLinkableSelfNode: true,
                            toLinkableSelfNode: true,
                            fromLinkableDuplicates: true,
                            toLinkableDuplicates: true
                        }),

                    $(go.Panel, "Vertical",
                        {
                            name: "PanelVertical",
                            minSize: new go.Size(20, 20)
                        },

                        new go.Binding("minSize", "minSize").makeTwoWay(),
                            $(go.Panel, "Horizontal",
                                {
                                stretch: go.GraphObject.Horizontal,
                                background: "red"
                            },
                            $(go.TextBlock,
                                {
                                    alignment: go.Spot.Left,
                                    margin: 5,
                                    isMultiline: false,
                                    font: "bold 18px sans-serif",
                                    opacity: 0.75,
                                    stroke: "#404040"
                                },
                                new go.Binding("text", "text").makeTwoWay(),
                                new go.Binding("font", "font").makeTwoWay()
                            )
                        ), // end Horizontal Panel
                        $(go.Placeholder, {padding: 5, alignment: go.Spot.TopLeft})
                    )
                ));

            myPalette = $(go.Palette, "myPaletteDiv",
                {
                    groupTemplateMap: myDiagram.groupTemplateMap,
                    layout: $(go.GridLayout, {wrappingColumn: 1, alignment: go.GridLayout.Position})
                });

            myPalette.model = new go.GraphLinksModel([
                {
                    key: -1024,
                    nodeType: 4,
                    text: "palette",
                    category: "OfGroups",
                    isGroup: "true",
                    font: "bold 13px sans-serif"
                }
            ]);

forrest

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 6969

Trending Articles