1.安装库和依赖

npm i echarts --save
npm i ngx-echarts --save
npm i resize-observer-polyfill --save-dev

2.相关配置

  在module添加

import { NgxEchartsModule } from 'ngx-echarts';
import * as echarts from 'echarts'; imports: [
NgxEchartsModule.forRoot({ echarts }),
],

3.页面

  ts

import { Component, OnInit } from '@angular/core';
import { EChartsOption } from 'echarts'; @Component({
selector: 'app-demo001',
templateUrl: './demo001.component.html',
styleUrls: ['./demo001.component.scss']
})
export class Demo001Component implements OnInit {
data: EChartsOption = {};
constructor() { } ngOnInit(): void {
this.data = {
title: {
text: 'ECharts 入门示例'
},
tooltip: {},
xAxis: {
data: ['衬衫', '羊毛衫', '雪纺衫', '裤子', '高跟鞋', '袜子']
},
yAxis: {},
series: [{
name: '销量',
type: 'bar',
data: [5, 20, 36, 10, 10, 20]
}]
}
} }

  html

<div echarts [options] = "data"></div>

最新文章

  1. C#体检套餐项目
  2. (译)利用ASP.NET加密和解密Web.config中连接字符串
  3. terminator终端工具
  4. 如何写出安全的API接口
  5. angularJS推荐显示注入写法
  6. To and Fro
  7. merry Christmas
  8. 【ASP.NET】获取网站目录的方法
  9. C# 玩家昵称屏蔽敏感字眼
  10. centos 端口开放及关闭
  11. 微信开放JS-SDK,助力网页开发
  12. js的两种数据类型
  13. CPP之内存分配
  14. yum list失败
  15. win8下Source Insight has not been installed completely问题的解决
  16. Linux 设置程序开机自启动 (命令systemctl 和 chkconfig用法区别比较)
  17. openssl https 单向认证连接成功示例
  18. 写几个简单用artTemplate的例子
  19. Cmake编译opencv下载不了ffmpeg时的解决办法
  20. wamp-php 集成环境的基础配置

热门文章

  1. Hexo博客搭建和简单部署
  2. 使用命令行运行用例时提示python.exe: Error while finding module specification for &#39;testcase_1.Test&#39;.....
  3. 关于 MySQL 嵌套子查询中,无法关联主表字段问题的折中解决方法
  4. 使用time.Time数据类型获取时间报错
  5. Java学习笔记:2022年1月9日(其二)
  6. C++获取含有中文字符的string长度
  7. react系列-从0开始搭建一个react项目
  8. postgresql添加mysql_fdw测试过程
  9. MyBatis的使用七(处理表与表之间的关系)
  10. Windows/office常用的激活工具有哪些