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

Center Node in TreeLayout with double link

$
0
0

@nekke wrote:

Hi’ im a novice with GoJs so i’m first of all i’m sorry for the request.

I use GoJs with C#, so i try to do a treeflowchart wth some data generated by my source code in c#

I have this code in my html page:

function draw(data, linkData) {
var array = data;
var $ = go.GraphObject.make;
var myDiagram =
$(go.Diagram, “myDiagramDiv”,
{
initialContentAlignment: go.Spot.Top, // center Diagram contents
“undoManager.isEnabled”: true, // enable Ctrl-Z to undo and Ctrl-Y to redo
//initialAutoScale: go.Diagram.Uniform,

                });
        myDiagram.zoomToRect(myDiagram.documentBounds)

        //var model = $(go.TreeModel);

        // define a simple Node template
        myDiagram.nodeTemplate = $(go.Node, "Auto", { defaultAlignment: go.Spot.Center, margin: 4 },
            $(go.Shape,
                new go.Binding("figure", "shape"),
                new go.Binding("width", "width"),
                new go.Binding("height", "height"),
                new go.Binding("fill", "bgcolor"),
                new go.Binding("stroke", "stroke")),
            $(go.TextBlock, { margin: 8, textAlign: "center" }, new go.Binding("text", "text"), new go.Binding("stroke", "color"))
        );


        // define the group template
        myDiagram.groupTemplate =
            $(go.Group, "Auto",
                { // define the group's internal layout
                    layout: $(go.GridLayout, { wrappingColumn: 4 })
                },
                $(go.Shape, "Cloud",
                    new go.Binding("width", "width"),

                    { fill: "yellow", stroke: "gray", strokeWidth: 2 }),
                $(go.Panel, "Vertical",
                    { defaultAlignment: go.Spot.Top, margin: 4 },
                    $(go.Panel, "Vertical",
                        { defaultAlignment: go.Spot.Top },
                        // the SubGraphExpanderButton is a panel that functions as a button to expand or collapse the subGraph

                        $(go.TextBlock,
                            { font: "Bold 18px Sans-Serif", margin: 4 },
                            new go.Binding("text", "key"))
                    ),

                    // create a placeholder to represent the area where the contents of the group are
                    $(go.Placeholder,
                        { padding: new go.Margin(10, 10) })
                )  // end Vertical Panel
            );  // end Group


        myDiagram.layout = $(go.TreeLayout, {angle: 90});
        myDiagram.model.nodeDataArray = array[0];
        myDiagram.model.linkDataArray = array[1];




        // define a Link template that routes orthogonally, with no arrowhead
        myDiagram.linkTemplate =
            $(go.Link,
                $(go.Shape),
                $(go.Shape, { toArrow: "Standard" })); // the link shape

    }

This is the result:
Capture

i would like to put the last node in center of panel…

Thx You

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 7069

Trending Articles