cytoscape:改变第二轴出租车分支的长度

2024-03-15

I want to create a tree with different branch lengths, looking like this:looking like this Is there a possibility of assigning a length to the secondary axis of taxi trees? I tried to assigning a weight to a branch, but every branch has the same length in the x-asis. In the following you can see my code, maybe you see an error or can help me with this problem. Thank you! window.addEventListener("DOMContentLoaded", function() { var toJson = function(res){ return res.Json(); };

var cy = (window.cy = cytoscape({
container: document.getElementById("cy"),

// demo your layout
layout: {
  name: "dagre",
  rankDir: 'LR'

  // some more options here...
},

style: [{
    selector: "node",
    style: {
      //"background-color": "#dd4de2",
      'background-color': '#9dbaea',
      'border-color': 'white',
      'border-style': 'solid',
      'border-width': 0.3,
      'text-valign': 'center',
      'text-halign': 'right',
      'height': 5,
      'width': 5,
      'font-size': 3,
    }
  },
  {
    selector: ".leaf",
    style: {
      "background-color": "red",
      'content': 'data(id)',
      'font-size': 6,
      'height': 5,
      'width': 5,
    }
  },
  {
    selector: ".root",
    style: {
      "background-color": "#9dbaea",
      'font-size': 4,
      'content': "root",
      'height': 5,
      'width': 5,
    }
  },
  {
    selector: "edge",
    style: {
      'width': 1,
      'length': 'data(weight)',
      //'target-arrow-shape': 'vee',
      'line-color': 'black',
      //'target-arrow-color': '#9dbaea',
      'curve-style': 'taxi',
      //needs to be updated depending no edgeweight
      'taxi-turn': '100px',
      'taxi-direction': 'vertical',
      'edge-distances': 'node-position',
      opacity: 0.7
    }
  }
],
elements: {
  nodes: [
      { data: { id: 'inner_n0', type: 'taxi' } },
      { data: { id: 'inner_n1', type: 'taxi' } },
      { data: { id: 'inner_n2', type: 'taxi' } },
      { data: { id: 'inner_n3', type: 'taxi' } },
      { data: { id: 'cell1' } },
      { data: { id: 'cell2' } },
      { data: { id: 'cell3' } },
      { data: { id: 'cell4' } },
      { data: { id: 'cell5' } },
    ],
    edges: [
      { data: { source: 'inner_n0', weight:'10', target: 'inner_n1' }, "classes": 'taxi'  },
      { data: { source: 'inner_n0', weight:'10', target: 'inner_n3' }, "classes": 'taxi'  },
      { data: { source: 'inner_n1', weight:'10', target: 'inner_n2' }, "classes": 'taxi'  },
      { data: { source: 'inner_n1', weight:'10', target: 'cell2' }, "classes": 'taxi'  },
      { data: { source: 'inner_n2', weight:'5', target: 'cell3' }, "classes": 'taxi'  },
      { data: { source: 'inner_n3', weight:'5', target: 'cell1' }, "classes": 'taxi'  },
      { data: { source: 'inner_n3', weight:'20', target: 'cell5' }, "classes": 'taxi'  },
      { data: { source: 'inner_n2', weight:'10', target: 'cell4' }, "classes": 'taxi'  }
    ]
}

//elements: fetch('input.json').then(toJson),
}));

cy.nodes().leaves().addClass("leaf");
cy.nodes().roots().addClass("root");
});

    <!doctype html>

<html>

  <head>
    <title>phylogenetic tree</title>

    <script src="https://unpkg.com/cytoscape/dist/cytoscape.min.js"></script>

    <script src="https://unpkg.com/browse/[email protected] /cdn-cgi/l/email-protection/dist/dagre.js"></script>
    <script src="https://cdn.rawgit.com/cytoscape/cytoscape.js-dagre/1.5.0/cytoscape-dagre.js"></script>

    <script src="https://cdn.jsdelivr.net/npm/[email protected] /cdn-cgi/l/email-protection/cytoscape-klay.min.js"></script>

    <style>
      body {
        font-family: helvetica;
        font-size: 14px;
      }

      #cy {
        width: 950px;
        height: 650px;
        border-style: double;
        border-color: coral;
        position: absolute;
        display: block;
        left: 0;
        top: 0;
        z-index: 999;
      }


      h1 {
        opacity: 0.5;
        font-size: 1em;
      }
    </style>

    <script src="code.js"></script>
  </head>

  <body>
    <h1>cytoscape-dagre demo</h1>

    <div id="cy"></div>

  </body>

</html>
    


None

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

