首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >节点的GoJS位置

节点的GoJS位置
EN

Stack Overflow用户
提问于 2014-09-04 13:51:45
回答 1查看 4.6K关注 0票数 1

就像我可以做的那样,使GoJS中的所有元素在一个组中相互在线,而不是像它们当前显示的那样成对,所以我想:

S -> A -> B -> E

但实际上是这样的:

S -> A

B -> E

在这里,我在jsFiddle,中给出了一个例子,非常感谢您的帮助。

代码语言:javascript
复制
    // Groups consist of a title in the color given by the group node data
    // above a translucent gray rectangle surrounding the member parts
    myDiagram.groupTemplate =
      $(go.Group, "Horizontal",
        { selectionObjectName: "PANEL",  // selection handle goes around shape, not label
          ungroupable: true },  // enable Ctrl-Shift-G to ungroup a selected Group
        $(go.TextBlock,
          {
            font: "13px sans-serif",
            isMultiline: false,  // don't allow newlines in text
            editable: true  // allow in-place editing by user
          },
          new go.Binding("text", "text").makeTwoWay(),
          new go.Binding("stroke", "color")),
        $(go.Panel, "Auto",
          { name: "PANEL" },
          $(go.Shape, "Process",  // the rectangular shape around the members
            { fill: "#FFF", stroke: "#333", strokeWidth: 1, width: 400 }),
          $(go.Placeholder, { padding: 10 })  // represents where the members are
        ),
        { // this tooltip Adornment is shared by all groups
          toolTip:
            $(go.Adornment, "Auto",
              $(go.Shape, { fill: "#FFFFCC" }),
              $(go.TextBlock, { margin: 4 },
                // bind to tooltip, not to Group.data, to allow access to Group properties
                new go.Binding("text", "", groupInfo).ofObject())
            )
        }
      );
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-09-10 14:06:53

在组内使用GridLayout:

代码语言:javascript
复制
myDiagram.groupTemplate =
  $(go.Group, "Horizontal",
    { selectionObjectName: "PANEL",  // selection handle goes around shape, not label
      ungroupable: true,
      layout: $(go.GridLayout)
    },

此外,要使布局中的节点居中,可以将locationSpot设置为中心:

代码语言:javascript
复制
myDiagram.nodeTemplate =
  $(go.Node, "Auto",
    { locationSpot: go.Spot.Center },

注意,S和E节点很高,因为它们的定义很高,所以看起来它们偏离了中心,但它们不是(选择它们来看看我的意思)。

http://jsfiddle.net/rb7nyxfd/6/

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25667246

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档