【问题标题】:Get nodeDataArray from diagram after edit in GOJS在 GOJS 中编辑后从图中获取 nodeDataArray
【发布时间】:2017-11-28 22:40:34
【问题描述】:

我正在使用 GoJS 制作图表, 我允许对节点进行文本编辑,并在以后创建新节点并编辑节点和链接

        window.diagram =
$(go.Diagram, "myDiagramDiv",
{
  initialContentAlignment: go.Spot.Center, // center Diagram contents
  "undoManager.isEnabled": true, // enable Ctrl-Z to undo and Ctrl-Y to redo
});
           // the node template describes how each Node should be constructed
          diagram.nodeTemplate =
            $(go.Node, "Auto",  // the Shape automatically fits around the TextBlock
            $(go.Shape, "RoundedRectangle",  // use this kind of figure for the Shape
             // bind Shape.fill to Node.data.color
             new go.Binding("fill", "color")),
            $(go.TextBlock,
            { margin: 3 ,// some room around the text
               editable: true },  // permet de le modifier
            // bind TextBlock.text to Node.data.key
            new go.Binding("text", "key")),
         );
          diagram.linkTemplate =
            $(go.Link,
            $(go.Shape),                           // this is the link shape (the line)
            $(go.Shape, { toArrow: "Standard" }),  // this is an arrowhead
            $(go.TextBlock,                        // this is a Link label
            new go.Binding("text", "text"))
        );

我可以得到对象使用

    window.diagram.GraphLinksModel.nodeDataArray

但即使在编辑图表后我也会得到相同的对象数组 编辑后获取 nodeDataArray 和 linkDataArray 有什么帮助吗?

【问题讨论】:

    标签: javascript graph diagram gojs


    【解决方案1】:

    我找到了答案, 我应该在绑定时添加一个函数

        $(go.TextBlock,
                { margin: 3 ,// some room around the text
                   editable: true}, 
                // bind TextBlock.text to Node.data.key
                new go.Binding("text", "key").makeTwoWay()), // makeTwoWayis what i neededd
             );
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多