注意:n本人采用最新版本的 echarts4.1.0,ngx-echarts3.1.0angular6.0.0;其余版本可以下载对应的文件
1.通过npm 导入相对应的包
npm install echarts --save
npm install ngx-echarts --save
2.在angular.jsonn文件中引入echart
3.在app.module中引入文件
import { NgxEchartsModule } from “ngx-echarts”;
在importsn中引入NgxEchartsModule
4.在对应页面使用,在component中声明option
this.visitOption= {
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross',
crossStyle: {
color: '#999'
}
}
},
toolbox: {
feature: {
dataView: {show: true, readOnly: false},
magicType: {show: true, type: ['line', 'bar']},
restore: {show: true},
saveAsImage: {show: true}
}
},
legend: {
data:['时间','访问量','平均访问量']
},
xAxis: [
{
type: 'catego