@@ -161,6 +161,10 @@ Diagram.prototype={
}
this.xratio=this.xAxisLength/(this.xMax-this.xMin);
this.yratio=this.yAxisLength/(this.yMax-this.yMin);
+
+ //绘制数据滤波
+ this.line.datas=Utils.waveFilter(this.line.datas,6)
this.render(diagramData.descTxt);
},
@@ -192,8 +196,7 @@ Diagram.prototype={
drawCurve:function(){
var points=this.line.datas; //[[1,10.5],[1.5,11.8],[2,15],[2.5,14.2],[2.8,12.2],[3,13.2],[5,11.2]];
-
- var g=this.curveShape.graphics;
+ var g=this.curveShape.graphics;
g.setStrokeStyle(1);
g.beginStroke(this.line.colorAry[0]);
g.moveTo(this.getX(points[0][0]),this.getY(points[0][1]));
@@ -54,6 +54,22 @@ export default {
return ary.length - 1;
+ },
+ waveFilter:function(datas,winsize){
+ let fileterWin=[]
+ let sumWin=0
+ let outItm=null
+ let rst=datas.map((data,index)=>{
+ if(index>=winsize){
+ outItm=fileterWin.shift()
+ sumWin-=outItm[1]
+ }
+ fileterWin.push(data)
+ sumWin+=data[1]
+ return [data[0],sumWin/fileterWin.length]
+ })
+ return rst