Javascript arbor js-保存和加载图

Javascript arbor js-保存和加载图,javascript,diagram,arbor.js,force-based-algorithm,Javascript,Diagram,Arbor.js,Force Based Algorithm,我使用arbor js使用基于力的算法创建图表 我希望在总能量低于某一点后,能够保存节点的x,y系统坐标,以便在访问图形时可以重新加载它们,以避免从头开始重新处理所有能量 我在这方面遇到了两个问题: sys.energy().sum始终返回NaN 作为替代方案,我决定使用setTimeout在给定时间段后保存图形节点位置 虽然我已经能够将节点x、y系统坐标保存到DB中,但当我尝试使用保存的x、y坐标将数据加载到图形中(使用sys.merge或sys.addNode)时,图形无法显示,并且控制

我使用arbor js使用基于力的算法创建图表

我希望在总能量低于某一点后,能够保存节点的x,y系统坐标,以便在访问图形时可以重新加载它们,以避免从头开始重新处理所有能量

我在这方面遇到了两个问题:

  • sys.energy().sum
    始终返回
    NaN

    • 作为替代方案,我决定使用
      setTimeout
      在给定时间段后保存图形节点位置
  • 虽然我已经能够将节点x、y系统坐标保存到DB中,但当我尝试使用保存的x、y坐标将数据加载到图形中(使用
    sys.merge
    sys.addNode
    )时,图形无法显示,并且控制台日志中出现“内存不足”消息

  • 下面是一个保存了节点x、y系统坐标的数据示例,它会导致arbor js在加载时崩溃:

    {"nodes":{"0":{"edgeCount":0,"x":13.11901,"y":14.89151,"id":0,"name":"Global"},"23":
    
    {"edgeCount":1,"x":18.08981,"y":-0.8355745,"id":23,"name":"Aristotle"},"26":  
    {"edgeCount":1,"x":5.688836,"y":14.86863,"id":26,"name":"Socrates"},"27":
    {"edgeCount":1,"x":14.84461,"y":-1.687457,"id":27,"name":"Christianity"},"34":
    {"edgeCount":1,"x":-2.265221,"y":13.59168,"id":34,"name":"Maths"},"91":
    {"edgeCount":11,"x":5.868572,"y":-1.315289,"id":91,"name":"Plato"},"92":
    {"edgeCount":4,"x":-3.14131,"y":8.81194,"id":92,"name":"Virtue"},"127": 
    {"edgeCount":1,"x":-3.308347,"y":8.463552,"id":127,"name":"Poetry"},"131":
    {"edgeCount":1,"x":7.605158,"y":-3.951363,"id":131,"name":"Wisdom"},"147":
    {"edgeCount":1,"x":6.195698,"y":-4.572639,"id":147,"name":"Person"},"149":
    {"edgeCount":1,"x":2.10395,"y":-2.390886,"id":149,"name":"Republic"},"171":
    {"edgeCount":1,"x":3.359434,"y":-3.996424,"id":171,"name":"Justice"},"172":
    {"edgeCount":1,"x":-0.2544371,"y":-4.218832,"id":172,"name":"Temperance"},"173":
    {"edgeCount":1,"x":-8.773163,"y":2.587845,"id":173,"name":"Courage"},"178":
    {"edgeCount":1,"x":-2.380451,"y":-5.787674,"id":178,"name":"Schopenhauer"},"194":
    {"edgeCount":2,"x":-7.747643,"y":-1.653015,"id":194,"name":"Beauty"},"195":
    {"edgeCount":1,"x":-10.45985,"y":-2.670299,"id":195,"name":"Objective"},"196":
    {"edgeCount":1,"x":-10.64573,"y":-6.874766,"id":196,"name":"Truth"},"219":
    {"edgeCount":1,"x":-6.22574,"y":-7.565969,"id":219,"name":"Theory of forms"},"221":
    {"edgeCount":1,"x":-8.314561,"y":-7.570002,"id":221,"name":"Platinus"},"245":
    {"edgeCount":0,"x":-13.20351,"y":-8.421284,"id":245,"name":"Diagram"},"254":
    {"edgeCount":1,"x":-13.54734,"y":-7.7437,"id":254,"name":"Green"}},
        "edges":{"23":{"91":{"context":{"id":0,"name":"Global"},"source":
    {"id":23,"name":"Aristotle"},"predicate":{"id":21,"name":"studied with"},"target":
    {"id":91,"name":"Plato"}}},"26":{"91":{"context":{"id":0,"name":"Global"},"source":
    {"id":26,"name":"Socrates"},"predicate":{"id":2,"name":"inspires"},"target":
    {"id":91,"name":"Plato"}}},"91":{"149":{"context":{"id":0,"name":"Global"},"source":
    {"id":91,"name":"Plato"},"predicate":{"id":1,"name":"writes"},"target":
    {"id":149,"name":"Republic"}},"219":{"context":{"id":0,"name":"Global"},"source":
    {"id":91,"name":"Plato"},"predicate":{"id":1,"name":"writes"},"target":{"id":219,"name":"Theory of forms"}},"27":{"context":{"id":0,"name":"Global"},"source":{"id":91,"name":"Plato"},"predicate":
    {"id":3,"name":"influences"},"target":{"id":27,"name":"Christianity"}},"178":{"context":
    {"id":0,"name":"Global"},"source":{"id":91,"name":"Plato"},"predicate":
    {"id":3,"name":"influences"},"target":{"id":178,"name":"Schopenhauer"}},"221":{"context":
    {"id":0,"name":"Global"},"source":{"id":91,"name":"Plato"},"predicate":
    {"id":3,"name":"influences"},"target":{"id":221,"name":"Platinus"}},"254":{"context":
    {"id":245,"name":"Diagram"},"source":{"id":91,"name":"Plato"},"predicate":
    {"id":28,"name":"is"},"target":{"id":254,"name":"Green"}},"34":{"context":
    {"id":0,"name":"Global"},"source":{"id":91,"name":"Plato"},"predicate":{"id":33,"name":"is associated with"},"target":{"id":34,"name":"Maths"}},"127":{"context":
    {"id":0,"name":"Global"},"source":{"id":91,"name":"Plato"},"predicate":{"id":47,"name":"is obsessed with"},"target":{"id":127,"name":"Poetry"}},"147":{"context":
    {"id":0,"name":"Global"},"source":{"id":91,"name":"Plato"},"predicate":{"id":56,"name":"is type of"},"target":{"id":147,"name":"Person"}}},"92":{"131":{"context":{"id":91,"name":"Plato"},"source":
    {"id":92,"name":"Virtue"},"predicate":{"id":28,"name":"is"},"target":
    {"id":131,"name":"Wisdom"}},"171":{"context":{"id":91,"name":"Plato"},"source":
    {"id":92,"name":"Virtue"},"predicate":{"id":28,"name":"is"},"target":
    {"id":171,"name":"Justice"}},"172":{"context":{"id":91,"name":"Plato"},"source":
    {"id":92,"name":"Virtue"},"predicate":{"id":28,"name":"is"},"target":
    {"id":172,"name":"Temperance"}},"173":{"context":{"id":91,"name":"Plato"},"source":
    {"id":92,"name":"Virtue"},"predicate":{"id":28,"name":"is"},"target":
    {"id":173,"name":"Courage"}}},"194":{"195":{"context":{"id":91,"name":"Plato"},"source":
    {"id":194,"name":"Beauty"},"predicate":{"id":28,"name":"is"},"target":
    {"id":195,"name":"Objective"}},"196":{"context":{"id":91,"name":"Plato"},"source":
    {"id":194,"name":"Beauty"},"predicate":{"id":33,"name":"is associated with"},"target":
    {"id":196,"name":"Truth"}}}}} 
    
    我找不到节点x,y坐标在输入数据中的图形示例。

    查看一下,似乎可以在数据字典中包含x和y值。从您的示例中,我不确定如何将数据传递给方法。也许可以尝试添加几个节点,看看它们放在哪里。我也有同样的问题,能量是NaN。也许使用调试器会有所帮助