【问题标题】:How to create network graph or hierarchical tree using visjs in angularjs?如何在angularjs中使用visjs创建网络图或分层树?
【发布时间】:2015-09-09 03:43:11
【问题描述】:

在使用 angularjs 中的 visjs 创建网络图时,我需要一些帮助。我正在研究this plunker 以实现this 之类的目标

我按照AngularJS - visjs 中提到的步骤操作,但无法使其正常工作,因此我创建了一个 plunker(如上所示)来获得社区的帮助。

控制器代码。

var app = angular.module('app', ['ngVis']);

app.controller('MainCtrl', ['$scope', 'VisDataSet',

  function($scope, VisDataSet) {
      $scope.data = VisDataSet({
          "1": {
              "id": 1,
              "content": "<i class=\"fi-flag\"></i> item 1",
              "start": "2014-09-01T17:59:13.706Z",
              "className": "magenta",
              "type": "box"
          },
          "2": {
              "id": 2,
              "content": "<a href=\"http://visjs.org\" target=\"_blank\">visjs.org</a>",
              "start": "2014-09-02T17:59:13.706Z",
              "type": "box"
          },
          "3": {
              "id": 3,
              "content": "item 3",
              "start": "2014-08-29T17:59:13.706Z",
              "type": "box"
          },
          "4": {
              "id": 4,
              "content": "item 4",
              "start": "2014-09-01T17:59:13.706Z",
              "end": "2014-09-03T17:59:13.706Z",
              "type": "range"
          },
          "5": {
              "id": 5,
              "content": "item 5",
              "start": "2014-08-30T17:59:13.706Z",
              "type": "point"
          },
          "6": {
              "id": 6,
              "content": "item 6",
              "start": "2014-09-04T17:59:13.706Z",
              "type": "point"
          },
          "7": {
              "id": 7,
              "content": "<i class=\"fi-anchor\"></i> item 7",
              "start": "2014-08-28T17:59:13.706Z",
              "end": "2014-08-29T17:59:13.706Z",
              "type": "range",
              "className": "orange"
          }
      });
      $scope.options = {
          "align": "center",
          "autoResize": true,
          "editable": true,
          "selectable": true,
          "orientation": "bottom",
          "showCurrentTime": true,
          "showCustomTime": true,
          "showMajorLabels": true,
          "showMinorLabels": true
      };
  }
]);

请帮我找出这个plunker中的问题

【问题讨论】:

  • 是否有任何控制台错误?
  • @pankajparkar:我在控制台中没有收到任何错误。我已经发布了一个持续的question here。请看一看。

标签: angularjs angularjs-directive plunker vis.js


【解决方案1】:

我看到了一些问题。首先,您将 css 文件作为脚本而不是样式表包含在内。所以用这个:

<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/vis/4.3.0/vis.css">
<link rel="stylesheet" type="text/css" href="style.css">

其次,如果您查看 angular-vis.js,您会发现该指令实际上应该是 vis-timeline。所以我只是在html中将其更改为:

<vis-timeline data="data" options="options"></vis-timeline>

我删除了 events 属性,因为它没有在您的范围内定义,但我假设您可以查看 visjs 文档以了解应该去那里。

查看修改后的plunker 了解整个修复。

【讨论】:

  • 感谢 plunker 现在工作,将其更改为网络视图以解决我的实际问题。另外,你怎么说 angular-vis.js 有 vis-timeline 指令。我看到指令名称是visTimeline。请帮助我理解,我想我错过了一些东西,因为我是 angularjs 的新手
  • 这是一个 angular.js 命名约定。看到这个问题:stackoverflow.com/questions/19503121/…
  • 在 angularjs 中为 visjs 设置放大缩小按钮时需要您的帮助。我问了question here。请看一下。谢谢
  • 在这个问题上需要你的帮助:stackoverflow.com/questions/44421653/…
猜你喜欢
  • 2015-09-10
  • 1970-01-01
  • 2013-02-28
  • 1970-01-01
  • 2021-04-17
  • 2017-11-28
  • 1970-01-01
  • 2017-08-03
  • 1970-01-01
相关资源
最近更新 更多