你认为预测起了吗?请留言
配置项如下
// See https://github.com/ecomfe/echarts-stat
var data = [
[96.24, 11.35],
[33.09, 85.11],
[57.60, 36.61],
[36.77, 27.26],
[20.10, 6.72],
[45.53, 36.37],
[110.07, 80.13],
[72.05, 20.88],
[39.82, 37.15],
[48.05, 70.50],
[0.85, 2.57],
[51.66, 63.70],
[61.07, 127.13],
[64.54, 33.59],
[35.50, 25.01],
[226.55, 664.02],
[188.60, 175.31],
[81.31, 108.68]
];
var data1=[
[96.24, 11.35],
[33.09, 85.11],
[57.60, 36.61],
[36.77, 27.26],
[20.10, 6.72],
[45.53, 36.37],
[110.07, 80.13],
[72.05, 20.88],
[39.82, 37.15],
[48.05, 70.50],
[0.85, 2.57],
[51.66, 63.70],
[61.07, 127.13],
[64.54, 33.59],
[35.50, 25.01],
[226.55, 664.02],
[188.60, 175.31],
[81.31, 108.68]
];
data.push([251,30])
data.sort(function(a, b) {
return a[0] - b[0];
});
var myRegression = ecStat.regression('polynomial', data);
var yucedata=myRegression.points.sort(function(a, b) {
return a[0] - b[0];
});
data1.sort(function(a, b) {
return a[0] - b[0];
});
var data2=[];
data2.push(data1[data1.length-1])
data2.push(yucedata[yucedata.length-1])
option = {
title:{
text:'test 预测' ,
subtext:'你认为预测起了吗?请留言'
},
tooltip: {
trigger: 'axis',
formatter:function(params){
if(params.length === 1){
if(params[0].seriesName === 'line1'){
return params[0].axisValue+'<br/>预测:'+params[0].data[1];
}else{
return params[0].axisValue+'<br/>实际:'+params[0].data[1];
}
}else{
return params[0].axisValue+'<br/>实际:'+params[0].data[1];
}
}
},
xAxis: {
type: 'value',
splitLine: {
show:false,
},
splitNumber: 20
},
yAxis: {
type: 'value',
splitLine: {
show:false,
}
},
grid: {
top: 90
},
series: [{
name: 'line',
type: 'line',
lineStyle:{
color:'#600'
},
data: data1
}, {
name: 'line1',
type: 'line',
lineStyle:{
color:'#2aa' ,
type: 'dashed'
},
data: data2,
}]
};