Chart.vue 2.44 KB
Newer Older
SHINDAESUB committed
1
<template>
SHINDAESUB committed
2 3 4 5
    <v-card 
        dense
        height="400"
        class="elevation-0"
SHINDAESUB committed
6
        :disabled="step < 4"
SHINDAESUB committed
7 8 9 10 11 12 13 14
    >
      <v-toolbar
          class="elevation-0 "
          dense
      >
          <v-toolbar-title>통계</v-toolbar-title>
          <v-spacer></v-spacer>
      </v-toolbar>
SHINDAESUB committed
15
      <div v-if="result.length !== 0" class=" pa-0 ma-0">
SHINDAESUB committed
16 17 18
        <DoughnutChart
            class="mt-3 pa-0 ma-0"
            :chart-data="totalColl"
SHINDAESUB committed
19
            :height="220"
SHINDAESUB committed
20 21 22 23 24
            :percent="percent"
        />
        <v-card-text>
          <v-list-item>
            <v-list-item-subtitle>응답 속도 합계</v-list-item-subtitle>
SHINDAESUB committed
25
            <v-list-item-title>{{total === 0 ? 0 +' sec' : total.toFixed(2) + ' sec'}}</v-list-item-title>
SHINDAESUB committed
26 27 28 29
          </v-list-item>

          <v-list-item>
            <v-list-item-subtitle>응답 속도 평균</v-list-item-subtitle>
SHINDAESUB committed
30
            <v-list-item-title>{{total/counter === 0 ? 0 +' sec' : (total/counter).toFixed(2) + ' sec'}} </v-list-item-title>
SHINDAESUB committed
31 32 33
          </v-list-item>
        </v-card-text>
      </div>
SHINDAESUB committed
34 35 36 37
    </v-card>
</template>

<script>
SHINDAESUB committed
38 39
import DoughnutChart from '../../components/DoughnutChart.vue'

SHINDAESUB committed
40 41 42
export default {
    data () {
      return {
SHINDAESUB committed
43 44 45 46 47
        total:0,
        totalColl:{},
        success:0,
        fail:0,
        percent:0
SHINDAESUB committed
48 49
      }
    },
SHINDAESUB committed
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80

    props: {
        step:Number,
        wpo:String,
        infos:Array,
        project:Object,
        result:Array,
        counter:Number
    },

    mounted(){
      this.totalColl = {
          labels: ['성공','실패'],
          datasets: [
              {
                  backgroundColor: ['#4CAF50' ,'#F44336'],
                  data: [ this.success ,this.fail],
              }
          ],
      }
    },

    components: {
        DoughnutChart,
    },

    watch:{
        result(current){
          
          if(current.length !== 0){
            
SHINDAESUB committed
81 82
            this.total = this.total + current[current.length-1]['time']
            current[current.length-1]['result'] === 0 ?  ++ this.fail : ++this.success  
SHINDAESUB committed
83
            
SHINDAESUB committed
84
            this.percent = Math.round((100 * this.success ) / this.counter)
SHINDAESUB committed
85 86 87 88 89 90 91 92 93 94 95 96 97 98

            this.totalColl = {
                labels: ['성공','실패'],
                datasets: [
                    {
                        backgroundColor: ['#4CAF50' ,'#F44336'],
                        data: [ this.success ,this.fail],
                    }
                ],
            }
          }
        }
    }

SHINDAESUB committed
99 100 101 102 103 104
}
</script>

<style>

</style>