|
@@ -20,10 +20,11 @@ export default {
|
|
|
paiqidata: new Array(30).fill("-"),
|
|
|
chouqidata: new Array(30).fill("-"),
|
|
|
xData: new Array(30).fill("-"),
|
|
|
+ count: 0,
|
|
|
drawTiming: null,
|
|
|
cdata: {
|
|
|
paiqidata: [],
|
|
|
- paiqidata: [],
|
|
|
+ chouqidata: [],
|
|
|
xData: [],
|
|
|
},
|
|
|
};
|
|
@@ -43,23 +44,31 @@ export default {
|
|
|
methods: {
|
|
|
addData(data) {
|
|
|
// 先扩展数组,然后删除多余元素
|
|
|
- this.paiqidata = [
|
|
|
- ...data.map((item) => item["paiqiliuliang_after"]),
|
|
|
- ...this.paiqidata
|
|
|
- ].slice(0,-1)
|
|
|
- this.chouqidata = [
|
|
|
- ...data.map((item) => item["chouqiliuliang_after"]),
|
|
|
- ...this.chouqidata
|
|
|
- ].slice(0,-1)
|
|
|
- this.xData = [
|
|
|
- ...data.map((item) => item["date"].split(" ")[1]),
|
|
|
- ...this.xData,
|
|
|
- ].slice(0,-1)
|
|
|
- // console.log("pidai",this.paiqidata);
|
|
|
- // console.log(this.xData);
|
|
|
- this.cdata.paiqidata = this.paiqidata;
|
|
|
- this.cdata.chouqidata = this.chouqidata;
|
|
|
- this.cdata.xData = this.xData;
|
|
|
+ console.log("data", data);
|
|
|
+ if (this.count < 30) {
|
|
|
+ for (let i = 0; i < data.length; i++) {
|
|
|
+ this.paiqidata[this.count] = data[i]["paiqiliuliang_after"];
|
|
|
+ this.chouqidata[this.count] = data[i]["chouqiliuliang_after"];
|
|
|
+ this.xData[this.count] = data[i]["date"].split(" ")[1];
|
|
|
+ }
|
|
|
+ this.count++;
|
|
|
+ } else {
|
|
|
+ for (let i = 0; i < data.length; i++) {
|
|
|
+ this.cdata.paiqidata.shift();
|
|
|
+ this.paiqidata.push(data[i]["paiqiliuliang_after"]);
|
|
|
+ this.chouqidata.shift();
|
|
|
+ this.chouqidata.push(data[i]["chouqiliuliang_after"]);
|
|
|
+ this.xData.shift();
|
|
|
+ this.xData.push(data[i]["date"].split(" ")[1]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ console.log("this.paiqidata", this.paiqidata);
|
|
|
+ console.log("this.chouqidata", this.chouqidata);
|
|
|
+ console.log("this.xData", this.xData);
|
|
|
+ this.cdata.paiqidata= this.paiqidata;
|
|
|
+ this.cdata.chouqidata=this.chouqidata;
|
|
|
+ this.cdata.xData=this.xData;
|
|
|
+ console.log("this.cdata", this.cdata);
|
|
|
},
|
|
|
initWebSocket() {
|
|
|
// 连接错误
|