Angular6使用echarts外掛
阿新 • • 發佈:2018-12-21
1.安裝
npm install echarts --save
npm install ngx-echarts --save
2.在angular.json檔案中引入echarts.min.js
3.在使用的module.ts匯入模組
4.對應html
<div echarts [options]="chartOptions" class="demo-chart"></div>
5.對應ts屬性配置
this.chartOptions = {
title: {
text: 'ECharts 資料統計'
} ,
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow' // 預設為直線,可選為:'line' | 'shadow'
}
},
legend: {
data: ['使用者來源']
},
xAxis: {
data: ["Android", "IOS", "PC", "Ohter"]
},
yAxis: {
},
series: [{
name: '訪問量',
type: 'line',
data: [500, 200, 360, 100]
}]
}
效果圖: