首页 技术 正文
技术 2022年11月17日
0 收藏 335 点赞 2,396 浏览 570 个字

原文:https://segmentfault.com/a/1190000008077830

1、 安装 ng2-charts

npm install ng2-charts –save
2、 还必须引入 chart.js

npm install chart.js –save
3、 主模块中引入

import { ChartsModule } from ‘ng2-charts/ng2-charts’;
imports: [
ChartsModule
]
4、 如果使用angular-cli那么如下配置 angular-cli.json

“scripts”: [
“../node_modules/chart.js/dist/Chart.bundle.min.js”
]
有时候需要ng serve 重新启动服务,要不然会报错,坑了好久。

5、 然后就可以使用了参考api文档,添加html界面和配置js文件

http://www.bootcss.com/p/chart.js/docs/
http://valor-software.com/ng2-charts/

问题:执行完 npm install ng2-charts –save 发现原来node_modules中的包好多被删除了!

原因:因为ng2-charts依赖的一些包的版本比较旧,所以被移除了,首先去执行一下npm update,然后再去安装插件,就可以了。

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,999
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,511
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,357
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,140
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,770
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,848