【问题标题】:Cytoscape Edges CoordinatesCytoscape 边缘坐标
【发布时间】:2018-07-20 06:12:04
【问题描述】:

我在获取边缘坐标 (x, y) 时遇到问题。
有什么解决办法吗?

cy.on('tap', function(e) {
    if (e.cyTarget === cy) {
        ...
    }
});

【问题讨论】:

    标签: cytoscape.js


    【解决方案1】:

    您可以使用midpoint 方法获取边缘的模型位置坐标:

    cy.on('tap', function(e){
        // Checking if the target is not the background and if it is an edge
        if(typeof e.cyTarget.isEdge !== 'undefined' && e.cyTarget.isEdge()) {
            // Logging its position
            console.log(e.cyTarget.midpoint());
        }
    });
    

    更多关于midpoint方法的信息可以在here找到。

    【讨论】:

    • 修改了答案,因为第一个版本有错误的方法。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-06-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多