安装
npm i echarts
npm i echarts-stat
调用
data() {
return {
myRegression: []
}
},
computed: {
return {
trendLineOption() { //趋势分析
return {
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'line'
}
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
top: '2.5%',
containLabel: true
},
xAxis: {
type: 'category',
data: this.lineXaxis,
boundaryGap: false,
axisLabel: {
rotate: 40
}
},
yAxis: {
type: 'value'
},
series: [{
data: this.lineData,
type: 'line'
}, {
type: "line",
showSymbol: false,
lineStyle: {
type: "dashed",
color: "#999"
},
smooth: true,
data: this.myRegression.points
}]
}
}
}
}
methods: {
// 回归分析
ecStat() {
this.myRegression = ecStat.regression('polynomial', this.trendData, 4);
this.myRegression.points.sort((a, b) => {
return a[0] - b[0];
})
console.log(this.myRegression);
}
}
网友评论