问题描述
我需要创建使用网络图一些帮助在angularjs。我工作的实现类似的
I need some help in creating a network graph using visjs in angularjs. I am working on this plunker to achieve something like this
我跟着的,但无法让它工作,所以我创建plunker(上述)从社区获得帮助。
I followed the steps mentioned in AngularJS - visjs but was unable to make it work so I created a plunker (given above) to get help from community.
控制器code。
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
};
}
]);
请帮我在这
推荐答案
我看到的几个问题。首先,你包括你的CSS文件作为脚本而不是作为样式表。所以用这个:
I saw a few issues. First, you were including your css files as scripts instead of as stylesheets. So use this:
<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">
二,如果你看一看角vis.js,你会看到该指令实际上应该是VIS-时间表。所以我就改成了这个在html:
Second if you take a look at angular-vis.js, you'll see that the directive should actually be vis-timeline. So I just changed it to this in the html:
<vis-timeline data="data" options="options"></vis-timeline>
我删除的事件属性,因为,这不是你的范围界定,但我相信你可以看看visjs文档,看看有什么应该去那里。
I removed the events attribute because that wasn't defined on your scope, but I assume you can look at the visjs documentation to see what should go there.
请参阅修订整个修复。
这篇关于如何创建网络图或使用visjs在angularjs层次树?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!