Angular8 引入百度Echarts,進行圖表分析css
原文地址:傳送門html
npm install echarts -S npm install ngx-echarts -S npm install @types/echarts -D
{ "scripts": [ "../node_modules/echarts/dist/echarts.min.js" // or echarts.js for debug purpose ], }
這裏有個坑,記得在你調用了echarts的相關模塊的Module裏面引入NgxEchartsModule,否則會報錯:Template parse errors: Can't bind to 'options' since it isn't a known property of 'div'.因此切記node
import { NgxEchartsModule } from 'ngx-echarts'; @NgModule({ imports: [ ..., NgxEchartsModule ], ... }) export class AppModule { }
<div echarts [options]="chartOption" class="demo-chart"></div>
.demo-chart { height: 400px; }
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' }] }