【问题标题】:How to hide an edge of vis.js using angularjs如何使用 angularjs 隐藏 vis.js 的边缘
【发布时间】:2016-04-27 09:17:12
【问题描述】:

我想在 angularjs 控制器中隐藏节点及其所有相关边。我正在使用 angular-vis.js。我的代码只能隐藏节点,但不能隐藏边。

$scope.hideSelection = function() 
{ 
    $scope.data.nodes.update([{id: $scope.selectedNode.toString(), hidden: true}]); // this part is working fine
    $scope.hiddenNodes.push($scope.selectedNode);

    if ($scope.selectedEdges.length > 0){
       $scope.selectedEdges.forEach(function(edgeId){
           $scope.data.edges.update([{id: edgeId.toString(), hidden: true}]); // When it comes here it not doing the update as it did on nodes
           $scope.hiddenEdges.push(edgeId);
       });
    } 
}

这是我的plunker 的链接以查看完整示例

【问题讨论】:

    标签: angularjs vis.js


    【解决方案1】:

    将边缘传递给$scope.data 的问题不是 vis.DataSet:

    $scope.data = 
    {
      nodes: new vis.DataSet(nodes),
      edges: edges //  <==
    };
    

    ==>

     $scope.data = 
    {
      nodes: new vis.DataSet(nodes),
      edges: new vis.DataSet(edges) // <==
    };
    

    [http://plnkr.co/edit/1H1RBZr9KUPrVhAqT6fX]

    【讨论】:

      猜你喜欢
      • 2019-10-28
      • 1970-01-01
      • 2022-01-09
      • 1970-01-01
      • 2016-01-28
      • 2017-03-29
      • 1970-01-01
      • 1970-01-01
      • 2014-10-24
      相关资源
      最近更新 更多