官网地址 https://www.echartsjs.com/zh/index.html
具体使用说明参考 https://github.com/xieziyu/ngx-echarts
安装方法
// 如果需要GL 3D地球模型数据的支持先安装
npm install echarts-gl -S
// 不需要的话直接安装如下
npm install echarts -S
npm install ngx-echarts -S
npm install @types/echarts -D
使用方法
1. 在要使用的模块中导入
import { NgxEchartsModule } from 'ngx-echarts';
@NgModule({
imports: [
NgxEchartsModule],
})
2. 文件内容定义
html:
<div echarts [options]="chartOption" class="demo-chart"></div>
scss:
.demo-chart {
height: 400px;
}
ts:
import { EChartOption } from 'echarts';
// ...
chartOption: EChartOption = {
xAxis: {
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
yAxis: {
type: 'value'
},
series: [{
data: [820, 932, 901, 934, 1290, 1330, 1320],
type: 'line'
}]
}
页面显示