我正在使用NVD3.js库来生成图形。我尝试在其中添加折线图&得到上述错误。如何解决?
我正在尝试here
答案 0 :(得分:4)
Actually i found out, the problem was the folder structure. The examples that comes with the angular-nvd3 website gives path
bower_components/nvd3/nv.d3.js
, check in your bower_components file the actual path would be
bower_components/nvd3/build/nv.d3.js
Similarly the nv.d3.css path is NOT
bower_components/nvd3/nv.d3.css
it is,
bower_components/nvd3/build/nv.d3.css
Also, DON'T forget to add
<meta charset="utf-8">
as the first line inside your head tag..
答案 1 :(得分:3)
你可以张贴一个Plunker / Fiddle吗?在我的头顶,它可能只是你包括nv.d3.js的地方。你还包括D3.js吗?
答案 2 :(得分:1)
您是否包含nv.d3.js
&amp; d3.js
因为这些序列也会导致问题尝试首先添加d3.js
答案 3 :(得分:1)
我在使用ionic2时遇到了类似的问题(基于Angular2)。
尽管index.html中包含了所有必需的库。 问题最终是脚本必须包含在之前 离子应用程序加载!!!
<!-- These scripts are copied from node_modules-->
<script src="build/d3.min.js" charset="utf-8"></script>
<script src="build/nv.d3.min.js"></script>
<!-- Ionic's root component and where the app will load -->
<ion-app></ion-app>
答案 4 :(得分:0)
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.8.4/nv.d3.min.css"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js" charset="utf-8"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.8.5/nv.d3.min.js"></script>
&#13;
在index.html中添加这些文件
答案 5 :(得分:0)
如果您使用的是角度2或更高版本,那么
"../node_modules/ng2-nvd3/node_modules/d3/d3.min.js",
"../node_modules/ng2-nvd3/node_modules/nvd3/build/nv.d3.min.js"
只需在scripts
中的.angular-cli.json
数组下添加以上行。