cytoscape:改变第二轴出租车分支的长度 的相关文章

  • 如何在bootstrap中默认隐藏侧边栏?

    我在这里有一个很好的参考 作为 Bootstrap 在设计 Web 表单应用程序时的侧边栏 http startbootstrap com template overviews simple sidebar http startbootst
  • 为什么网格项目不居中?

    由于某种原因 两个输入范围使网格中的前两项偏离中心 我假设这是因为它们的影子 DOM 样式 事实真的是这样吗 有谁知道为什么范围使项目 A 和 B 偏离中心 这是一个代码笔 https codepen io tOkyO1 pen QOeKL
  • O(1) 算法确定节点是否是多路树中另一个节点的后代?

    想象一下下面的树 A B C D E F 我正在寻找一种方法来查询 F 是否是 A 的后代 注意 F 不需要是directA 的后代 在这种特殊情况下这是正确的 只需要针对更大的潜在后代节点池测试有限数量的潜在父节点 当测试一个节点是否是潜
  • R Shinydashboard 自定义 CSS 到 valueBox

    我一直在尝试将 valueBox 的颜色更改为自定义颜色 超出 validColors 中可用的颜色 但一直无法这样做 我知道有一种方法可以使用标签来包含自定义 CSS 但是我无法将它们放在正确的位置 ui lt dashboardPage
  • 将输入中每个单词的第一个字符设为大写

    我想知道如何在输入区域自动生成单词的第一个字符 目前我的代码是 Name
  • PHP 共享标头而不使用服务器端脚本?

    到目前为止我总是通过 PHP 解决简单的问题 您有一个包含页眉 菜单 页脚和内容字段的网站 每个页面的页眉 菜单和页脚通常是相同的 在没有 PHP 或任何其他服务器端语言的情况下 如何使页眉 菜单和页脚数据仅存在于一个文件中 例如 您不会有
  • Android中webview的截图方法

    我在 webview 中的 html5 canvas 上画了一些线 并尝试使用下面的代码截取 webview 的屏幕截图 WebView webView WebView findViewById R id webview webView s
  • AngularJS 在指令运行之前通过 AJAX 检索数据

    我正在使用 AngularUIuiMap http angular ui github com directives map实例化谷歌地图的指令 uiMap 指令非常适合处理硬编码数据 mapOptions and myMarkers 但是
  • 如何设置 CSS 网格的最大高度

    我有以下 CSS 网格 grid 3x4 display grid grid template columns 1fr 1fr 1fr grid template rows 1fr 1fr 1fr 1fr grid template are
  • 我的 CSS 未在 Internet Explorer 11 和 Firefox 中加载!仅适用于 Chrome

    我正在创建一个简单的网页 我的 CSS 只能在 Chrome 中使用 它在 Firefox 和 IE11 中都不起作用 这是我的 HTML h1 b u Adding a new Visitor u b h1 br div class wr
  • 设置浏览器窗口最小化的最小尺寸限制?

    有没有办法在所有浏览器中手动设置浏览器窗口的最小尺寸 你可以试试 body min width 600px 一旦视口小于 600 像素 您将得到一个水平滚动条 这仅适用于支持 min width CSS 属性的现代浏览器 我认为不可能限制用
  • JSF 2.1 中的 HTML 4 <按钮>

    我想使用以下命令 The JSF
  • 用隐藏单元格补充 colspanned 表格有什么不好吗?

    我一直在表格上开发一些排序和选择功能 我发现在具有跨单元格的表格中定位非常困难 我只是添加了跨区单元格并将其隐藏 它看起来不错 它与我的 js 一起工作 非常适合索引 但我想知道这是否是合法的方法 stuffing display none
  • VBA / HTML / jQuery 选择自动完成 - 在列表中选择

    我正在尝试使用 Excel 中的 VBA 在网站的列表中选择一个值 这不是一个 正常列表 该网站使用 jQuery 选择自动完成 如下所示 example http davidwalsh name demo jquery chosen ph
  • 如何更改 Bootstrap 3 div 列顺序

    正在做我的第一个响应式设计 在 Bootstrap 3 中可能会出现类似的情况 在 lg 上更改此设置 a b c sm 上的这个 a c b 您可以使用两个 div 一个用于第一类型的布置 另一个用于第二类型的布置 第一个仅在 lg 中显
  • 在d3.js中将2D形状转换为3D,并根据ANGULAR中的值调整高度

    我正在使用 d3 js v6 创建以下 2D 图表表示的 3D 图表 这个圆圈中有多个正方形 每个正方形都根据值分配了一种颜色 值越大 正方形越暗 现在我想将其转换为 3D 形状 其中当值变高时 只有特定正方形的高度会增加 因此结果在某种程
  • 如何将送货地址复制到帐单地址

    我想知道是否可以将送货地址复制到帐单地址 当用户单击与送货地址相同的复选框时 送货地址值将被复制到账单输入字段 我完成了大部分部分 但我不确定如何将选择菜单 状态 值复制到帐单地址 我真的很感谢任何帮助 My code document r
  • 我可以停止 :hover 应用于元素吗?

    假设我有一些 CSS button hover font weight bold 我怎样才能防止 hover随意应用样式 我的目标用例是当元素被禁用时 例如 使用这个 HTML
  • 单击引导分页链接时调用 jquery 函数

    我想在单击引导分页链接时调用 jquery 函数 假设我想从第1页遍历到第2页 应该调用一个jquery函数 我正在使用以下代码 但它不起作用 ul pagination on click li function alert page ch
  • 应用对数来导航树

    我曾经知道一种使用对数从树的一片叶子移动到树的下一个 有序 叶子的方法 我认为它涉及获取 当前 叶子的位置值 排名 并将其用作从根向下到新目标叶子的新遍历的种子 一直使用对数函数测试来确定是否沿着右或左节点向下到达叶子 我已经不记得如何运用

随机推荐