【发布时间】:2016-06-21 03:58:32
【问题描述】:
【问题讨论】:
标签: angularjs d3.js nvd3.js c3.js
【问题讨论】:
标签: angularjs d3.js nvd3.js c3.js
似乎你需要 提供文件路径 和 注入依赖项。我认为您将angular-nvd3 称为nvd3
angular-nvd3 是一个封装了原始nvd3 图表库的角度模块。它有 angular directives 帮助您在 Angular 应用程序中使用 nvd3 图表(带有绑定等)。
例如(view it online):
<nvd3 options="options" data="data" class="with-3d-shadow with-transitions"></nvd3>
你必须在 Angular 中使用 "dependecy injection" 是因为 Angular 与第三方模块集成的方式:当你想使用第三方时 Angular 模块,您需要在应用模块定义中将其声明为依赖项。
例如,此语法意味着您声明了一个名为 myApp 的 Angular 应用程序,它依赖于 angular-nvd3:
angular.module('myApp', ['nvd3'])
.controller(...)
.service(...)
除此之外,您还需要在主 html 文件中包含 3rd 方库代码,例如:
<meta charset="utf-8"> <!-- it's important for d3.js -->
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/d3/d3.js"></script>
<script src="bower_components/nvd3/nv.d3.js"></script> <!-- or use another assembly -->
<script src="bower_components/angular-nvd3/dist/angular-nvd3.js"></script>
<link rel="stylesheet" href="bower_components/nvd3/nv.d3.css">
【讨论】: