Zalozky, statistika
This commit is contained in:
@@ -1,48 +1,69 @@
|
||||
<template>
|
||||
<div>
|
||||
<vue-table-dynamic :params="params"></vue-table-dynamic>
|
||||
<vue-table-dynamic :params="params" :key="redraw"></vue-table-dynamic>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: ['data'],
|
||||
props: ['fromdate','todate','type','range'],
|
||||
name: 'Stats',
|
||||
data() {
|
||||
return {
|
||||
params: {
|
||||
data: [
|
||||
['', 'Min', 'Max', 'Avg', 'Current'],
|
||||
['', 'Min', 'Max', 'Avg', 'Posledná'],
|
||||
],
|
||||
header: 'row',
|
||||
border: true,
|
||||
stripe: true
|
||||
}
|
||||
stripe: true,
|
||||
height: 0,
|
||||
},
|
||||
redraw: 0,
|
||||
}
|
||||
},
|
||||
mounted: function () {
|
||||
console.log("Mounted");
|
||||
console.log(this.data);
|
||||
let min = null;
|
||||
let max = null;
|
||||
let avg = 0;
|
||||
let current = null;
|
||||
for (var index = 0; index < this.data.length; ++index) {
|
||||
let row = this.data[index];
|
||||
let val = row[1];
|
||||
|
||||
if (min == null) min = val;
|
||||
else if (min > val) min = val;
|
||||
console.log("type=",this.type);
|
||||
var that = this;
|
||||
moment.locale('sk_SK');
|
||||
|
||||
if (max == null) max = val;
|
||||
else if (max < val) max = val;
|
||||
axios.get('/stats/get', {
|
||||
params: {
|
||||
type: this.type,
|
||||
startdate: this.fromdate,
|
||||
enddate: this.todate,
|
||||
range: this.range
|
||||
}
|
||||
})
|
||||
.then(function (response) {
|
||||
console.log("STATS DATA");
|
||||
console.log(that.type);
|
||||
that.params.data[0][0] = 'Čas';
|
||||
if (that.range) {
|
||||
for (var i = 0; i < response.data.length; i++) {
|
||||
var row = response.data[i];
|
||||
let time = moment(row.time).format('LLL');
|
||||
let mean = null;
|
||||
if (row.mean != null) {
|
||||
mean = row.mean.toFixed(2);
|
||||
that.params.data.push([time,row.min,row.max,mean,row.last]);
|
||||
}
|
||||
that.params.height = 400;
|
||||
}
|
||||
} else {
|
||||
that.params.data.push(['Hodnota',response.data[0].min,response.data[0].max,response.data[0].mean.toFixed(2),response.data[0].last]);
|
||||
};
|
||||
console.log(that.params.data);
|
||||
that.redraw += 1;
|
||||
|
||||
avg = avg + val;
|
||||
current = val;
|
||||
}
|
||||
avg = avg / this.data.length;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
});
|
||||
|
||||
this.params.data.push(['Hodnota',min,max,avg.toFixed(2),current]);
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user