D3js可折叠树减少节点之间的长度

时间:2016-09-15 10:14:21

标签: javascript jquery json d3.js

我在可折叠树中显示json。树显示正常,但节点之间的长度应该减少。请让我知道如何在d3js中执行此操作。

 var treeData = {
      "name": "test",
      "description": "sdfdsfdf",
      "children": [
        {
          "name": "test",
          "description": "test",
          "children": [
            {
              "name": "test",
              "description": "dfdsfdsfdf"
            },
            {
              "name": "truetest",
              "description": "status check",
              "children": [
                {
                  "name": "variable test",
                  "description": "variable test"
                },
                {
                  "name": "variable test",
                  "description": "variable test"
                }
              ]
            },
            {
              "name": "uuuu",
              "description": "trest",
              "destination": "10.154.130.1"
            }
          ]
        }
      ]
    }
        var totalNodes = 0;
        var maxLabelLength = 0;
        // variables for drag/drop
        var selectedNode = null;
        var draggingNode = null;
        // panning variables
        var panSpeed = 200;
        var panBoundary = 20; // Within 20px from edges will pan when dragging.
        // Misc. variables
        var i = 0;
        var duration = 750;
        var root;

相同的plunker链接是:http://plnkr.co/edit/uGnQMihoHM1BU1YGPUYv?p=preview

1 个答案:

答案 0 :(得分:-1)

链接的高度和宽度分别在第355行和dndTree.js文件的第363-368行的函数中设置。