我正在运行此代码并且在输出中没有任何内容。积累没有错误,但我无法找出错误。谁能告诉我可能是什么问题?此致
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script src="Dependencies/Angular/angular.js"></script>
<script src="Dependencies/D3/d3.js"></script>
<script src="Dependencies/nvd3/nv.d3.js"></script>
<script src="Dependencies/Angularjs-nvd3-Directives/angularjs-nvd3-directives.js"></script>
<link rel="stylesheet"href="Dependencies/nvd3/nv.d3.css">
<script>
var app = angular.module("nvd3TestApp", ['nvd3ChartDirectives']);
function ExampleCtrl($scope){
$scope.exampleData = [
{
"key": "Series 1",
"values": [ [ 1025409600000 , 0] , [ 1309406400000 , 121.92388706072] , [ 1312084800000 , 116.70036100870] , [ 1314763200000 , 88.367701837033] , [ 1317355200000 , 59.159665765725] , [ 1320033600000 , 79.793568139753] , [ 1322629200000 , 75.903834028417] , [ 1325307600000 , 72.704218209157] , [ 1327986000000 , 84.936990804097] , [ 1330491600000 , 93.388148670744]]
}];
}
</script>
</head>
<body ng-app='nvd3TestApp'>
<div ng-controller="ExampleCtrl">
<nvd3-line-chart data="exampleData"
showXAxis="true"
showYAxis="true"
tooltips="true"
interactive="true">
</nvd3-line-chart>
</div>
</body>
</html>
答案 0 :(得分:0)
作为控制者的全球职能在角度上已经支持了很长一段时间......因为1.2xx
左右
试
var app = angular.module("nvd3TestApp", ['nvd3ChartDirectives']);
app.controller('ExampleCtrl', function($scope) {
$scope.exampleData = [{
"key": "Series 1",
"values": [
......
]
}];
});
答案 1 :(得分:0)
我相信我已经用你的代码解决了你的问题。我没有加载任何CSS,所以你可能必须添加你的css使它看起来正确。我还会在结束</body>
标记之前将脚本标记移动到正确的位置。这样你的代码就不会在dom加载之前运行。这将防止将来出现一些令人头疼的问题。
实时预览:http://codepen.io/larryjoelane/pen/OMQqMd
JavaScript / Angular Code:
var app = angular.module("nvd3TestApp", ['nvd3ChartDirectives']).controller("ExampleCtrl", function($scope) {
$scope.exampleData = [{
"key": "Series 1",
"values": [
[1025409600000, 0],
[1309406400000, 121.92388706072],
[1312084800000, 116.70036100870],
[1314763200000, 88.367701837033],
[1317355200000, 59.159665765725],
[1320033600000, 79.793568139753],
[1322629200000, 75.903834028417],
[1325307600000, 72.704218209157],
[1327986000000, 84.936990804097],
[1330491600000, 93.388148670744]
]
}];
})();